tap-to-ctrf
v0.1.0
Published
Convert TAP (Test Anything Protocol) stream to CTRF JSON
Maintainers
Readme
tap-to-ctrf
Convert TAP (Test Anything Protocol) output into CTRF (Common Test Report Format) JSON. Built for piping from runners that expose TAP—such as AVA via ava --tap—into tools and CI steps that consume CTRF.
Requirements
- Node.js 18 or newer
Install
npm install tap-to-ctrfOr use from a clone without publishing:
cd tap-to-ctrf && npm installCLI
Read TAP from stdin or from a file, write CTRF JSON to stdout (pretty-printed).
# Pipe from AVA (recommended: set tool name for results.tool.name)
npx ava --tap | npx tap-to-ctrf --tool-name ava > ctrf-report.json
# Read a saved TAP file
npx tap-to-ctrf ./results.tap > ctrf-report.jsonIf you run the CLI with no arguments and stdin is a TTY (no pipe), it exits with an error so it does not wait forever for input.
Options
| Option | Description |
| -------------------- | ---------------------------------------------- |
| --tool-name <name> | Value for results.tool.name (default: tap) |
| -h, --help | Show help |
| -V, --version | Print package version |
Programmatic API
The package exports convertTapToCtrf from the package root (exports in package.json).
import { convertTapToCtrf } from "tap-to-ctrf";
const tap = "TAP version 13\n1..1\nok 1 - example\n";
const doc = await convertTapToCtrf(tap, { toolName: "my-runner" });
// doc.reportFormat === "CTRF"
// doc.results.summary, doc.results.tests, …Optional second argument: { toolName?, toolVersion? } (toolVersion sets results.tool.version when provided).
Behavior notes
- Per-test duration: TAP usually does not include timing. Each test gets
duration: 0unless the stream includes a TAPtimedirective for that test (then it is converted from seconds to milliseconds). - Run timing:
results.summary.startandresults.summary.stopreflect wall-clock time around parsing the stream, not the original test process. - Statuses:
ok/not ok,# SKIP,# TODO, and YAML diagnostics after failures are mapped to CTRFstatusand optionalmessage/tracewhere applicable.
Development
npm testLicense
MIT
