menu
Channels
Team

Running Cypress with `npm test` sets NODE_ENV to development

November 14, 2019 at 10:53am

Running Cypress with `npm test` sets NODE_ENV to development

November 14, 2019 at 10:53am (Edited 3 weeks ago)
Hi guys,
I was about to create a issue but I'm sure this is more of a misunderstanding from my part so here goes:
I set up Cypress to run e2e tests on my application, which I run with npm test (cypress open --config-file cypress/cypress.json). My problem is that the CRA docs say that with npm test, NODE_ENV will be automatically set to test but it's not the case here, and I cannot override the value in any way.
Could someone help me setting the correct value for this env var? Thanks :)

November 15, 2019 at 7:43am
You described your environment, but not the actual problem/challenge. What is it that you're trying to do and what's the result vs what you expect? Are you trying to run cypress via the npm test script, but it fails due to how CRA treats the test script and sets up a test environment? If so, why not add a script: "test:e2e": "cypress open --config-file cypress/cypress.json"?
  • reply
  • like
I can correctly run Cypress with the npm test command, and everything runs fine except for the NODE_ENV environment variable, which is supposed to be set to test when using the npm test command, but it is not in my case. Also I just thought about something: I guess I understand why the variable is set to development, it's because I run the app alongside Cypress, with npm start, so that's what sets NODE_ENV to development. But in that case I don't want it to. So how am I supposed to do? Should I use concurrently in npm test?
  • reply
  • like