Jest

A guide for generating JUnit test reports for Jest tests

1. Generate JUnit

Install the jest-junit package:

npm install --save-dev jest-junit

Update your Jest config to add jest-junit as a reporter:

{
  "reporters": [
    [
      "jest-junit",
      {
        "outputDirectory": "./test_results",
        "outputName": "report.xml",
        "addFileAttribute": "true"
      }
    ]
  ]
}

2. Output Location

The outputDirectory and outputName specify the location of the JUnit test report. In the example above, the JUnit would be at ./test_results/report.xml.

Next Step

JUnit files generated with Jest are compatible with Trunk Flaky Tests. See CI Providers for a guide on how to upload test results to Trunk.

Last updated