How would it be possible to set environment variables for Mocha tests under windows OS? I'm only able to add only 1 variable but not more, example:
"name": "node-app",
"version": "1.0.0",
"description": "some app",
"main": "index.js",
"scripts": {
"integration-test": "SET TEST_MODE=handler&mocha tests/test_cases/*.js --reporter spec"
},
"author": "",
This can be done under windows using cross-env without changing the source code, we only need to install it as a dev dependency and then add it to the script line. But still under other linux we can simply do this :
"scripts": {
"integration-test": "env KEY1=YOUR_KEY1 KEY2=YOUR_KEY2 mocha test"
},
I wonder if it is possible to make it happen for windows without additional libraries?
There's a package on npm solving this, called cross-env.
From the documentation:
{
"scripts": {
"build": "cross-env NODE_ENV=production webpack --config build/webpack.config.js"
}
}
You can also set multiple variables easily.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With