Jest NUnit Reporter

1.3.1 · maintenance · verified Tue Apr 21

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.

Common errors

Warnings

Install

Imports

Quickstart

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.

view raw JSON →