TestsStream
History
entryFile to events forwarded from child processes when tests run with process isolation.parentId to test events that carry a testId.class TestsStream extends Readable
A successful call to run() method will return a new TestsStream
object, streaming a series of events representing the execution of the tests.
TestsStream will emit events, in the order of the tests definition
Some of the events are guaranteed to be emitted in the same order as the tests are defined, while others are emitted in the order that the tests execute.
The following tables summarize all events by scope.
Test scoped events are emitted once per test or suite. Most of them come in pairs: a declaration ordered event, buffered so that events are emitted in the same order as the tests are defined, and one or more corresponding execution ordered events, emitted immediately as the tests execute.
| Declaration ordered (buffered) | Execution ordered (immediate) |
|---|---|
'test:start' | 'test:enqueue' followed by 'test:dequeue' |
'test:pass' | 'test:complete' (details.passed is true) |
'test:fail' | 'test:complete' (details.passed is false) |
'test:plan' | |
'test:diagnostic' | |
'test:log' |
'test:log' is deliberately execution ordered only: it is the live
counterpart of 'test:diagnostic''s buffered reporting.
File scoped and global events are always emitted immediately, in execution order.
File scoped events are emitted once per test file:
| Event | Notes |
|---|---|
'test:stderr' | Only emitted if the --test flag is passed. |
'test:stdout' | Only emitted if the --test flag is passed. |
'test:summary' | Per file, only when process isolation is used. |
Global events are emitted once per test run:
| Event | Notes |
|---|---|
'test:summary' | The final cumulative summary. |
'test:coverage' | Only when code coverage is enabled. |
'test:interrupted' | Only when the run receives SIGINT. |
'test:watch:drained' | Watch mode only. |
'test:watch:restarted' | Watch mode only. |
The root test also emits 'test:plan' and 'test:diagnostic' events
at the end of the run to report run level totals.
ObjectObjectArraystringnumbernumbernumbernumbernumbernumbernumbernumbernumberArrayArrayObjectObjectnumbernumbernumbernumbernumbernumbernumbernumbernumberstringnumberEmitted when code coverage is enabled and all tests have completed.
Objectundefined if the test was run through the REPL.Objectfile when the test is defined in a module imported by the entry file.undefined if the test was run through the REPL.stringnumbertestId of the enclosing test, or
undefined for top-level tests. Lets custom reporters track lineage
when concurrent siblings at the same nesting level interleave.string[]numbernumbercontext.todo is calledcontext.skip is calledEmitted when a test completes its execution.
This event is not emitted in the same order as the tests are
defined.
The corresponding declaration ordered events are 'test:pass' and 'test:fail'.
Objectundefined if the test was run through the REPL.file when the test is defined in a module imported by the entry file.undefined if the test was run through the REPL.stringnumbertestId of the enclosing test, or
undefined for top-level tests. Lets custom reporters track lineage
when concurrent siblings at the same nesting level interleave.string[]numberstring'suite' or 'test'.Emitted when a test is dequeued, right before it is executed.
This event is not guaranteed to be emitted in the same order as the tests are
defined. The corresponding declaration ordered event is 'test:start'.
Objectundefined if the test was run through the REPL.file when the test is defined in a module imported by the entry file.undefined if the test was run through the REPL.stringnumberstringEmitted when context.diagnostic is called.
This event is guaranteed to be emitted in the same order as the tests are
defined.
Objectundefined if the test was run through the REPL.file when the test is defined in a module imported by the entry file.undefined if the test was run through the REPL.stringnumbertestId of the enclosing test, or
undefined for top-level tests. Lets custom reporters track lineage
when concurrent siblings at the same nesting level interleave.string[]numberstring'suite' or 'test'.Emitted when a test is enqueued for execution.
Objectundefined if the test was run through the REPL.ObjectnumberErrorError--test-rerun-failures flag.file when the test is defined in a module imported by the entry file.undefined if the test was run through the REPL.stringnumbertestId of the enclosing test, or
undefined for top-level tests. Lets custom reporters track lineage
when concurrent siblings at the same nesting level interleave.string[]numbernumbercontext.todo is calledcontext.skip is calledEmitted when a test fails.
This event is guaranteed to be emitted in the same order as the tests are
defined.
The corresponding execution ordered event is 'test:complete'.
ObjectArrayEmitted when the test runner is interrupted by a SIGINT signal (e.g., when
pressing Ctrl+C). The event contains information about
the tests that were running at the time of interruption.
When using process isolation (the default), the test name will be the file path
since the parent runner only knows about file-level tests. When using
--test-isolation=none, the actual test name is shown.
Objectundefined if the test was run through the REPL.anycontext.log, or
undefined if none was provided. The test runner does not interpret this
value.file when the test is defined in a module imported by the entry file.undefined if the test was run through the REPL.stringstringnumbernumberEmitted when context.log is called. Unlike 'test:diagnostic',
this event is emitted immediately, in the order that the tests execute,
making it suitable for reporters that render test output unbuffered.
Objectundefined if the test was run through the REPL.Objectnumber--test-rerun-failures flag.--test-rerun-failures flag.file when the test is defined in a module imported by the entry file.undefined if the test was run through the REPL.stringnumbertestId of the enclosing test, or
undefined for top-level tests. Lets custom reporters track lineage
when concurrent siblings at the same nesting level interleave.string[]numbernumbercontext.todo is calledcontext.skip is calledEmitted when a test passes.
This event is guaranteed to be emitted in the same order as the tests are
defined.
The corresponding execution ordered event is 'test:complete'.
Objectundefined if the test was run through the REPL.file when the test is defined in a module imported by the entry file.undefined if the test was run through the REPL.numbernumberEmitted when all subtests have completed for a given test. This event is guaranteed to be emitted in the same order as the tests are defined.
Objectundefined if the test was run through the REPL.file when the test is defined in a module imported by the entry file.undefined if the test was run through the REPL.stringnumbertestId of the enclosing test, or
undefined for top-level tests. Lets custom reporters track lineage
when concurrent siblings at the same nesting level interleave.string[]numberEmitted when a test starts reporting its own and its subtests status.
This event is guaranteed to be emitted in the same order as the tests are
defined.
The corresponding execution ordered event is 'test:dequeue'.
Emitted when a running test writes to stderr.
This event is only emitted if --test flag is passed.
This event is not guaranteed to be emitted in the same order as the tests are
defined.
Emitted when a running test writes to stdout.
This event is only emitted if --test flag is passed.
This event is not guaranteed to be emitted in the same order as the tests are
defined.
ObjectObjectnumbernumbernumbernumbernumbernumbernumbernumbernumberundefined.booleanfalse.Emitted when a test run completes. This event contains metrics pertaining to
the completed test run, and is useful for determining if a test run passed or
failed. If process-level test isolation is used, a 'test:summary' event is
generated for each test file in addition to a final cumulative summary.
Emitted when no more tests are queued for execution in watch mode.
Emitted when one or more tests are restarted due to a file change in watch mode.