mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00
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:
parent
ff11b59569
commit
f7a2ba7e83
2 changed files with 14 additions and 1 deletions
|
@ -58,7 +58,7 @@ function isFailure(node) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function isSkipped(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) {
|
module.exports = async function* junitReporter(source) {
|
||||||
|
|
|
@ -191,4 +191,17 @@ describe('node:test reporters', { concurrency: true }, () => {
|
||||||
assert.match(fileConent, /ℹ skipped 0/);
|
assert.match(fileConent, /ℹ skipped 0/);
|
||||||
assert.match(fileConent, /ℹ todo 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".*\/>/);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue