Skip to content

Commit 8a2447f

Browse files
committed
doc: add scope overview tables for TestsStream events
Summarize all TestsStream events in three tables by scope (test, file, and global), pairing declaration ordered (buffered) test scoped events with their execution ordered (immediate) equivalents. Signed-off-by: Moshe Atlow <moshe@atlow.co.il>
1 parent 7036199 commit 8a2447f

1 file changed

Lines changed: 54 additions & 0 deletions

File tree

doc/api/test.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3464,6 +3464,45 @@ object, streaming a series of events representing the execution of the tests.
34643464
Some of the events are guaranteed to be emitted in the same order as the tests
34653465
are defined, while others are emitted in the order that the tests execute.
34663466

3467+
The following tables summarize all events by scope.
3468+
3469+
Test scoped events are emitted once per test or suite. Most of them come in
3470+
pairs: a declaration ordered event, buffered so that events are emitted in the
3471+
same order as the tests are defined, and one or more corresponding execution
3472+
ordered events, emitted immediately as the tests execute.
3473+
3474+
| Declaration ordered (buffered) | Execution ordered (immediate) |
3475+
| ------------------------------ | ----------------------------------------------------- |
3476+
| [`'test:start'`][] | [`'test:enqueue'`][] followed by [`'test:dequeue'`][] |
3477+
| [`'test:pass'`][] | [`'test:complete'`][] (`details.passed` is `true`) |
3478+
| [`'test:fail'`][] | [`'test:complete'`][] (`details.passed` is `false`) |
3479+
| [`'test:plan'`][] | |
3480+
| [`'test:diagnostic'`][] | |
3481+
3482+
File scoped and global events are always emitted immediately, in execution
3483+
order.
3484+
3485+
File scoped events are emitted once per test file:
3486+
3487+
| Event | Notes |
3488+
| -------------------- | ---------------------------------------------- |
3489+
| [`'test:stderr'`][] | Only emitted if the `--test` flag is passed. |
3490+
| [`'test:stdout'`][] | Only emitted if the `--test` flag is passed. |
3491+
| [`'test:summary'`][] | Per file, only when process isolation is used. |
3492+
3493+
Global events are emitted once per test run:
3494+
3495+
| Event | Notes |
3496+
| ---------------------------- | ------------------------------------ |
3497+
| [`'test:summary'`][] | The final cumulative summary. |
3498+
| [`'test:coverage'`][] | Only when code coverage is enabled. |
3499+
| [`'test:interrupted'`][] | Only when the run receives `SIGINT`. |
3500+
| [`'test:watch:drained'`][] | Watch mode only. |
3501+
| [`'test:watch:restarted'`][] | Watch mode only. |
3502+
3503+
The root test also emits [`'test:plan'`][] and [`'test:diagnostic'`][] events
3504+
at the end of the run to report run level totals.
3505+
34673506
### Event: `'test:coverage'`
34683507

34693508
* `data` {Object}
@@ -4724,6 +4763,21 @@ test.describe('my suite', (suite) => {
47244763

47254764
[TAP]: https://testanything.org/
47264765
[Test tags]: #test-tags
4766+
[`'test:complete'`]: #event-testcomplete
4767+
[`'test:coverage'`]: #event-testcoverage
4768+
[`'test:dequeue'`]: #event-testdequeue
4769+
[`'test:diagnostic'`]: #event-testdiagnostic
4770+
[`'test:enqueue'`]: #event-testenqueue
4771+
[`'test:fail'`]: #event-testfail
4772+
[`'test:interrupted'`]: #event-testinterrupted
4773+
[`'test:pass'`]: #event-testpass
4774+
[`'test:plan'`]: #event-testplan
4775+
[`'test:start'`]: #event-teststart
4776+
[`'test:stderr'`]: #event-teststderr
4777+
[`'test:stdout'`]: #event-teststdout
4778+
[`'test:summary'`]: #event-testsummary
4779+
[`'test:watch:drained'`]: #event-testwatchdrained
4780+
[`'test:watch:restarted'`]: #event-testwatchrestarted
47274781
[`--experimental-test-coverage`]: cli.md#--experimental-test-coverage
47284782
[`--experimental-test-module-mocks`]: cli.md#--experimental-test-module-mocks
47294783
[`--experimental-test-tag-filter`]: cli.md#--experimental-test-tag-filterexpr

0 commit comments

Comments
 (0)