Skip to content

Reporters

A reporter turns run events into output. as-test ships two — a human-readable default and tap — and accepts custom reporter modules.

Built-in reporters

ReporterOutput
defaultHuman-readable progress, per-suite results, coverage summary.
tapTAP version 13, for CI and TAP consumers.
bash
ast test                 # default
ast test --reporter tap
ast test --tap           # shortcut for --reporter tap

Configuring a reporter

String form selects a built-in or a module path:

json
{ "runOptions": { "reporter": "tap" } }

Object form passes options. The TAP reporter supports single-file (default) and per-file output, with outDir / outFile controlling where it lands:

json
{
  "runOptions": {
    "reporter": {
      "name": "tap",
      "options": ["per-file"],
      "outDir": "./.as-test/reports"
    }
  }
}
FieldPurpose
name"default", "tap", or a module path.
optionsReporter-specific flags (TAP: single-file | per-file).
outDirOutput directory (TAP; defaults to ./.as-test/reports).
outFileOutput file for TAP single-file mode.

Custom reporters

Point name (or --reporter) at a module path. as-test resolves it and calls its createReporter factory, which returns an object implementing the reporter interface. Implement only the hooks you care about:

ts
// my-reporter.ts
export function createReporter(context) {
  return {
    onRunStart(event) {},
    onFileStart(event) {},
    onSuiteStart(event) {},
    onSuiteEnd(event) {},
    onAssertionFail(event) {},
    onSnapshotMissing(event) {},
    onWarning(event) {},
    onLog(event) {},
    onFileEnd(event) {},
    onRunComplete(event) {},
    flush() {},
  };
}
json
{ "runOptions": { "reporter": "./tools/my-reporter.js" } }
HookFires
onRunStartonce, before any file runs
onFileStart / onFileEndaround each spec file
onSuiteStart / onSuiteEndaround each suite
onAssertionFailon a failing assertion
onSnapshotMissingwhen a snapshot has no baseline
onWarning / onLogon warnings and log() output
onRunCompleteonce, with the final aggregated results
flushat the end, to write buffered output

All hooks are optional. Use onRunComplete for summary output and flush to write files.