'NODE_ENV with Jest
I am migrating from Mocha to Jest. My test imports the config package, which selects a configuration file or another depending on the NODE_ENV environment variable. However, it looks like NODE_ENV is found while running the test from Jest
Next line does not work (that is, NODE_ENV is ignored):
NODE_ENV=test jest test/*.js --notify --config jest.config.json
As a consequence the config package reports:
console.error node_modules/config/lib/config.js:1727
WARNING: NODE_ENV value of 'test' did not match any deployment config file names.
Do you know how to include NODE_ENV?
Solution 1:[1]
The warning is from the Strict-Mode. So what you have to do here is..
- Create a file called
test.jsoninsideconfig/ - Add
NODE_ENVvalue astest
That should work
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | alisidaniel |
