@darrion.kuhn
You can add the recursive option to Mocha programmatically by setting it in the Mocha options object before calling mocha.run()
.
Here is an example of how to add the recursive option:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
const Mocha = require('mocha'); // Create a new instance of Mocha const mocha = new Mocha({ recursive: true // Set the recursive option to true }); // Add test files to Mocha mocha.addFile('test-file.js'); // Run the tests mocha.run(function(failures) { process.exitCode = failures ? 1 : 0; // exit with non-zero status if there were failures }); |
In this example, we set the recursive
option to true
in the Mocha options object. This tells Mocha to recursively search for test files in subdirectories of the directory specified when running Mocha.
You can customize the Mocha options object by adding any other options you want to set programmatically before running Mocha using mocha.run()
.