I have a project that uses Jasmine on Node.js. I want the generated test reports to include file paths for each test.
Steps to reproduce:
npm install --save-dev jasmine npx jasmine init npx jasmine examples As I understand, by default jasmine only outputs test results to the console.
So I added jasmine-reporters package and configured it to use JUnitXmlReporter by adding spec/helpers/reporter.js file:
var junitReporter = new jasmineReporters.JUnitXmlReporter({ savePath: '..', consolidateAll: false }); jasmine.getEnv().addReporter(junitReporter); After running npx jasmine, the XML file created by JUnitXmlReporter looks like:
% cat reports/junitresults-Player.xml <?xml version="1.0" encoding="UTF-8" ?> <testsuites disabled="0" errors="0" failures="0" tests="5" time="0.003"> <testsuite name="Player" timestamp="2025-11-13T10:18:11" hostname="localhost" time="0.002" errors="0" tests="2" skipped="0" disabled="0" failures="0"> <testcase classname="Player" name="should be able to play a Song" time="0.001" /> <testcase classname="Player" name="tells the current song if the user has made it a favorite" time="0" /> </testsuite> However I need to have spec file paths in the XML reports.
So for example:
<testsuite name="spec/jasmine_examples/PlayerSpec.js" timestamp="2025-11-13T10:18:11" hostname="localhost" time="0.002" errors="0" tests="2" skipped="0" disabled="0" failures="0"> Spec path either in the name field or in a separate field works for me. If it's not possible to do with 'jasmine-reporters', other workarounds are also welcome.