How do I get JUnit XML output from Jest? How do I get JUnit XML output from Jest? jenkins jenkins

How do I get JUnit XML output from Jest?


If you use a more recent version of jest (I'm looking at 16.0.2), you don't need to specify the testrunner because jasmine is the default. You also don't need the unmockedModulePathPatterns section of the jest config.

I.e. you just need to include the following devDependencies in your package.json:

"jasmine-reporters": "^2.2.0","jest": "^16.0.2","jest-cli": "^16.0.2"

And add this jest config to your package.json (note: you no longer need the unmockedModulePathPatterns section):

"jest": {  "setupTestFrameworkScriptFile": "./setup-jasmine-env.js"}

And then use Drew's setup-jasmine-env.js from the question.


Jest has support for its own reporters via the testResultsProcessor config. So I wrote up a little thing that generates compatible junit xml for this. You can find it here. https://github.com/palmerj3/jest-junit


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": [     "./node_modules/q",     "./node_modules/react",     "./node_modules/jasmine-reporters"   ]},

Hope that helps!

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