badeball / cypress-configuration

A re-implementation of Cypress' configuration resolvement and search for test files
MIT License
0 stars 2 forks source link

Cannot use dynamic specPattern #7

Closed rsaleri closed 3 months ago

rsaleri commented 3 months ago

Issue comes from using cypress-parallel. I have the need to segregate some test and then parallelize them. I tried using the tag, but that didn't work since the filtering comes after the cypress-parallel spec strategy.

Seeing that it uses this library to retrieve the specPattern I tried using a dynamic approach using an env variable, but it doesn't resolve the configuration:

> cypress-parallel run --node 1:1

Error: Expected a string literal for specPattern, but got Identifier
    at parseTestingTypeObject (/home/rsaleri/projects/cypress-parallel-issue/node_modules/@badeball/cypress-configuration/dist/cypress-configuration/cypress-post10-configuration-parser.js:38:27)
    at parseTestingTypesObject (/home/rsaleri/projects/cypress-parallel-issue/node_modules/@badeball/cypress-configuration/dist/cypress-configuration/cypress-post10-configuration-parser.js:70:29)
    at parsePost10Configuration (/home/rsaleri/projects/cypress-parallel-issue/node_modules/@badeball/cypress-configuration/dist/cypress-configuration/cypress-post10-configuration-parser.js:165:44)
    at parseConfigurationFile (/home/rsaleri/projects/cypress-parallel-issue/node_modules/@badeball/cypress-configuration/dist/cypress-configuration/cypress-post10-configuration.js:191:83)
    at resolvePost10Configuration (/home/rsaleri/projects/cypress-parallel-issue/node_modules/@badeball/cypress-configuration/dist/cypress-configuration/cypress-post10-configuration.js:112:68)
    at resolveConfiguration (/home/rsaleri/projects/cypress-parallel-issue/node_modules/@badeball/cypress-configuration/dist/cypress-configuration/index.js:73:78)
    at run (/home/rsaleri/projects/cypress-parallel-issue/node_modules/@badeball/cypress-parallel/lib/cli.js:124:83)

Process finished with exit code 1

I put together a Proof of Concept here: https://github.com/rsaleri/cypress-parallel-issue

badeball commented 3 months ago

This is expected behavior, as parsing is best effort. You can use cypress-split instead, which implements a different strategy.

rsaleri commented 3 months ago

Thank you very much, I'll look into it