Registry / testing / jest-nunit-reporter

jest-nunit-reporter

JSON →
library1.3.1jsnpmunverified

jest-nunit-reporter is a utility package for Jest that transforms its test results into an XML format compatible with NUnit. This allows Jest test outcomes to be consumed by CI/CD systems that expect NUnit-style reports, such as Azure DevOps or Jenkins, facilitating integration into enterprise build pipelines. The current stable version is 1.3.2. This package operates as a `testResultsProcessor` within Jest's configuration, meaning it's invoked by Jest after all tests have completed to process the full test suite results. It offers configuration options for specifying output file names and paths, and for customizing test suite naming within the generated XML, providing flexibility for integration into various CI environments. Release cadence appears infrequent, primarily addressing maintenance and minor enhancements as needed, rather than rapid feature development, as its core functionality is stable.

npm install jest-nunit-reporter
INSTALL
IMPORT
SIG · JEST-NUNIT-REPORTE
J
jest-nunit-reporter
testingjavascriptv1.3.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Reporter Configuration Path
"testResultsProcessor": "./node_modules/jest-nunit-reporter"
import { NUnitReporter } from 'jest-nunit-reporter'
This package is used as a Jest `testResultsProcessor` and is referenced by its file path, not imported as a standard JavaScript module. Direct `import` or `require` statements are not applicable for its primary usage.
Configuration Options
"jestNunitReporter": { "outputPath": "reports/", "outputFileName": "custom-report.xml" }
import NUnitReporter, { Options } from 'jest-nunit-reporter'
Configuration for the reporter is done via the `jestNunitReporter` object within your Jest configuration (e.g., `package.json` or `jest.config.js`), not through programmatic imports or API calls.

This quickstart demonstrates how to configure Jest to use `jest-nunit-reporter` via `package.json` and generate an NUnit XML report from sample Jest tests. It includes setting the `testResultsProcessor` and specifying output paths.

{ "name": "my-jest-nunit-project", "version": "1.0.0", "description": "Example project for jest-nunit-reporter", "main": "index.js", "scripts": { "test": "jest" }, "devDependencies": { "jest": "^29.0.0", "jest-nunit-reporter": "^1.3.1" }, "jest": { "testResultsProcessor": "./node_modules/jest-nunit-reporter", "jestNunitReporter": { "outputPath": "./reports", "outputFileName": "nunit-test-report.xml" } } } // File: my-component.test.js describe('My Important Component', () => { test('should perform basic arithmetic correctly', () => { expect(1 + 1).toBe(2); }); test('should handle a simple string operation', () => { expect('hello'.toUpperCase()).toBe('HELLO'); }); it('should demonstrate a skipped test', () => { pending('This test is not yet implemented'); }); it('should potentially fail if conditions are not met', () => { // Uncomment the line below to simulate a failing test // expect(true).toBe(false); }); }); // To run: // 1. Save the above JSON as package.json // 2. Save the JS code as my-component.test.js // 3. Run `npm install` // 4. Run `npm test` // 5. Check the `reports/nunit-test-report.xml` file.
Debug
Known issues
gotchaThe `testResultsProcessor` path must be correctly specified. Jest resolves this path relative to your project root. An incorrect path will prevent the reporter from running.
fix
Ensure the path in `jest.config.js` or `package.json` points directly to the `jest-nunit-reporter` module within `node_modules`, e.g., `./node_modules/jest-nunit-reporter`.
affects: >=1.0.0
gotchaOutput files (e.g., `test-report.xml`) are generated in the project root by default. For CI/CD environments, it's crucial to configure `outputPath` to a predictable location to ensure reports are archived correctly.
fix
Add a `jestNunitReporter` object to your Jest configuration, specifying `outputPath`: `"jestNunitReporter": { "outputPath": "./test-results/", "outputFileName": "nunit.xml" }`.
affects: >=1.0.0
breakingMajor Jest version updates can sometimes introduce breaking changes in how `testResultsProcessor`s interact with Jest's internal result formats. While generally stable, always test with new Jest major versions.
fix
Consult the `jest-nunit-reporter` GitHub repository for any compatibility notes or required updates when upgrading to new major versions of Jest.
affects: >=1.0.0
gotchaThis reporter only processes test results; it does not directly run tests. If Jest finds no tests, the reporter will not generate an XML file or will generate an empty one, as there are no results to process.
fix
Ensure your Jest configuration correctly discovers and runs your test files (e.g., `testMatch` or `testRegex` patterns).
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module './node_modules/jest-nunit-reporter' from '...' at Function.resolveSync (node:internal/modules/cjs/loader: ...)
The `testResultsProcessor` path in your Jest configuration is incorrect or the package is not installed.
fix
Verify that `jest-nunit-reporter` is installed (`npm list jest-nunit-reporter`) and that the path in `jest.config.js` or `package.json` accurately points to its location, typically `./node_modules/jest-nunit-reporter`.
No test results XML file generated.
Jest did not run any tests, or the `outputPath` configuration is incorrect, or an internal error occurred during report generation.
fix
Check Jest's console output for test execution errors. Ensure your `jestNunitReporter.outputPath` and `outputFileName` are correctly configured and accessible by the process. Confirm Jest actually ran tests by observing console output.
TypeError: Cannot read properties of undefined (reading 'outputPath') at Object.<anonymous> (...jest-nunit-reporter/index.js:...) (jest-nunit-reporter: 1.x)
The `jestNunitReporter` configuration object is missing or malformed in your Jest configuration.
fix
Ensure your `jest` configuration includes a valid `jestNunitReporter` object with expected properties, especially `outputPath` if you are trying to configure it, for example: `"jestNunitReporter": { "outputPath": "reports/" }`.
Upgrade
Version history
1.3.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
5 hits · last 30 days
node
5
Resources
jest-nunit-reporter — npm install jest-nunit-reporter · libregistry