Drew Stephens Drew Stephens - 1 year ago 534
Javascript Question

How do I get JUnit XML output from Jest?

I have a React app that has Jest tests. I'm configuring Jest in my


"jest": {
"setupEnvScriptFile": "./test/jestenv.js",
"setupTestFrameworkScriptFile": "./test/setup-jasmine-env.js",
"testRunner": "node_modules/jest-cli/src/testRunners/jasmine/jasmine2.js",
"unmockedModulePathPatterns": [

looks like this:

var jasmineReporters = require('jasmine-reporters');
jasmine.VERBOSE = true;
new jasmineReporters.JUnitXmlReporter({
consolidateAll: true,
savePath: "output/",
filePrefix: "test-results"

It took a bit of working to get that jasmine env setup correctly, but I"m not seeing anything in the
directory (indeed, it isn't created and creating it myself doesn't help). I suspect that my alterations to the
var aren't the same one that Jest is using, but I can't figure out how to hook them together.

Answer Source

looks like all you're missing from the above setup is to add jasmine-reporters to unmockedModulePathPatterns, so give the following a go:

"jest": {


   "unmockedModulePathPatterns": [

Hope that helps!

UPDATE: for anyone else experiencing this problem, I have put a working demo up here.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download