@@ -3500,6 +3500,74 @@ Global events are emitted once per test run:
35003500The root test also emits [ ` 'test:plan' ` ] [ ] and [ ` 'test:diagnostic' ` ] [ ] events
35013501at the end of the run to report run level totals.
35023502
3503+ ### Event lifecycle
3504+
3505+ The tables above group the events; the diagram below places them on a
3506+ timeline. The declaration ordered events form the main spine, buffered so that
3507+ a reporter sees them in source order, while each execution ordered twin is
3508+ emitted immediately, when the work actually happens. In particular,
3509+ [ ` 'test:start' ` ] [ ] marks when a test begins _ reporting_ its own and its
3510+ subtests' status, not when its body begins executing; that moment is
3511+ [ ` 'test:dequeue' ` ] [ ] .
3512+
3513+ ``` text
3514+ node:test reporter event lifecycle
3515+ main spine = DECLARATION order (buffered; matches source order)
3516+ right side = EXECUTION order (emitted immediately); β marks each twin
3517+
3518+ LEAF TEST
3519+ βββββββββ
3520+ ββββββββββββββββ test:enqueue
3521+ β test:start β βββββ twins ββββ (queued for execution;
3522+ ββββββββββββββββ type: 'suite' | 'test')
3523+ β begins REPORTING test:dequeue
3524+ β (not the start of (about to run; emitted right
3525+ β the test body) before the test body runs)
3526+ β
3527+ β [ between the twins, on the execution timeline, the test
3528+ β body runs: context.log() emits test:log live, and
3529+ β test:stdout / test:stderr stream with --test ]
3530+ β
3531+ βΌ
3532+ βββββββββββββββββββββββββ
3533+ β test:pass β test:fail β βββββ twin ββββ test:complete
3534+ βββββββββββββββββββββββββ result (details.passed says which)
3535+ β
3536+ βΌ
3537+ test:diagnostic the test's own context.diagnostic() messages,
3538+ buffered while it runs, flushed after its result
3539+
3540+
3541+ SUITE / PARENT TEST (each subtest is the whole LEAF flow above)
3542+ βββββββββββββββββββ
3543+ test:start ββΊ [ full flow of each subtest ... ] ββΊ
3544+ test:plan (count = subtests) ββΊ test:pass β test:fail ββΊ
3545+ test:diagnostic
3546+
3547+
3548+ RUN-LEVEL FINALE (root, after all top-level tests)
3549+ ββββββββββββββββ
3550+ test:plan top-level count
3551+ β
3552+ βΌ
3553+ test:diagnostic x N tests, suites, pass, fail, cancelled,
3554+ β skipped, todo, duration_ms (+ coverage errors)
3555+ βΌ
3556+ test:coverage only if coverage is enabled
3557+ β
3558+ βΌ
3559+ test:summary ββΊ stream ends
3560+
3561+
3562+ INTERRUPTION (SIGINT, e.g. Ctrl+C, while tests are still running)
3563+ ββββββββββββ
3564+ test:interrupted the innermost tests still running at that moment
3565+ β (not emitted if none were running)
3566+ βΌ
3567+ the run exits immediately β the buffered spine never flushes, so
3568+ neither the finale above nor those tests' own results are emitted
3569+ ```
3570+
35033571### Event: ` 'test:coverage' `
35043572
35053573* ` data ` {Object}
0 commit comments