Last active
May 24, 2021 06:18
-
-
Save yourtion/e3b7515104cd88606605001825387570 to your computer and use it in GitHub Desktop.
Custom Mocha reporter https://github.com/mochajs/mocha/wiki/Third-party-reporters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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