JUnit XML reporter — an additive artifact reporter, not a stdout format. Enabled with
--junit[=<path>], it accumulates a <testcase> per testEnd and writes the document at
run end, while whichever --reporter is active keeps owning stdout. That split matters:
CI wants a readable log and a machine-readable file, and it's what --coverage=lcov
already does for coverage artifacts.
-
onRunEnd(): Promise<void>context: ReporterContext,_info: RunEndInfo
Serializes the accumulated cases and writes the XML document to disk.
-
onRunStart(): void
Drops cases from any previous run so watch reruns start clean.
-
onTestEnd(): voidcontext: ReporterContext,details: TestDetails
Accumulates one
<testcase>; the document is written once at run end. -
xml(): string
The XML document as it stands.
onRunEndwrites exactly this to disk; the JS API reads it back so a caller can ship the report somewhere other than the filesystem.
Builds the full JUnit XML document string from a flat list of test cases.
Resolves where the JUnit document is written: --junit=<path> (relative to the project
root) when given a string, else <output>/junit.xml.
Converts one testEnd into a JUnit <testcase>. Failing assertions are flattened into a
failureDetail with stacks resolved back to original sources (same as the TAP at: field).
Usage
import * as mod from "lib/reporters/junit.ts";