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`.

PR-URL: https://github.com/nodejs/node/pull/59414
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com>
This commit is contained in:
Sungwon authored and Marco Ippolito committed 2025-11-19 18:01:43 +01:00
1 parent caa2db4bac
commit bc3ffbd713
2 files changed
+14 -1

No files matched your search

+1 -1
View File
@@ -56,7 +56,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) {
+13
View File
@@ -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".*\/>/);
});
});