Reputation: 231
Cypress is by default run in production mode (process.env.NODE_ENV === 'production'). I want to run it in 'test' mode because I have some functionalities in my code which should not be run under test, for example reporting to Sentry
I have something like this in my application code:
if (process.env.NODE_ENV === 'production' || process.env.NODE_ENV === 'development') {
//report to sentry
}
I have tried to set environment variables in Cypress but it is set only for test files.
"test:e2e": "percy exec -- vue-cli-service test:e2e --mode test"
I have also tried to run command with --mode test but then there is a problem with test runner (is not starting tests)
Regards
Upvotes: 3
Views: 4633
Reputation: 8044
You are passing an option to cypress and not setting an environment variable. If you want to set an environment variable do this on mac,
"test:e2e": "NODE_ENV='development' percy exec -- vue-cli-service test:e2e"
or in windows
"test:e2e": "SET NODE_ENV='development' percy exec -- vue-cli-service test:e2e"
or you can use something more sophisticated like this https://www.npmjs.com/package/cross-env
Upvotes: 2