@@ -47,7 +47,39 @@ var globals = [
47
47
48
48
var constants = utils . defineConstants (
49
49
/**
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
+ *
51
83
* @public
52
84
* @memberof Runner
53
85
* @readonly
@@ -97,7 +129,13 @@ var constants = utils.defineConstants(
97
129
*/
98
130
EVENT_TEST_END : 'test end' ,
99
131
/**
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
+ *
101
139
*/
102
140
EVENT_TEST_FAIL : 'fail' ,
103
141
/**
0 commit comments