I am trying to run my cypress integration tests in a different NODE_ENV. The reason for this is because I want my tests to use a different api than the one used in development.
Currently I'm setting the api url by checking the NODE_ENV and then setting the url that way.
if(process.env.NODE_ENV === 'development') {
BASE_URL = 'http://localhost:3001'
} else {
BASE_URL = 'https://api.example.com'
}
When I start the Next server for the cypress tests, I set the NODE_ENV to test.
"ci:start": "set NODE_ENV='test' & next start",
"ci": "cypress run"
Even after setting the NODE_ENV, it always shows up as "development inside the app.
I've also looked at the docs and followed the instructions it has there. It says that:
When running tests with tools like jest or cypress where you need to set specific environment vars only for testing purposes. Test default values will be loaded if NODE_ENV is set to test.
However that is not the case as .env.local is still being loaded and the NODE_ENV does not change.
Any help would be appreciated, thanks.