Reputation: 99
In cypress.json there is one env variable:
"env": {
"AUTH_TOKEN": "token_1"
},
I have multiple users in db and would like to test them separately without editing cypress.json. Cypress documentation provides two possible ways how to override env variables form command line:
cypress run --env AUTH_TOKEN="token_2"
and
AUTH_TOKEN="token_2" cypress run
When I run cypress interface with
npm run cy:open --env AUTH_TOKEN="token_2"
or
AUTH_TOKEN="token_2" npm run cy:open
token_1 does not get overriden with token_2. Why is cypress ignoring options provided in command line?
Upvotes: 4
Views: 6900
Reputation:
npm run
requires a --
to pass parameters to script cy:open
in package.json,
npm run cy:open -- --env AUTH_TOKEN="token_2"
or use yarn
yarn cy:open --env AUTH_TOKEN="token_2"
or bypass the script
yarn cypress open --env AUTH_TOKEN="token_2"
or
npx cypress open --env AUTH_TOKEN="token_2"
Upvotes: 8