Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save craigtaub/7a10ac36c7d8a051ecc32480e2e234fc to your computer and use it in GitHub Desktop.
Save craigtaub/7a10ac36c7d8a051ecc32480e2e234fc to your computer and use it in GitHub Desktop.
const builder = (yargs) => {
// cli/run.js builder()
return yargs
.options({
config: {
config: true,
description: "Path to config file",
},
reporter: {
default: defaults.reporter,
description: "Specify reporter to use",
requiresArg: true,
},
ui: {
default: defaults.ui,
description: "Specify user interface",
requiresArg: true,
},
})
.check((argv) => {
// lib/cli/run-helpers.js handleRequires
// load --requires first, because it can impact "plugin" validation
// lib/cli/run-helpers.js validatePlugin
// validate `--reporter` and `--ui`. Ensures there's only one, and asserts that it actually exists
// Checks keys on Mocha.reporters + Mocha.interfaces
return true;
});
};
const handler = async function (argv) {
const mocha = new Mocha(argv);
try {
// NEXT PHASE
await runMocha(mocha, argv);
} catch (err) {
console.error("\n" + (err.stack || `Error: ${err.message || err}`));
process.exit(1);
}
};
const commands = {
run: {
command: ["$0 [spec..]", "inspect"],
describe: "Run tests with Our-Mocha",
builder,
handler,
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment