@tracegraph/jest
v0.3.1
Published
TraceGraph reporter for Jest — captures test structure and results as structured traces
Readme
@tracegraph/jest
TraceGraph reporter for Jest. Produces per-test .trace.json files (capture level 5), giving each test case its own isolated trace with full test-lifecycle events. Drop-in addition to any existing Jest setup.
What's in this package
| Export | Description |
|--------|-------------|
| TraceGraphJestReporter | Jest reporter class — implements onTestFileStart, onTestStart, onTestResult, and onRunComplete to write one trace per test |
The package also provides a default export so Jest can load it via the short-form string '@tracegraph/jest' without needing the class name.
Installation
npm install -D @tracegraph/jest jestUsage
Add to jest.config.js
module.exports = {
reporters: [
'default',
'@tracegraph/jest',
],
};With options (currently none required, reserved for future use):
module.exports = {
reporters: [
'default',
['@tracegraph/jest', {}],
],
};Via tracegraph run (auto-injection)
tracegraph run -- npx jest
# → "@tracegraph/jest reporter auto-injected"tracegraph run detects Jest in the command and appends --reporters=default --reporters=@tracegraph/jest automatically unless the reporter is already present.
Direct CLI usage
npx jest --reporters=default --reporters=@tracegraph/jestWhat the reporter captures
Each test trace includes:
test_fileevent — the test file path and suite structuretest_runevent per test — test name, pass/fail/skip/todo status, and duration in millisecondserrorevent on test failure — error type and message extracted from Jest's test result- All events emitted by
traceFunction/traceMethod/traceExpressinstrumentation running inside the test body
Trace isolation
Each test in a test file gets its own traceId. Events are written to separate .tmp files per test and atomically finalised to .trace.json files when the test completes.
Requirements
- Jest ≥ 27.0.0
TRACEGRAPH_ENABLED=1andTRACEGRAPH_RUN_DIRset in the environment (set automatically bytracegraph run)
