Support feature files in a sub directory
See original GitHub issueCurrent 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.
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:
- Created a year ago
- Comments:6 (2 by maintainers)
This has been fixed in v12.0.1.
@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:
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.