question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support feature files in a sub directory

See original GitHub issue

Current behavior

In our project we have sub folders with feature files in integration folder. This used to work with previous package, but gives an error with this one.

image

This has been very fun to debug 😃

In this process I actually ended up moving from webpack to esbuild files as I could not make it work with webpack v5. Now I can share a useful stack trace:

`[ERROR] [plugin feature] The “path” argument must be of type string. Received null

../node_modules/common-ancestor-path/index.js:14:4:
  14 Γöé   : parse(a).root !== parse(b).root ? null
     Γò╡     ^

at validateString (internal/validators.js:124:11)
at parse (path.js:818:5)
at commonAncestorPath (C:\ffd\abcdefget\node_modules\common-ancestor-path\index.js:14:5)
at Array.reduce (<anonymous>)
at Object.module.exports [as default] (C:\ffd\abcdefget\node_modules\common-ancestor-path\index.js:17:38)
at compile (C:\ffd\abcdefget\node_modules\@badeball\cypress-cucumber-preprocessor\lib\template.js:36:55)
at C:\ffd\abcdefget\node_modules\@badeball\cypress-cucumber-preprocessor\esbuild.js:13:60
at callback (C:\ffd\abcdefget\node_modules\esbuild\lib\main.js:993:28)
at handleRequest (C:\ffd\abcdefget\node_modules\esbuild\lib\main.js:721:30)

This error came from the “onLoad” callback registered here:

../node_modules/@badeball/cypress-cucumber-preprocessor/esbuild.js:10:18:
  10 Γöé             build.onLoad({ filter: /\.feature$/ }, async (args) => {
     Γò╡                   ~~~~~~

at setup (C:\ffd\abcdefget\node_modules\@badeball\cypress-cucumber-preprocessor\esbuild.js:10:19)
at handlePlugins (C:\ffd\abcdefget\node_modules\esbuild\lib\main.js:855:23)
at Object.buildOrServe (C:\ffd\abcdefget\node_modules\esbuild\lib\main.js:1149:7)
at C:\ffd\abcdefget\node_modules\esbuild\lib\main.js:2110:17
at new Promise (<anonymous>)
at Object.build (C:\ffd\abcdefget\node_modules\esbuild\lib\main.js:2109:14)
at Object.build (C:\ffd\abcdefget\node_modules\esbuild\lib\main.js:1956:51)
at Object.cypressESBuildFilePreprocessor [as handler] (C:\ffd\abcdefget\node_modules\@bahmutov\cypress-esbuild-preprocessor\src\index.js:68:33)
at invoke (C:\Users\abcdef\AppData\Local\Cypress\Cache\8.5.0\Cypress\resources\app\packages\server\lib\plugins\child\run_plugins.js:22:16)
at C:\Users\abcdef\AppData\Local\Cypress\Cache\8.5.0\Cypress\resources\app\packages\server\lib\plugins\util.js:45:14
at tryCatcher (C:\Users\abcdef\AppData\Local\Cypress\Cache\8.5.0\Cypress\resources\app\packages\server\node_modules\bluebird\js\release\util.js:16:23)
at Function.Promise.attempt.Promise.try (C:\Users\abcdef\AppData\Local\Cypress\Cache\8.5.0\Cypress\resources\app\packages\server\node_modules\bluebird\js\release\method.js:39:29)
at Object.wrapChildPromise (C:\Users\abcdef\AppData\Local\Cypress\Cache\8.5.0\Cypress\resources\app\packages\server\lib\plugins\util.js:44:23)
at Object.wrap (C:\Users\abcdef\AppData\Local\Cypress\Cache\8.5.0\Cypress\resources\app\packages\server\lib\plugins\child\preprocessor.js:28:8)
at execute (C:\Users\abcdef\AppData\Local\Cypress\Cache\8.5.0\Cypress\resources\app\packages\server\lib\plugins\child\run_plugins.js:119:27)

Desired behavior

Build should work as normal and not issue a cryptic error message. Webpack version literally threw The "path" argument must be of type string. Received null with stack trace originating in internal node package!

My current workaround is to patch template.js file, specifically the place that assigns value to implicitIntegrationFolder.

{
        // workaround to support sub folders in integration folder
        file: './node_modules/@badeball/cypress-cucumber-preprocessor/lib/template.js',
        find: 'const implicitIntegrationFolder = (0, assertions_1.assertAndReturn)((0, common_ancestor_path_1.default)(...(0, cypress_configuration_1.getTestFiles)(configuration).map(path_1.default.dirname)), "Expected to find a common ancestor path");',
        replace: `const implicitIntegrationFolder = (0, assertions_1.assertAndReturn)((0, common_ancestor_path_1.default)(...(0, cypress_configuration_1.getTestFiles)(configuration).map(path_1.default.dirname).filter(p => p.endsWith('/integration'))), "Expected to find a common ancestor path");`
    }

Test code to reproduce

Simply create a sub folder in integration folder and add a feature file there to reproduce this issue.

Versions

  • Cypress version: 8.5.0
  • Preprocessor version: 12.0.0
  • Node version: 16.15.1

Checklist

  • I’ve read the FAQ.
  • I’ve read Instructions for logging issues.
  • I’m not using cypress-cucumber-preprocessor@4.3.1 (package name has changed and it is no longer the most recent version, see #689).

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
badeballcommented, Aug 8, 2022

This has been fixed in v12.0.1.

0reactions
FDIMcommented, Aug 8, 2022

@badeball I finally managed to reproduce the issue. For some reason if I have multiple files in a sub-folder, I’ll get an error:

image

If I remove “sub copy.feature” file, then it works again.

The only code change I’ve done to webpack-ts example is to make it run with cypress 8.5, it’s probably the same with v10.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Support organizing .feature files into subdirectories of ... - GitHub
Cucumber -Ruby allows to organize .feature files into subdirectories of /features . This structure is useful for example when using folders ...
Read more >
Subdirectories in Cucumber Features - Atomic Spin
Cucumber allows you to add feature subdirectories for organization. Subdirectories work as expected when running the entire cucumber suite.
Read more >
How to organize and execute cucumber features (e.g. in ...
In cucumber you are able to run features in whatever directory you like. This also includes executing features in subdirectories. There are only ......
Read more >
How to organise feature files | Cucumber Blog
A typical way to structure documentation is to use chapters, sections, sub-sections and so on. Each scenario documents an example of the ...
Read more >
Cucumber Features In Subdirectories - Developmentastic
I'm working on a project where we've amassed a decent amount of Cucumber features. Dumping them in the root directory makes it difficult...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found