nrwl not respecting the cypress --env argument through command line
See original GitHub issueI was not able to understand if I am doing something wrong or it’s a Bug.
I wanted to set my env variable defined in the cypress.json file through the command line. According to the cypress docs, they give 5 different styles to do that. But nrwl is not respecting the cypress –env option (https://docs.cypress.io/guides/guides/environment-variables.html#Option-3-CYPRESS)
My cypress.json File
{
"defaultCommandTimeout": 8000,
"viewportWidth": 1440,
"viewportHeight": 900,
"env": {
"ENVIRONMENT": "Stagging"
},
"fileServerFolder": ".",
"fixturesFolder": "./src/fixtures",
"integrationFolder": "./src/integration",
"pluginsFile": "./src/plugins/index",
"supportFile": "./src/support/index.ts",
"video": true,
"videosFolder": "../../../dist/cypress/apps/web/e2e/videos",
"screenshotsFolder": "../../../dist/cypress/apps/web/e2e/screenshots",
"chromeWebSecurity": false
}
I am using this command ng e2e --env environment=Dev --watch --headless
it’s giving me 'Unknown option: ‘–env’

I also tried using cypress open --env environment=Dev instead of the ng CLI command, the problem here is according to the framework .nodemodules is sitting in projects root folder ‘projectname\node_modules’ , whereas my cypress framework is sitting in ‘projectname\apps\admin-web\ui-e2e’ so, when I am trying to execute cypress open --env environment=Dev' a sample cypress framework and cypress.json file is getting created in the root folder (‘projectname\cypress.json’) and executing cypress example integration tests, instead of my project tests
StackOverflow question https://stackoverflow.com/questions/58440173/how-to-set-environment-variables-in-cypress-json-file-through-command-line-ang
I was not able to figure this out. Can anyone help me with it, Thank you
Issue Analytics
- State:
- Created 4 years ago
- Reactions:7
- Comments:13

Top Related StackOverflow Question
@Yohandah
You can do it this way :
--env.TAGS=@e2e-testsIt seems to work.Can this be re-open? it should allow the env to pass custom variable eg.
--env mock_env