Karma

A guide for generating Trunk-compatible test reports for Karma tests

1. Generate JUnit

Install the karma-junit-reporter package:

npm install --save-dev karma-junit-reporter

Add the junit reporter to your karma config file:

module.exports = function(config) {
  config.set(
    {
      reporters: ['junit'],
      junitReporter: {
        outputDir: 'test_results',
        outputFile: 'junit.xml'
      }
    }
  )
}

2. Output Location

The outputDir and outputFile specify the location of the JUnit test report. In the example above, the JUnit would be at ./test_results/$browserName/report.xml.

Disable Retries

You need to disable automatic retries if you previously enabled them. Retries compromise the accurate detection of flaky tests.

Karma doesn't support retries out of the box, but if you implemented retries, remember to disable them.

Next Step

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

Last updated