jest-junit
A Jest reporter that converts test results into JUnit-compatible XML for CI dashboards and test-analytics tools.
Repository Health
Technical Analysis
jest-junit is the de facto standard reporter for turning Jest test output into JUnit XML, the format most CI dashboards and test-analytics platforms expect. Rather than parsing Jest’s console output, CI pipelines add jest-junit to the reporters array and get a structured junit.xml file with per-suite and per-test timing, failure messages, and pass/fail/skip counts.
Beyond the default output, jest-junit exposes fine-grained control over naming (via {classname}, {title}, {filepath} templates or custom functions), lets teams inject arbitrary <property> metadata for downstream tools like Datadog CI Visibility, and supports monorepo-friendly path prefixing and unique output filenames for parallel/sharded test runs.
What You Get
- A drop-in Jest reporter that outputs
junit.xmlfor immediate CI integration, with no custom scripting required. - Full control over how suite, test, and class names render via template strings or callback functions.
- Hooks for attaching custom
<properties>metadata to test suites and individual test cases. - Configuration through three layers (defaults, package.json, environment variables) so teams can override behavior per environment without code changes.
Common Use Cases
- Feeding Jest results into CI systems that expect JUnit XML (Jenkins, GitLab CI, CircleCI, Bitbucket Pipelines).
- Aggregating test reports across multiple packages in a monorepo test run.
- Enriching test reports with vendor-specific metadata for test-analytics tools like Datadog CI Visibility.
Under The Hood
Architecture
index.js exports a constructor function that supports both the legacy testResultsProcessor API (invoked statically) and the modern reporters API (invoked via new), delegating to an internal processor() that merges options via getOptions.options() and hands Jest’s aggregated result object to utils/buildJsonResults.js, which produces a nested JSON structure mirroring the JUnit schema (testsuites -> testsuite -> testcase). That structure is serialized to XML by the xml package and written to disk with fs.writeFileSync. An onTestResult hook buffers per-file console output so it can be attached during onRunComplete. The whole codebase is a small, flat set of single-purpose modules (index.js plus utils/ and constants/) rather than a layered architecture, and every templating and custom-property feature depends on the variable-substitution scheme defined once in buildJsonResults.js — a change there ripples through classname/title/suitename templating and the custom-properties injection points alike.
Tech Stack
Plain Node.js (engines >=20) with no build step, shipped as CommonJS. Runtime dependencies are minimal and purpose-built: xml for JSON-to-XML serialization, strip-ansi for cleaning terminal escape codes out of failure messages, and uuid (dynamically imported as ESM) for generating unique output filenames. Dev dependencies show the project dogfoods itself — jest/babel-jest run its own test suite, libxml2-wasm validates generated XML output against schema in tests, and slash normalizes paths in fixtures. CI runs on GitHub Actions across a Node 20/22/23/24 x Jest 30.x matrix plus an ubuntu/macOS matrix, with no database or web framework involved — this is pure CLI/library glue code.
Code Quality
Tests live under __tests__/ (buildJsonResults, getOptions, getTestSuitePropertiesPath, testResultProcessor) backed by an extensive set of captured Jest result fixtures under __mocks__/ — failing suites, empty suites, retried tests, multi-project/monorepo runs — giving fairly thorough scenario coverage for a small reporter. Error handling is defensive but soft: getAppOptions catches package.json parse failures and only console.warns rather than throwing. There is no TypeScript and no dedicated lint config in the repo, so option shapes are validated only by the test suite, not by a type system. Naming is consistent throughout, with all env-var-to-option mappings centralized in constants/index.js.
API Design
The public surface is a single reporter export configured through jest-junit package.json keys, JEST_JUNIT_* env vars, or reporter options, with a documented precedence order across all three. Getting started requires zero code — just adding the reporter name to Jest’s reporters array — while advanced use (custom naming templates as strings or functions, custom <properties> via drop-in junitProperties.js/junitTestCaseProperties.js files) stays opt-in and additive. Documentation in the README is unusually thorough, walking through each option with rendered XML examples, which keeps the learning curve low despite the fairly large configuration surface.
Used by 11 apps in this directory
Cal.diy
Scheduling
The 100% MIT-licensed, community-driven scheduling platform — self-host your own booking infrastructure with no enterprise strings attached.
CodeSandbox
Code Editors · Developer Tools
Instantly ready browser-based IDE that runs full npm dependency resolution and transpilation entirely client-side, with no server needed.
Forem
Community · Blogging
Open source Ruby on Rails platform for building developer communities with articles, discussions, and social profiles—the same software that powers dev.to.
GitLab
Devops · Developer Tools
The complete DevOps platform that unifies Git hosting, CI/CD, issue tracking, and security scanning into a single self-hostable application.
Grafana
Monitoring · Analytics
The open-source observability platform that unifies metrics, logs, and traces from any data source into dynamic, queryable dashboards.
Langflow
AI Agents · AI Development
Build, test, and deploy AI agents and RAG workflows visually with native API and MCP server export.
LibreChat
Developer Tools · AI Assistants
Unite every major AI model in one self-hosted chat platform with agents, code execution, MCP tools, and enterprise authentication.
Metabase
Analytics
The open-source BI platform that lets anyone ask questions and build dashboards without writing SQL — with an embedded analytics SDK and AI-powered query assistant included.
Paperless-ngx
Bookmarks Archiving
Turn your paper pile into a searchable digital archive with OCR, AI classification, and automated workflows — all running on your own server.