@@ -3580,6 +3580,74 @@ Global events are emitted once per test run:
35803580The root test also emits [ ` 'test:plan' ` ] [ ] and [ ` 'test:diagnostic' ` ] [ ] events
35813581at the end of the run to report run level totals.
35823582
3583+ ### Event lifecycle
3584+
3585+ The tables above group the events; the diagram below places them on a
3586+ timeline. The declaration ordered events form the main spine, buffered so that
3587+ a reporter sees them in source order, while each execution ordered twin is
3588+ emitted immediately, when the work actually happens. In particular,
3589+ [ ` 'test:start' ` ] [ ] marks when a test begins _ reporting_ its own and its
3590+ subtests' status, not when its body begins executing; that moment is
3591+ [ ` 'test:dequeue' ` ] [ ] .
3592+
3593+ ``` text
3594+ node:test reporter event lifecycle
3595+ main spine = DECLARATION order (buffered; matches source order)
3596+ right side = EXECUTION order (emitted immediately); β marks each twin
3597+
3598+ LEAF TEST
3599+ βββββββββ
3600+ ββββββββββββββββ test:enqueue
3601+ β test:start β βββββ twins ββββ (queued for execution;
3602+ ββββββββββββββββ type: 'suite' | 'test')
3603+ β begins REPORTING test:dequeue
3604+ β (not the start of (about to run; emitted right
3605+ β the test body) before the test body runs)
3606+ β
3607+ β [ between the twins, on the execution timeline, the test
3608+ β body runs: context.log() emits test:log live, and
3609+ β test:stdout / test:stderr stream with --test ]
3610+ β
3611+ βΌ
3612+ βββββββββββββββββββββββββ
3613+ β test:pass β test:fail β βββββ twin ββββ test:complete
3614+ βββββββββββββββββββββββββ result (details.passed says which)
3615+ β
3616+ βΌ
3617+ test:diagnostic the test's own context.diagnostic() messages,
3618+ buffered while it runs, flushed after its result
3619+
3620+
3621+ SUITE / PARENT TEST (each subtest is the whole LEAF flow above)
3622+ βββββββββββββββββββ
3623+ test:start ββΊ [ full flow of each subtest ... ] ββΊ
3624+ test:plan (count = subtests) ββΊ test:pass β test:fail ββΊ
3625+ test:diagnostic
3626+
3627+
3628+ RUN-LEVEL FINALE (root, after all top-level tests)
3629+ ββββββββββββββββ
3630+ test:plan top-level count
3631+ β
3632+ βΌ
3633+ test:diagnostic x N tests, suites, pass, fail, cancelled,
3634+ β skipped, todo, duration_ms (+ coverage errors)
3635+ βΌ
3636+ test:coverage only if coverage is enabled
3637+ β
3638+ βΌ
3639+ test:summary ββΊ stream ends
3640+
3641+
3642+ INTERRUPTION (SIGINT, e.g. Ctrl+C, while tests are still running)
3643+ ββββββββββββ
3644+ test:interrupted the innermost tests still running at that moment
3645+ β (not emitted if none were running)
3646+ βΌ
3647+ the run exits immediately β the buffered spine never flushes, so
3648+ neither the finale above nor those tests' own results are emitted
3649+ ```
3650+
35833651### Event: ` 'test:coverage' `
35843652
35853653* ` data ` {Object}
0 commit comments