You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- much destructuring
- many renames
- adds `EVENT_DELAY_END` emitted from `Runner` for reporter use; needs tests
- consolidated use of `object.assign` polyfill into `utils` module
- some docstring fixes/consistency
- add `utils.createMap()` and `utils.defineConstants()`; needs more tests
- fix broken custom assertion
- don't needlessly extend `Base` reporter in simple reporter example
@@ -78,33 +76,46 @@ To use this reporter, execute `mocha --reporter /path/to/my-reporter.js`.
78
76
79
77
For further examples, the built-in reporter implementations are the [best place to look](https://github.com/mochajs/mocha/tree/master/lib/reporters). The [integration tests](https://github.com/mochajs/mocha/tree/master/test/reporters) may also be helpful.
80
78
79
+
## The `Base` Reporter Class
80
+
81
+
[Base] is an "abstract" class. It contains console-specific settings and utilities, commonly used by built-in reporters. Browsing the built-in reporter implementations, you may often see static properties of [Base] referenced.
82
+
83
+
It's often useful--but not necessary--for a custom reporter to extend [Base].
84
+
85
+
## Statistics
86
+
87
+
Mocha adds a `stats` property of type [StatsCollector](/api/module-lib_stats-collector.html) to each reporter instance immediately following instantiation.
88
+
81
89
## Events
82
90
83
-
A reporter should listen for events emitted from the `runner` (an instance of [Runner]).
91
+
A reporter should listen for events emitted from the `runner` (a singleton instance of [Runner]).
84
92
85
93
The event names are exported from the `constants` property of `Mocha.Runner`:
|`RUNNER_EVENT_BEGIN`|`start`|_(n/a)_| Execution will begin. Corresponding "end" event is `RUNNER_EVENT_END`. |
90
-
|`RUNNER_EVENT_END`|`end`|_(n/a)_| All [Suite]s, [Test]s and [Hook]s have completed execution. Corresponding "begin" event is `RUNNER_EVENT_BEGIN`. |
91
-
|`RUNNER_EVENT_SUITE_BEGIN`|`suite`|`Suite`| The [Hook]s and [Test]s within a [Suite] are about to be executed. Any nested [Suite]s will also be executed. Corresponding "end" event is `RUNNER_EVENT_SUITE_END`. |
92
-
|`RUNNER_EVENT_SUITE_END`|`suite end`|`Suite`| The [Hook]s, [Test]s, and nested [Suite]s within a [Suite] have completed execution. Corresponding "begin" event is `RUNNER_EVENT_SUITE_BEGIN`. |
93
-
|`RUNNER_EVENT_HOOK_BEGIN`|`hook`|`Hook`| A [Hook] will execute. Corresponding "end" event is `RUNNER_EVENT_HOOK_END`. |
94
-
|`RUNNER_EVENT_HOOK_END`|`hook end`|`Hook`| A [Hook] has completed execution. Corresponding "begin" event is `RUNNER_EVENT_HOOK_BEGIN`. |
95
-
|`RUNNER_EVENT_TEST_BEGIN`|`test`|`Test`| A [Test] will execute. Corresponding "end" event is `RUNNER_EVENT_TEST_END`. |
96
-
|`RUNNER_EVENT_TEST_END`|`test end`|`Test`| A [Test] has completed execution. Corresponding "begin" event is `RUNNER_EVENT_TEST_BEGIN`. |
97
-
|`RUNNER_EVENT_FAIL`|`fail`|`Test`, `Error`| A [Test] has failed or thrown an exception. |
98
-
|`RUNNER_EVENT_PASS`|`pass`|`Test`| A [Test] has passed. |
99
-
|`RUNNER_EVENT_PENDING`|`pending`|`Test`| A [Test] was skipped. |
100
-
|`RUNNER_EVENT_RETRY`|`retry`|`Test`, `Error`| A [Test] failed, but is about to be retried; only emitted if the `retry` option is nonzero. |
101
-
|`RUNNER_EVENT_WAITING`|`waiting`|_(n/a)_| Waiting for `global.run()` to be called; only emitted when `delay` option is `true`. |
|`EVENT_RUN_BEGIN`|`start`|_(n/a)_| Execution will begin. |
98
+
|`EVENT_RUN_END`|`end`|_(n/a)_| All [Suite]s, [Test]s and [Hook]s have completed execution. |
99
+
|`EVENT_DELAY_BEGIN`|`waiting`|_(n/a)_| Waiting for `global.run()` to be called; only emitted when [delay] option is `true`. |
100
+
|`EVENT_DELAY_END`|`ready`|_(n/a)_| User called `global.run()` and the root suite is ready to execute. |
101
+
|`EVENT_SUITE_BEGIN`|`suite`|`Suite`| The [Hook]s and [Test]s within a [Suite] will be executed, including any nested [Suite]s. |
102
+
|`EVENT_SUITE_END`|`suite end`|`Suite`| The [Hook]s, [Test]s, and nested [Suite]s within a [Suite] have completed execution. |
103
+
|`EVENT_HOOK_BEGIN`|`hook`|`Hook`| A [Hook] will be executed. |
104
+
|`EVENT_HOOK_END`|`hook end`|`Hook`| A [Hook] has completed execution. |
105
+
|`EVENT_TEST_BEGIN`|`test`|`Test`| A [Test] will be executed. |
106
+
|`EVENT_TEST_END`|`test end`|`Test`| A [Test] has completed execution. |
107
+
|`EVENT_TEST_FAIL`|`fail`|`Test`, `Error`| A [Test] has failed or thrown an exception. |
108
+
|`EVENT_TEST_PASS`|`pass`|`Test`| A [Test] has passed. |
109
+
|`EVENT_TEST_PENDING`|`pending`|`Test`| A [Test] was skipped. |
110
+
|`EVENT_TEST_RETRY`|`retry`|`Test`, `Error`| A [Test] failed, but is about to be retried; only emitted if the `retry` option is nonzero. |
102
111
103
112
**Please use these constants** instead of the event names in your own reporter! This will ensure compatibility with future versions of Mocha.
104
113
105
-
> It's important to understand that all suite callbacks will be run _before_ the [Runner] emits `RUNNER_EVENT_BEGIN`. Hooks and tests, however, won't run until _after_ the [Runner] emits `RUNNER_EVENT_BEGIN`.
114
+
> It's important to understand that all `Suite` callbacks will be run _before_ the [Runner] emits `EVENT_RUN_BEGIN`. Hooks and tests, however, won't run until _after_ the [Runner] emits `EVENT_RUN_BEGIN`.
0 commit comments