question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

nrwl not respecting the cypress --env argument through command line

See original GitHub issue

I 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’

image

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:closed
  • Created 4 years ago
  • Reactions:7
  • Comments:13

github_iconTop GitHub Comments

15reactions
wmedalicommented, Sep 20, 2021

@Yohandah

You can do it this way : --env.TAGS=@e2e-tests It seems to work.

8reactions
AskMarvinVcommented, Jul 1, 2020

Can this be re-open? it should allow the env to pass custom variable eg. --env mock_env

Read more comments on GitHub >

github_iconTop Results From Across the Web

nrwl-nx/community - Gitter
Hey guys, NX environments does not appear to be a suitable replacement for react (non-angular) .env environment variables, as it offers replacement instead...
Read more >
Environment Variables | Cypress Documentation
In Cypress, "environment variables" are variables that are accessible via Cypress.env . These are not the same as OS-level environment variables.
Read more >
Cypress: Can't use --env variables from command line in test file
This returns an error saying that environment is not defined. In my test file I have the following to use the variable from...
Read more >
Cypress v10 Environment Variables - Gleb Bahmutov
What can it do for our user values? Notice that it gets the config passed as the second argument. Let's print the config.env...
Read more >
@nrwl/workspace:run-commands | Nx
When interpolation is not present in the command, all arguments are forwarded to the command by default. This is useful when you need...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found