Direct Answer
There is no native property that limits the reporter to only failed events. However, karma-junit-reporter provides a filter option (in recent versions) that lets you exclude tests from the generated XML based on any condition, including skipped status. This is the intended way to achieve what you need without writing a custom reporter.
Configuring the Filter
In your karma.conf.js, add a filter function to the junitReporter configuration. The function receives a test result object (with fields like success, skipped, suite, description) and returns true to include the test in the XML, or false to exclude it.
// karma.conf.js
module.exports = function(config) {
config.set({
reporters: ['junit'],
junitReporter: {
outputDir: 'test-results',
outputFile: 'junit.xml',
filter: (test) => !test.skipped // Exclude skipped tests
}
});
};
To include only failures (and exclude skipped and passing tests), use:
filter: (test) => !test.success && !test.skipped
Note that failOnTests: false only prevents the CI process from exiting with a non-zero code; it does not affect what the reporter writes to XML.
Reducing Console Noise
If the XML also contains browser console messages (in system-out/system-err) that contribute to alert fatigue, you can disable console capture globally with:
client: {
captureConsole: false
}
This removes all console output from the JUnit report, which may be acceptable if you rely on other sources for debugging.
Verification and Version Check
The filter option is not present in all versions of karma-junit-reporter. Verify your installed version with npm list karma-junit-reporter and check its README. After adding the filter, run a test that includes skipped cases and inspect the generated XML to confirm they are absent.
Missing Diagnostic Detail
Which version of karma-junit-reporter are you currently using? This determines whether the filter option is available. If you're on an older version without it, the alternative is to post-process the XML in your CI pipeline (e.g., with a script) to strip entries where skipped="true".