Sometimes you might want your test to make use of variables set on an environment-level. Common reasons for this include
The best way to do this is to use NodeJS's native environmental variables.
In your package.json or directly in a terminal set your variable name and value.
package.json
env CI=STAGE mocha
Then in your test or code reference it via process.env.CI. e.g.
process.env.CI
if (process.env.CI === "STAGE") // do something
The value is available from anywhere in a spec file allowing you to set values from it before the tests run. e.g.
const URL = `${process.env.APP_HOST}/${process.env.APP_URI}`; describe('Test the page loads',() { // tests ...
There was an error while loading. Please reload this page.