Jest JUnit Reporter (Legacy)

1.1.0 · abandoned · verified Sun Apr 19

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.

Common errors

Warnings

Install

Quickstart

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.

view raw JSON →