class GithubReporter
implements Reporter
GitHub Actions reporter: spec output, plus a ::error workflow command per failure so the
failure is annotated inline on the PR diff.
Getting annotations otherwise costs an artifact upload, a second workflow, a third-party reporter action, and a fork-token dance. Here it's one flag — the file:line is already resolved back to original sources by the shared failure descriptor.
Composes SpecReporter rather than reimplementing it: the log stays as readable as a normal spec run, and annotations are strictly additional.
import type { ReporterContext } from './types.ts'; import type { TestDetails } from './types.ts'; // Defined, not invoked: streams spec output plus ::error commands to stdout. function example(context: ReporterContext, details: TestDetails) { const reporter = new GithubReporter(); reporter.onRunStart(context, { fileCount: 1, groupCount: 1 }); reporter.onTestEnd(context, details); // spec line, plus "::error …" per failing assertion reporter.onRunEnd(context, { durationMs: 800 }); }
onRunEnd(context: ReporterContext,info: RunEndInfo): void
Delegates the summary + failure recap to the spec renderer.
import type { ReporterContext } from './types.ts'; // Defined, not invoked: prints the summary to stdout. function example(reporter: GithubReporter, context: ReporterContext) { reporter.onRunEnd(context, { durationMs: 800 }); // " 5 passing (800ms)" … }
onRunStart(context: ReporterContext,info: RunStartInfo): void
Delegates the run banner to the spec renderer.
import type { ReporterContext } from './types.ts'; // Defined, not invoked: prints the banner to stdout. function example(reporter: GithubReporter, context: ReporterContext) { reporter.onRunStart(context, { fileCount: 2, groupCount: 1 }); // "Running 2 test files …" }
onTestEnd(context: ReporterContext,details: TestDetails): void
Renders the spec line, then annotates each failing assertion for the PR diff.
import type { ReporterContext } from './types.ts'; import type { TestDetails } from './types.ts'; // Defined, not invoked: writes the spec line and one ::error command per failing assertion. function example(reporter: GithubReporter, context: ReporterContext, failed: TestDetails) { reporter.onTestEnd(context, failed); // " ✖ adds (3ms)" … then "::error file=lib/math.ts,line=4,col=3,title=Math | adds::…" }