diff --git a/lib/internal/test_runner/reporter/junit.js b/lib/internal/test_runner/reporter/junit.js index 0b2efe119fe..24bbd9ffc3e 100644 --- a/lib/internal/test_runner/reporter/junit.js +++ b/lib/internal/test_runner/reporter/junit.js @@ -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) { diff --git a/test/parallel/test-runner-reporters.js b/test/parallel/test-runner-reporters.js index b557cef1b9b..50a47578a1d 100644 --- a/test/parallel/test-runner-reporters.js +++ b/test/parallel/test-runner-reporters.js @@ -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, //); + assert.match(fileContents, /\s*/); + assert.match(fileContents, //); + assert.match(fileContents, //); + }); });