Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
test_runner: fix isSkipped check in junit
The `isSkipped` function in the JUnit reporter was incorrectly
checking for `node?.attrs.failures` instead of `node?.attrs.skipped`.
  • Loading branch information
mete0rfish committed Aug 9, 2025
commit a9e1cc8c4492a729e8b799089946c2bc6b1b9f2f
2 changes: 1 addition & 1 deletion lib/internal/test_runner/reporter/junit.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function isFailure(node) {
}

function isSkipped(node) {
return (node?.children && ArrayPrototypeSome(node.children, (c) => c.tag === 'skipped')) || node?.attrs?.failures;
return (node?.children && ArrayPrototypeSome(node.children, (c) => c.tag === 'skipped')) || node?.attrs?.skipped;
}

module.exports = async function* junitReporter(source) {
Expand Down
13 changes: 13 additions & 0 deletions test/parallel/test-runner-reporters.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,4 +191,17 @@ describe('node:test reporters', { concurrency: true }, () => {
assert.match(fileConent, /ℹ skipped 0/);
assert.match(fileConent, /ℹ todo 0/);
});

it('should correctly report pass/fail for junit reporter using reporters.js', async () => {
const file = tmpdir.resolve(`${tmpFiles++}.xml`);
const child = spawnSync(process.execPath,
['--test', '--test-reporter', 'junit', '--test-reporter-destination', file, testFile]);
assert.strictEqual(child.stderr.toString(), '');
assert.strictEqual(child.stdout.toString(), '');
const fileContents = fs.readFileSync(file, 'utf8');
assert.match(fileContents, /<testsuite .*name="nested".*tests="2".*failures="1".*skipped="0".*>/);
assert.match(fileContents, /<testcase .*name="failing".*>\s*<failure .*type="testCodeFailure".*message="error".*>/);
assert.match(fileContents, /<testcase .*name="ok".*classname="test".*\/>/);
assert.match(fileContents, /<testcase .*name="top level".*classname="test".*\/>/);
});
});