Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
124
rated 0 times [  125] [ 1]  / answers: 1 / hits: 29162  / 9 Years ago, wed, december 23, 2015, 12:00:00

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




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



The setup-jasmine-env.js looks like this:



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


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


More From » jenkins

 Answers
238

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.


[#63974] Sunday, December 20, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jaycie

Total Points: 414
Total Questions: 96
Total Answers: 117

Location: Christmas Island
Member since Mon, Oct 19, 2020
4 Years ago
;