type alias RunEvent

One thing that happened during a run, as it happened.

The fine-grained view of what RunResult summarizes. A caller that only wants the answer awaits the result; a caller drawing a progress bar reads these. Discriminated on kind so a switch is exhaustive and adding a variant is a compile error at every consumer rather than a silently-ignored event.

The last event of every run is runEnd, and it carries the complete result — so a consumer reading only this feed never needs a second channel to learn how the run came out.

// Defined, not invoked: real events arrive from a session.
function label(event: RunEvent) {
  return event.kind === 'test' ? event.test.fullName : event.kind;
}

Definition

({ kind: "runStart"; } & RunStartInfo)
| { kind: "test"; test: TestResult; }
| { kind: "notice"; notice: Notice; }
| { kind: "browserLog"; log: BrowserLog; }
| { kind: "runEnd"; result: RunResult; }

Usage

import { type RunEvent } from "lib/api/reporter.ts";