Sometimes, we want to run Mocha tests with extra options or parameters.
In this article, we’ll look at how to run Mocha tests with extra options or parameters.
How to run Mocha tests with extra options or parameters?
To run Mocha tests with extra options or parameters, we can set some environment variables before running the tests and then access them from process.env
.
For instance, we run the tests with
env KEY=YOUR_KEY mocha test/*.js
Then in the tests, we get the KEY
environment variable with
const key = process.env.KEY;
Conclusion
To run Mocha tests with extra options or parameters, we can set some environment variables before running the tests and then access them from process.env
.