To run Mocha tests with extra options or parameters with JavaScript, we get the values from process.argv.
For instance, we write
const argv = require("minimist")(process.argv.slice(2));
console.log("config", argv.config);
to get the command args with process.argv in the Mocha test file.
We then parse it with the minimist library into an object and get the config config.
Then we run the test with
mocha test.js --config=VALUE