I have below cypress nodeJS script commands in package.json
"scripts": {
"cy:run": "npx cypress run --browser chrome",
"cy:parallel" : "cypress-parallel -s cy:run -t 4 -d cypress/e2e/features/ -m false -a '"--env ENV=${ENVI}"'"
}
-a
is the argument that is dynamic, That I want to pass while running the tests like ENVI=QA
or ENVI=LIVE
I have tried following things but did not work for me
SET ENVI=QA
npm run cy:parallel
ENVI=QA npm run cy:parallel
$ENVI=QA npm run cy:parallel
Please share the correct way to pass the argument from the command-line
3
Answers
It worked for me with below command:
set the environment variable value like below:
$env:ENVI=QA
(On Windows)and change script command as follow:
Instead of
ENV=${ENVI}
, UseENV=%ENVI%
One way would use
CYPRESS_
prefix.To make things easier (independent of OS) use the package cross-env.
Install
package.json
Tested with a simple test:
You can use
--
to separate the npm command from the cypress command, and everything after it is passed as arguments to the cypress-parallel command: