class TAPReporter
implements Reporter
The default reporter: streams TAP version 13 to stdout. Stateless — every number it
prints comes from context.counts, which the dispatcher updates before onTestEnd.
import type { ReporterContext } from './types.ts'; import type { TestDetails } from './types.ts'; // Defined, not invoked: streams TAP to stdout. function example(context: ReporterContext, details: TestDetails) { const reporter = new TAPReporter(); reporter.onRunStart(context, { fileCount: 2, groupCount: 1 }); // "TAP version 13" reporter.onTestEnd(context, details); // "ok 1 Math | adds # (2 ms)" reporter.onRunEnd(context, { durationMs: 900 }); // "1..1" plan + summary comments }
onRunEnd(context: ReporterContext,info: RunEndInfo): void
Emits the TAP plan line and the run summary.
import type { ReporterContext } from './types.ts'; // Defined, not invoked: writes the plan + summary to stdout. function example(reporter: TAPReporter, context: ReporterContext) { reporter.onRunEnd(context, { durationMs: 900 }); // "1..12" then "# tests 12" … }
onRunStart(context: ReporterContext,info: RunStartInfo): void
Emits the TAP version header, plus the run banner as a # comment.
import type { ReporterContext } from './types.ts'; // Defined, not invoked: writes the TAP header to stdout. function example(context: ReporterContext) { new TAPReporter().onRunStart(context, { fileCount: 2, groupCount: 1 }); // "TAP version 13" then "# Running 2 test files across 1 group" }
onTestEnd(context: ReporterContext,details: TestDetails): void
Emits the ok / not ok line, with a YAML block for each failing assertion.
import type { ReporterContext } from './types.ts'; // Defined, not invoked: writes the test's TAP line to stdout. function example(reporter: TAPReporter, context: ReporterContext) { reporter.onTestEnd(context, { status: 'passed', fullName: ['Math', 'adds'], runtime: 2 }); // "ok 1 Math | adds # (2 ms)" — the number is context.counts.total }