Skip to content

Instantly share code, notes, and snippets.

@yourtion
Last active May 24, 2021 06:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yourtion/e3b7515104cd88606605001825387570 to your computer and use it in GitHub Desktop.
Save yourtion/e3b7515104cd88606605001825387570 to your computer and use it in GitHub Desktop.
const Mocha = require("mocha");
var constants = Mocha.Runner.constants;
var EVENT_RUN_END = constants.EVENT_RUN_END;
var EVENT_SUITE_BEGIN = constants.EVENT_SUITE_BEGIN;
var EVENT_SUITE_END = constants.EVENT_SUITE_END;
var EVENT_TEST_PASS = constants.EVENT_TEST_PASS;
const t = new Mocha();
t.addFile("./all.spec.js");
/**
* @public
* @class
* @memberof Mocha.reporters
* @extends Mocha.reporters.Base
* @param {Runner} runner - Instance triggers reporter actions.
* @param {Object} [options] - runner options
*/
function Report(runner, options) {
Mocha.reporters.Base.call(this, runner, options);
runner.on(EVENT_SUITE_BEGIN, function (suite) {
console.log("EVENT_SUITE_BEGIN", suite);
});
runner.on(EVENT_SUITE_END, function () {
console.log("EVENT_SUITE_END");
});
runner.on(EVENT_TEST_PASS, function (test) {
console.log("EVENT_TEST_PASS", test);
});
runner.once(EVENT_RUN_END, function () {
console.log("EVENT_RUN_END");
});
}
t.reporter(Report);
t.run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment