{"id":15345,"library":"jest-nunit-reporter","title":"Jest NUnit Reporter","description":"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.","status":"maintenance","version":"1.3.1","language":"javascript","source_language":"en","source_url":"https://github.com/kingatlas/jest-nunit-reporter","tags":["javascript","jest","nunit","reporter"],"install":[{"cmd":"npm install jest-nunit-reporter","lang":"bash","label":"npm"},{"cmd":"yarn add jest-nunit-reporter","lang":"bash","label":"yarn"},{"cmd":"pnpm add jest-nunit-reporter","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"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.","wrong":"import { NUnitReporter } from 'jest-nunit-reporter'","symbol":"Reporter Configuration Path","correct":"    \"testResultsProcessor\": \"./node_modules/jest-nunit-reporter\""},{"note":"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.","wrong":"import NUnitReporter, { Options } from 'jest-nunit-reporter'","symbol":"Configuration Options","correct":"    \"jestNunitReporter\": { \"outputPath\": \"reports/\", \"outputFileName\": \"custom-report.xml\" }"}],"quickstart":{"code":"{\n  \"name\": \"my-jest-nunit-project\",\n  \"version\": \"1.0.0\",\n  \"description\": \"Example project for jest-nunit-reporter\",\n  \"main\": \"index.js\",\n  \"scripts\": {\n    \"test\": \"jest\"\n  },\n  \"devDependencies\": {\n    \"jest\": \"^29.0.0\",\n    \"jest-nunit-reporter\": \"^1.3.1\"\n  },\n  \"jest\": {\n    \"testResultsProcessor\": \"./node_modules/jest-nunit-reporter\",\n    \"jestNunitReporter\": {\n      \"outputPath\": \"./reports\",\n      \"outputFileName\": \"nunit-test-report.xml\"\n    }\n  }\n}\n\n// File: my-component.test.js\ndescribe('My Important Component', () => {\n  test('should perform basic arithmetic correctly', () => {\n    expect(1 + 1).toBe(2);\n  });\n\n  test('should handle a simple string operation', () => {\n    expect('hello'.toUpperCase()).toBe('HELLO');\n  });\n\n  it('should demonstrate a skipped test', () => {\n    pending('This test is not yet implemented');\n  });\n\n  it('should potentially fail if conditions are not met', () => {\n    // Uncomment the line below to simulate a failing test\n    // expect(true).toBe(false);\n  });\n});\n\n// To run:\n// 1. Save the above JSON as package.json\n// 2. Save the JS code as my-component.test.js\n// 3. Run `npm install`\n// 4. Run `npm test`\n// 5. Check the `reports/nunit-test-report.xml` file.","lang":"javascript","description":"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."},"warnings":[{"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`.","message":"The `testResultsProcessor` path must be correctly specified. Jest resolves this path relative to your project root. An incorrect path will prevent the reporter from running.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Add a `jestNunitReporter` object to your Jest configuration, specifying `outputPath`: `\"jestNunitReporter\": { \"outputPath\": \"./test-results/\", \"outputFileName\": \"nunit.xml\" }`.","message":"Output 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.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Consult the `jest-nunit-reporter` GitHub repository for any compatibility notes or required updates when upgrading to new major versions of Jest.","message":"Major 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.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Ensure your Jest configuration correctly discovers and runs your test files (e.g., `testMatch` or `testRegex` patterns).","message":"This 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.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"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`.","cause":"The `testResultsProcessor` path in your Jest configuration is incorrect or the package is not installed.","error":"Error: Cannot find module './node_modules/jest-nunit-reporter' from '...' at Function.resolveSync (node:internal/modules/cjs/loader: ...)"},{"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.","cause":"Jest did not run any tests, or the `outputPath` configuration is incorrect, or an internal error occurred during report generation.","error":"No test results XML file generated."},{"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/\" }`.","cause":"The `jestNunitReporter` configuration object is missing or malformed in your Jest configuration.","error":"TypeError: Cannot read properties of undefined (reading 'outputPath') at Object.<anonymous> (...jest-nunit-reporter/index.js:...) (jest-nunit-reporter: 1.x)"}],"ecosystem":"npm"}