tnicola / cypress-parallel

Reduce up to 40% your Cypress suite execution time parallelizing the test run on the same machine.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"-a" option: removing the escaped quotes

VinceOPS opened this issue · comments

Hi there! First of all, thanks for this package :-).

I'm doing some experiments with it today, and noticed that the -a option was not working as intended. I did some investigations and noticed that the arguments passed to the yarn script were invalid:

{
  commandArguments: [
    'run',
    'ci:test',
    '',
    '--spec',
    './src/tests/someTestSuite.cy.js',
    '--reporter',
    'cypress-multi-reporters',
    '--reporter-options',
    'configFile=/Users/<...not relevant...>/multi-reporter-config.json',
    '\\"--env',
    'i="smoke"\\"'
  ]
}

cypress-parallel was run using a script command like this:

yarn ci:test-parallel -a '\"--env i="smoke"\"' -d "./src/tests/**/*.cy.js"

The --env option is not taken into account by Cypress.

In settings.js, as a workaround (dirty solution), I did the following change:

- scriptArguments: argv.args ? argv.args.split(' ') : []
+ scriptArguments: argv.args ? argv.args.split(' ').map(arg => arg.replace('\\"', '')) : []

and now the --env option is correctly observed by Cypress.

I'd be glad to propose a fix if the diagnostic is valid!


OS: Mac OS 12.6
CPU: Apple M1 Pro
Shell: zsh
Package manager: yarn v1

Might be somewhat related: #116. But in that case, \" was kept.

@VinceOPS thanks for reporting this. I think in your case the script should be called in this way:

yarn ci:test-parallel '-a --env i=smoke' '-d ./src/tests/**/*.cy.js'

Could you please try this way and let me know if it works?

Hi @tnicola, thanks for answering! I noticed my mistake but didn't think about commenting here, sorry.
I ended up doing:
yarn ci:test-parallel -a \'"--env i=${INCLUDE}"\' <...>`

Ok, that's great to know!Thanks!