Registry / testing / tap-junit

tap-junit

JSON →
library5.0.4jsnpmunverified

tap-junit is a CLI tool and module that converts TAP (Test Anything Protocol) output into JUnit XML format, primarily for CI/CD systems like Jenkins. Current stable version is 5.0.4, with occasional releases. It works with any TAP-producing test framework (tape, tap, etc.) and supports piping or file input. Key differentiators: lightweight, zero dependencies, customizable suite/class names, and pretty-printing option. Compared to alternatives like tap-xunit or tap2junit, tap-junit is simpler and more actively maintained.

npm install tap-junit
INSTALL
IMPORT
SIG · TAP-JUNIT
T
tap-junit
testingjavascriptv5.0.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import tapJunit from 'tap-junit'
const tapJunit = require('tap-junit')
Package is ESM-only; CommonJS require will fail unless using dynamic import.
transform
import { transform } from 'tap-junit'
The 'transform' function converts TAP string to JUnit XML string. Available as named export.
TransformStream
import { TransformStream } from 'tap-junit'
import { Transform } from 'tap-junit'
The Stream is named 'TransformStream', not 'Transform'. It is a Node.js transform stream.

Shows both CLI pipe usage and programmatic transform with TAP input to JUnit XML conversion.

import { execSync } from 'child_process'; // Using CLI: pipe TAP output into tap-junit const command = `echo 'TAP version 13 1..1 ok 1 first test' | npx tap-junit -p`; const result = execSync(command, { encoding: 'utf8' }); console.log(result); // Programmatic usage import { transform } from 'tap-junit'; const tapInput = `TAP version 13 1..2 ok 1 - passing test not ok 2 - failing test --- message: Assertion failed severity: fail ... `; const junitOutput = transform(tapInput, { suite: 'My Suite', pretty: true }); console.log(junitOutput);
Debug
Known issues
breakingVersion 4.x dropped support for Node.js < 12
fix
Upgrade Node.js to >=12 or stay on 3.x
affects: >=4.0.0 <5.0.0
breakingVersion 5.x dropped support for CommonJS (require). Package is now ESM-only.
fix
Use import or dynamic import() instead of require.
affects: >=5.0.0
deprecatedThe --file flag is deprecated in favor of --input (or -i).
fix
Use --input <file> instead of --file.
affects: >=3.0.0
gotchaIf no output file is specified, results are printed to stdout. Do not combine with --output if you want terminal output.
fix
Omit --output to print to stdout.
affects: all
gotchaThe transform function expects a string, not a stream. For streams, use the TransformStream.
fix
Use the TransformStream class for piping TAP data.
affects: all
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/tap-junit/index.js not supported.
Using require() instead of import. tap-junit 5+ is ESM-only.
fix
Change to import statement or use dynamic import: const tapJunit = await import('tap-junit');
Command 'tap-junit' not found
tap-junit is not installed globally or not in PATH.
fix
Install locally: npm i -D tap-junit and use npx tap-junit or the full path to ./node_modules/.bin/tap-junit
TypeError: transform is not a function
Importing the default export instead of the named export 'transform'.
fix
Use: import { transform } from 'tap-junit';
Error: Cannot find module 'tap-junit/transform'
Wrong import path; there is no submodule 'tap-junit/transform'.
fix
Import directly from 'tap-junit': import { transform } from 'tap-junit';
Upgrade
Version history
5.0.4latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
10 hits · last 30 days
node
10
Resources
tap-junit — npm install tap-junit · libregistry