junit-report-builder is a Node.js library designed to simplify the creation of JUnit XML reports compatible with Jenkins and other CI systems. Currently stable at version 5.1.2, it maintains a moderate release cadence, addressing dependency updates, minor features, and critical compatibility fixes. Its primary function is to programmatically construct complex XML reports, providing a fluent API for defining test suites, test cases, and their outcomes (success, failure, skipped, error). A key differentiator is its focus on direct XML generation from a programmatic interface, rather than processing existing test output, making it ideal for integration into custom testing frameworks or report generation tools. It ships with TypeScript type definitions, ensuring robust development workflows.
npm install junit-report-builderVerified import paths — ran on the pinned version, not inferred.
This example demonstrates creating a test suite, adding successful, failed, skipped, and error test cases, and writing the complete report to an XML file using async/await.
Upgrade your Node.js runtime to version 16 or newer. Use a tool like `nvm` to manage multiple Node.js versions if necessary.
For projects requiring CommonJS, upgrade directly to version 5.0.0 or later, which correctly restores CommonJS compatibility. Alternatively, refactor your codebase to use ES modules (`import`).
Upgrade to `junit-report-builder@^5.0.0` or higher to ensure stable CommonJS support. If you're on 4.0.0, either use ESM or upgrade to 5.0.0+.
Ensure that any input strings to report fields are valid XML characters. No specific fix is usually needed unless you were relying on malformed output.
Ensure you are using the correct import statement: `import builder from 'junit-report-builder';` for ESM or `const builder = require('junit-report-builder');` for CommonJS. Verify that the package is installed.Switch to ES module import syntax: `import builder from 'junit-report-builder';`. Alternatively, rename your file to `.cjs` or ensure your `package.json` specifies `"type": "commonjs"`.
Run `npm install junit-report-builder` to install the package. Verify that your project's `node_modules` directory is correctly configured.
No dependency data recorded yet.