Registry / testing / jest-junit-reporter

jest-junit-reporter

JSON →
library1.1.0jsnpmunverified

This entry describes `jest-junit-reporter` version 1.1.0, a utility for generating JUnit XML test reports from Jest test results. Published 9 years ago, this specific package is effectively abandoned and is no longer maintained. It leverages Jest's `testResultsProcessor` configuration option to intercept test outcomes and format them into a `test-results.xml` file. For any new projects or migrations, the actively maintained and recommended alternative is `jest-junit` (currently at version 16.0.0), which offers more features, better compatibility with modern Jest versions, and uses the `reporters` array configuration (as `testResultsProcessor` is deprecated by Jest itself). This legacy reporter's configuration is limited to environment variables like `TEST_REPORT_PATH` and `TEST_REPORT_FILENAME` for output location and filename. Due to its age, it may have compatibility issues with newer Node.js or Jest versions.

npm install jest-junit-reporter
INSTALL
IMPORT
SIG · JEST-JUNIT-REPORTE
J
jest-junit-reporter
testingjavascriptv1.1.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Demonstrates how to configure and use the `jest-junit-reporter` via `package.json` to generate a JUnit XML report.

{ "name": "my-jest-project", "version": "1.0.0", "description": "A simple project demonstrating jest-junit-reporter (legacy).", "main": "index.js", "scripts": { "test": "jest" }, "devDependencies": { "jest": "^27.0.0", "jest-junit-reporter": "^1.1.0" }, "jest": { "testResultsProcessor": "./node_modules/jest-junit-reporter" } } // Example test file (sum.test.js) function sum(a, b) { return a + b; } describe('sum', () => { test('adds 1 + 2 to equal 3', () => { expect(sum(1, 2)).toBe(3); }); test('adds 5 + 10 to equal 15', () => { expect(sum(5, 10)).toBe(15); }); test('should handle negative numbers', () => { expect(sum(-1, -1)).toBe(-2); }); }); // To run this and generate the report: // 1. npm install // 2. npm test // This will create a 'test-results.xml' file in the project root.
Debug
Known issues
deprecatedThe `testResultsProcessor` configuration option in Jest, which `jest-junit-reporter` uses, is deprecated and may be removed in future Jest versions.
fix
Migrate to using the `reporters` array in your Jest configuration with a modern JUnit reporter like `jest-junit`. Example: `reporters: ['default', ['jest-junit', { outputDirectory: 'reports', outputName: 'junit.xml' }]]`.
affects: >=jest@27.0.0
breakingThe `jest-junit-reporter` package (v1.1.0) is abandoned, with its last publish date 9 years ago. It is no longer maintained and may have compatibility issues with recent Node.js or Jest versions.
fix
Switch to `jest-junit` (npm package), which is actively maintained and supports modern Jest features and Node.js versions. Install `npm i -D jest-junit`.
affects: all
gotchaConfiguration for `jest-junit-reporter` (v1.1.0) relies solely on environment variables (`TEST_REPORT_PATH`, `TEST_REPORT_FILENAME`) to customize the output file path and name. This differs significantly from modern Jest reporters.
fix
If you must use this legacy reporter, ensure these environment variables are correctly set before running Jest. For `jest-junit`, configuration can be done via reporter options, a `jest-junit` key in `package.json`, or dedicated environment variables like `JEST_JUNIT_OUTPUT_DIR` and `JEST_JUNIT_OUTPUT_NAME`.
affects: all
Errors
Common errors & fixes
Error: Could not resolve a module for a custom reporter. Module name: ./node_modules/jest-junit-reporter
The `jest-junit-reporter` package is not correctly installed or the path in `testResultsProcessor` is incorrect.
fix
Ensure `jest-junit-reporter` is listed in your `devDependencies` and run `npm install`. Verify the path in `jest.testResultsProcessor` points to the correct location (e.g., `./node_modules/jest-junit-reporter`).
No 'test-results.xml' file generated.
Jest might not be running the `testResultsProcessor` due to an error, or the output path/filename is being overridden unexpectedly.
fix
Check Jest's console output for errors. Ensure tests are actually running. If using `TEST_REPORT_PATH` or `TEST_REPORT_FILENAME` environment variables, verify they are correctly set and accessible to the Jest process.
DeprecationWarning: The 'testResultsProcessor' option is deprecated and will be removed in a future release.
Jest is actively warning about the use of `testResultsProcessor`.
fix
Migrate to the `reporters` array in your Jest configuration. Consider switching to the `jest-junit` package for modern compatibility and features.
Upgrade
Version history
1.1.0latest on npm
Audit
Dependencies
xmlrequiredUsed for generating the XML output.
Agent activity
6 hits · last 30 days
node
6
Resources
jest-junit-reporter — npm install jest-junit-reporter · libregistry