Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit bc3ffbd

Browse filesBrowse files
mete0rfishmarco-ippolito
authored andcommitted
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: #59414 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com>
1 parent caa2db4 commit bc3ffbd
Copy full SHA for bc3ffbd

File tree

Expand file treeCollapse file tree

2 files changed

+14
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+14
-1
lines changed
Open diff view settings
Collapse file

‎lib/internal/test_runner/reporter/junit.js‎

Copy file name to clipboardExpand all lines: lib/internal/test_runner/reporter/junit.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ function isFailure(node) {
5656
}
5757

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

6262
module.exports = async function* junitReporter(source) {
Collapse file

‎test/parallel/test-runner-reporters.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-runner-reporters.js
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,4 +191,17 @@ describe('node:test reporters', { concurrency: true }, () => {
191191
assert.match(fileConent, / skipped 0/);
192192
assert.match(fileConent, / todo 0/);
193193
});
194+
195+
it('should correctly report pass/fail for junit reporter using reporters.js', async () => {
196+
const file = tmpdir.resolve(`${tmpFiles++}.xml`);
197+
const child = spawnSync(process.execPath,
198+
['--test', '--test-reporter', 'junit', '--test-reporter-destination', file, testFile]);
199+
assert.strictEqual(child.stderr.toString(), '');
200+
assert.strictEqual(child.stdout.toString(), '');
201+
const fileContents = fs.readFileSync(file, 'utf8');
202+
assert.match(fileContents, /<testsuite .*name="nested".*tests="2".*failures="1".*skipped="0".*>/);
203+
assert.match(fileContents, /<testcase .*name="failing".*>\s*<failure .*type="testCodeFailure".*message="error".*>/);
204+
assert.match(fileContents, /<testcase .*name="ok".*classname="test".*\/>/);
205+
assert.match(fileContents, /<testcase .*name="top level".*classname="test".*\/>/);
206+
});
194207
});

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.