I'm currently initializing a Mocha instance, to which I add files:
const mocha = new Mocha({
ui: "tdd",
color: true,
});
const testsRoot = path.resolve(__dirname);
mocha.addFile(path.resolve(testsRoot, "one.test.js"));
mocha.addFile(path.resolve(testsRoot, "two.test.js"));
mocha.run(...);
This obviously works as expected, as Mocha will require each file.
However, I'm now switching to generating JS code via Kotlin, which will output a single .js file.
The addFile approach becomes impossible.
I'm thus looking for a solution similar to:
const mocha = new Mocha({
ui: "tdd",
color: true,
});
// Made up code
mocha.addSuite("My suite", () => {
suite.test("my test", () => {
// ...
});
);
mocha.run(...);
Does Mocha offer an API that can help for this use case?