Jasmine

A guide for generating JUnit test reports for Jasmine tests

1. Generate JUnit

Install the jasmine-reporters package:

npm install --save-dev jasmine-reporters

In-Browser tests

When used for in-browser tests, the reporters are registered on a jasmineReporters object in the global scope (i.e. window.jasmineReporters).

var junitReporter = new jasmineReporters.JUnitXmlReporter({
    savePath: "test_reports",
    consolidateAll: false
});
jasmine.getEnv().addReporter(junitReporter);

NodeJS

In Node.js, jasmine-reporters exports an object with all the reporters which you can use however you like.

var reporters = require('jasmine-reporters');
var junitReporter = new reporters.JUnitXmlReporter({
    savePath: "test_reports",
    consolidateAll: false
});
jasmine.getEnv().addReporter(junitReporter)

2. Output Location

Jasmine will generate a JUnit report at the location specified by the savePath property. In the examples above, the JUnit report will be written to a directory named test_reports/.

Next Step

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

Last updated