@@ -47,7 +47,39 @@ var globals = [
4747
4848var constants = utils . defineConstants (
4949 /**
50- * {@link Runner }-related constants.
50+ * {@link Runner }-related constants. Used by reporters. Each event emits the corresponding object, unless otherwise indicated.
51+ * @example
52+ * const Mocha = require('mocha');
53+ * const Base = Mocha.reporters.Base;
54+ * const {
55+ * EVENT_HOOK_BEGIN,
56+ * EVENT_TEST_PASS,
57+ * EVENT_TEST_FAIL,
58+ * EVENT_TEST_END
59+ * } = Mocha.Runner.constants
60+ *
61+ * function MyReporter(runner, options) {
62+ * Base.call(this, runner, options);
63+ *
64+ * runner.on(EVENT_HOOK_BEGIN, function(hook) {
65+ * console.log('hook called: ', hook.title);
66+ * });
67+ *
68+ * runner.on(EVENT_TEST_PASS, function(test) {
69+ * console.log('pass: %s', test.fullTitle());
70+ * });
71+ *
72+ * runner.on(EVENT_TEST_FAIL, function(test, err) {
73+ * console.log('fail: %s -- error: %s', test.fullTitle(), err.message);
74+ * });
75+ *
76+ * runner.on(EVENT_TEST_END, function() {
77+ * console.log('end: %d/%d', runner.stats.passes, runner.stats.tests);
78+ * });
79+ * }
80+ *
81+ * module.exports = MyReporter;
82+ *
5183 * @public
5284 * @memberof Runner
5385 * @readonly
@@ -97,7 +129,13 @@ var constants = utils.defineConstants(
97129 */
98130 EVENT_TEST_END : 'test end' ,
99131 /**
100- * Emitted when {@link Test} execution fails
132+ * Emitted when {@link Test} execution fails. Includes an `err` object of type `Error`.
133+ * @example
134+ * runner.on(EVENT_TEST_FAIL, function(test, err) {
135+ * console.log('fail: %s -- error: %s', test.fullTitle(), err.message);
136+ * });
137+ *
138+ *
101139 */
102140 EVENT_TEST_FAIL : 'fail' ,
103141 /**
0 commit comments