Commit d3c40489628 for nodejs
commit d3c4048962853bb12359682381001ab63dced4ce
Author: Aliaksandr <42497203+AlexCannonball@users.noreply.github.com>
Date: Mon Nov 16 14:17:50 2026 +0300
test_runner: remove `failure` attribute from JUnit reporter
This commit aligns the Node.js test runner's JUnit XML output with the
official JUnit specification by removing the non-standard failure
attribute from elements.
Signed-off-by: Aliaksandr <42497203+AlexCannonball@users.noreply.github.com>
Co-authored-by: devholic22 <hyunjoon.tech@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66072
Fixes: https://github.com/nodejs/node/issues/59593
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
diff --git a/lib/internal/test_runner/reporter/junit.js b/lib/internal/test_runner/reporter/junit.js
index e5a3fa961ea..691a3e59321 100644
--- a/lib/internal/test_runner/reporter/junit.js
+++ b/lib/internal/test_runner/reporter/junit.js
@@ -149,7 +149,6 @@ module.exports = async function* junitReporter(source) {
children: [inspectWithNoCustomRetry(error, inspectOptions)],
});
currentTest.failures = 1;
- currentTest.attrs.failure = error?.message ?? '';
}
}
break;
diff --git a/test/fixtures/test-runner/output/junit_empty_diagnostic.snapshot b/test/fixtures/test-runner/output/junit_empty_diagnostic.snapshot
index 666c5c3523a..7944fdf3071 100644
--- a/test/fixtures/test-runner/output/junit_empty_diagnostic.snapshot
+++ b/test/fixtures/test-runner/output/junit_empty_diagnostic.snapshot
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<testsuites>
- <testcase name="failing" time="*" classname="test" file="*" failure="error">
+ <testcase name="failing" time="*" classname="test" file="*">
<failure type="testCodeFailure" message="error">
[Error [ERR_TEST_FAILURE]: error] {
code: 'ERR_TEST_FAILURE',
diff --git a/test/fixtures/test-runner/output/junit_reporter.snapshot b/test/fixtures/test-runner/output/junit_reporter.snapshot
index 3ff11ba2415..fd4f219a721 100644
--- a/test/fixtures/test-runner/output/junit_reporter.snapshot
+++ b/test/fixtures/test-runner/output/junit_reporter.snapshot
@@ -16,7 +16,7 @@
<testcase name="sync pass todo with message" time="*" classname="test" file="*">
<skipped type="todo" message="this is a passing todo"/>
</testcase>
- <testcase name="sync fail todo" time="*" classname="test" file="*" failure="thrown from sync fail todo">
+ <testcase name="sync fail todo" time="*" classname="test" file="*">
<skipped type="todo" message="true"/>
<failure type="testCodeFailure" message="thrown from sync fail todo">
[Error [ERR_TEST_FAILURE]: thrown from sync fail todo] {
@@ -28,7 +28,7 @@
}
</failure>
</testcase>
- <testcase name="sync fail todo with message" time="*" classname="test" file="*" failure="thrown from sync fail todo with message">
+ <testcase name="sync fail todo with message" time="*" classname="test" file="*">
<skipped type="todo" message="this is a failing todo"/>
<failure type="testCodeFailure" message="thrown from sync fail todo with message">
[Error [ERR_TEST_FAILURE]: thrown from sync fail todo with message] {
@@ -48,7 +48,7 @@
</testcase>
<testcase name="sync pass" time="*" classname="test" file="*"/>
<!-- this test should pass -->
- <testcase name="sync throw fail" time="*" classname="test" file="*" failure="thrown from sync throw fail">
+ <testcase name="sync throw fail" time="*" classname="test" file="*">
<failure type="testCodeFailure" message="thrown from sync throw fail">
[Error [ERR_TEST_FAILURE]: thrown from sync throw fail] {
code: 'ERR_TEST_FAILURE',
@@ -63,7 +63,7 @@
<skipped type="skipped" message="true"/>
</testcase>
<testcase name="async pass" time="*" classname="test" file="*"/>
- <testcase name="async throw fail" time="*" classname="test" file="*" failure="thrown from async throw fail">
+ <testcase name="async throw fail" time="*" classname="test" file="*">
<failure type="testCodeFailure" message="thrown from async throw fail">
[Error [ERR_TEST_FAILURE]: thrown from async throw fail] {
code: 'ERR_TEST_FAILURE',
@@ -74,7 +74,7 @@
}
</failure>
</testcase>
- <testcase name="async skip fail" time="*" classname="test" file="*" failure="thrown from async throw fail">
+ <testcase name="async skip fail" time="*" classname="test" file="*">
<skipped type="skipped" message="true"/>
<failure type="testCodeFailure" message="thrown from async throw fail">
[Error [ERR_TEST_FAILURE]: thrown from async throw fail] {
@@ -86,7 +86,7 @@
}
</failure>
</testcase>
- <testcase name="async assertion fail" time="*" classname="test" file="*" failure="Expected values to be strictly equal: true !== false ">
+ <testcase name="async assertion fail" time="*" classname="test" file="*">
<failure type="testCodeFailure" message="Expected values to be strictly equal: true !== false">
[Error [ERR_TEST_FAILURE]: Expected values to be strictly equal:
@@ -112,7 +112,7 @@ true !== false
</failure>
</testcase>
<testcase name="resolve pass" time="*" classname="test" file="*"/>
- <testcase name="reject fail" time="*" classname="test" file="*" failure="rejected from reject fail">
+ <testcase name="reject fail" time="*" classname="test" file="*">
<failure type="testCodeFailure" message="rejected from reject fail">
[Error [ERR_TEST_FAILURE]: rejected from reject fail] {
code: 'ERR_TEST_FAILURE',
@@ -129,7 +129,7 @@ true !== false
<testcase name="immediate reject - passes but warns" time="*" classname="test" file="*"/>
<testcase name="immediate resolve pass" time="*" classname="test" file="*"/>
<testsuite name="subtest sync throw fail" time="*" disabled="0" errors="0" tests="1" failures="1" skipped="0" timestamp="*" hostname="HOSTNAME">
- <testcase name="+sync throw fail" time="*" classname="subtest sync throw fail" file="*" failure="thrown from subtest sync throw fail">
+ <testcase name="+sync throw fail" time="*" classname="subtest sync throw fail" file="*">
<failure type="testCodeFailure" message="thrown from subtest sync throw fail">
Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fail
at TestContext.<anonymous> (<project-root>/test/fixtures/test-runner/output/output.js:125:11) {
@@ -145,7 +145,7 @@ Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fail
</testcase>
<!-- this subtest should make its parent test fail -->
</testsuite>
- <testcase name="sync throw non-error fail" time="*" classname="test" file="*" failure="Symbol(thrown symbol from sync throw non-error fail)">
+ <testcase name="sync throw non-error fail" time="*" classname="test" file="*">
<failure type="testCodeFailure" message="Symbol(thrown symbol from sync throw non-error fail)">
[Error [ERR_TEST_FAILURE]: Symbol(thrown symbol from sync throw non-error fail)] { code: 'ERR_TEST_FAILURE', failureType: 'testCodeFailure', cause: Symbol(thrown symbol from sync throw non-error fail) }
</failure>
@@ -169,7 +169,7 @@ Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fail
<testcase name="sync skip option with message" time="*" classname="test" file="*">
<skipped type="skipped" message="this is skipped"/>
</testcase>
- <testcase name="sync skip option is false fail" time="*" classname="test" file="*" failure="this should be executed">
+ <testcase name="sync skip option is false fail" time="*" classname="test" file="*">
<failure type="testCodeFailure" message="this should be executed">
[Error [ERR_TEST_FAILURE]: this should be executed] {
code: 'ERR_TEST_FAILURE',
@@ -195,7 +195,7 @@ Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fail
<skipped type="skipped" message="true"/>
</testcase>
<testcase name="callback pass" time="*" classname="test" file="*"/>
- <testcase name="callback fail" time="*" classname="test" file="*" failure="callback failure">
+ <testcase name="callback fail" time="*" classname="test" file="*">
<failure type="testCodeFailure" message="callback failure">
[Error [ERR_TEST_FAILURE]: callback failure] {
code: 'ERR_TEST_FAILURE',
@@ -209,12 +209,12 @@ Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fail
<testcase name="sync t is this in test" time="*" classname="test" file="*"/>
<testcase name="async t is this in test" time="*" classname="test" file="*"/>
<testcase name="callback t is this in test" time="*" classname="test" file="*"/>
- <testcase name="callback also returns a Promise" time="*" classname="test" file="*" failure="passed a callback but also returned a Promise">
+ <testcase name="callback also returns a Promise" time="*" classname="test" file="*">
<failure type="callbackAndPromisePresent" message="passed a callback but also returned a Promise">
[Error [ERR_TEST_FAILURE]: passed a callback but also returned a Promise] { code: 'ERR_TEST_FAILURE', failureType: 'callbackAndPromisePresent', cause: 'passed a callback but also returned a Promise' }
</failure>
</testcase>
- <testcase name="callback throw" time="*" classname="test" file="*" failure="thrown from callback throw">
+ <testcase name="callback throw" time="*" classname="test" file="*">
<failure type="testCodeFailure" message="thrown from callback throw">
[Error [ERR_TEST_FAILURE]: thrown from callback throw] {
code: 'ERR_TEST_FAILURE',
@@ -225,7 +225,7 @@ Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fail
}
</failure>
</testcase>
- <testcase name="callback called twice" time="*" classname="test" file="*" failure="callback invoked multiple times">
+ <testcase name="callback called twice" time="*" classname="test" file="*">
<failure type="multipleCallbackInvocations" message="callback invoked multiple times">
Error [ERR_TEST_FAILURE]: callback invoked multiple times
at TestContext.<anonymous> (<project-root>/test/fixtures/test-runner/output/output.js:272:3) {
@@ -236,7 +236,7 @@ Error [ERR_TEST_FAILURE]: callback invoked multiple times
</failure>
</testcase>
<testcase name="callback called twice in different ticks" time="*" classname="test" file="*"/>
- <testcase name="callback called twice in future tick" time="*" classname="test" file="*" failure="callback invoked multiple times">
+ <testcase name="callback called twice in future tick" time="*" classname="test" file="*">
<failure type="uncaughtException" message="callback invoked multiple times">
Error [ERR_TEST_FAILURE]: callback invoked multiple times
at <node-internal-frames> {
@@ -251,7 +251,7 @@ Error [ERR_TEST_FAILURE]: callback invoked multiple times
}
</failure>
</testcase>
- <testcase name="callback async throw" time="*" classname="test" file="*" failure="thrown from callback async throw">
+ <testcase name="callback async throw" time="*" classname="test" file="*">
<failure type="uncaughtException" message="thrown from callback async throw">
Error [ERR_TEST_FAILURE]: thrown from callback async throw
at <node-internal-frames> {
@@ -269,12 +269,12 @@ Error [ERR_TEST_FAILURE]: thrown from callback async throw
<testcase name="running subtest 3" time="*" classname="only is set on subtests but not in only mode" file="*"/>
<testcase name="running subtest 4" time="*" classname="only is set on subtests but not in only mode" file="*"/>
</testsuite>
- <testcase name="custom inspect symbol fail" time="*" classname="test" file="*" failure="customized">
+ <testcase name="custom inspect symbol fail" time="*" classname="test" file="*">
<failure type="testCodeFailure" message="customized">
[Error [ERR_TEST_FAILURE]: customized] { code: 'ERR_TEST_FAILURE', failureType: 'testCodeFailure', cause: customized }
</failure>
</testcase>
- <testcase name="custom inspect symbol that throws fail" time="*" classname="test" file="*" failure="{ foo: 1, Symbol(nodejs.util.inspect.custom): [Function: [nodejs.util.inspect.custom]] }">
+ <testcase name="custom inspect symbol that throws fail" time="*" classname="test" file="*">
<failure type="testCodeFailure" message="{ foo: 1, Symbol(nodejs.util.inspect.custom): [Function: [nodejs.util.inspect.custom]] }">
[Error [ERR_TEST_FAILURE]: {
foo: 1,
@@ -287,7 +287,7 @@ Error [ERR_TEST_FAILURE]: thrown from callback async throw
</failure>
</testcase>
<testsuite name="subtest sync throw fails" time="*" disabled="0" errors="0" tests="2" failures="2" skipped="0" timestamp="*" hostname="HOSTNAME">
- <testcase name="sync throw fails at first" time="*" classname="subtest sync throw fails" file="*" failure="thrown from subtest sync throw fails at first">
+ <testcase name="sync throw fails at first" time="*" classname="subtest sync throw fails" file="*">
<failure type="testCodeFailure" message="thrown from subtest sync throw fails at first">
Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fails at first
at TestContext.<anonymous> (<project-root>/test/fixtures/test-runner/output/output.js:334:11) {
@@ -301,7 +301,7 @@ Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fails at first
}
</failure>
</testcase>
- <testcase name="sync throw fails at second" time="*" classname="subtest sync throw fails" file="*" failure="thrown from subtest sync throw fails at second">
+ <testcase name="sync throw fails at second" time="*" classname="subtest sync throw fails" file="*">
<failure type="testCodeFailure" message="thrown from subtest sync throw fails at second">
Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fails at second
at TestContext.<anonymous> (<project-root>/test/fixtures/test-runner/output/output.js:337:11) {
@@ -316,12 +316,12 @@ Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fails at second
</failure>
</testcase>
</testsuite>
- <testcase name="timed out async test" time="*" classname="test" file="*" failure="test timed out after 5ms">
+ <testcase name="timed out async test" time="*" classname="test" file="*">
<failure type="testTimeoutFailure" message="test timed out after 5ms">
[Error [ERR_TEST_FAILURE]: test timed out after 5ms] { code: 'ERR_TEST_FAILURE', failureType: 'testTimeoutFailure', cause: 'test timed out after 5ms' }
</failure>
</testcase>
- <testcase name="timed out callback test" time="*" classname="test" file="*" failure="test timed out after 5ms">
+ <testcase name="timed out callback test" time="*" classname="test" file="*">
<failure type="testTimeoutFailure" message="test timed out after 5ms">
[Error [ERR_TEST_FAILURE]: test timed out after 5ms] { code: 'ERR_TEST_FAILURE', failureType: 'testTimeoutFailure', cause: 'test timed out after 5ms' }
</failure>
@@ -329,12 +329,12 @@ Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fails at second
<testcase name="large timeout async test is ok" time="*" classname="test" file="*"/>
<testcase name="large timeout callback test is ok" time="*" classname="test" file="*"/>
<testcase name="successful thenable" time="*" classname="test" file="*"/>
- <testcase name="rejected thenable" time="*" classname="test" file="*" failure="custom error">
+ <testcase name="rejected thenable" time="*" classname="test" file="*">
<failure type="testCodeFailure" message="custom error">
[Error [ERR_TEST_FAILURE]: custom error] { code: 'ERR_TEST_FAILURE', failureType: 'testCodeFailure', cause: 'custom error' }
</failure>
</testcase>
- <testcase name="unfinished test with uncaughtException" time="*" classname="test" file="*" failure="foo">
+ <testcase name="unfinished test with uncaughtException" time="*" classname="test" file="*">
<failure type="uncaughtException" message="foo">
Error [ERR_TEST_FAILURE]: foo
at <node-internal-frames> {
@@ -346,7 +346,7 @@ Error [ERR_TEST_FAILURE]: foo
}
</failure>
</testcase>
- <testcase name="unfinished test with unhandledRejection" time="*" classname="test" file="*" failure="bar">
+ <testcase name="unfinished test with unhandledRejection" time="*" classname="test" file="*">
<failure type="unhandledRejection" message="bar">
Error [ERR_TEST_FAILURE]: bar
at <node-internal-frames> {
@@ -358,7 +358,7 @@ Error [ERR_TEST_FAILURE]: bar
}
</failure>
</testcase>
- <testcase name="assertion errors display actual and expected properly" time="*" classname="test" file="*" failure="Expected values to be loosely deep-equal: { bar: 1, baz: { date: 1970-01-01T00:00:00.000Z, null: null, number: 1, string: 'Hello', undefined: undefined }, boo: [ 1 ], foo: 1 } should loosely deep-equal { baz: { date: 1970-01-01T00:00:00.000Z, null: null, number: 1, string: 'Hello', undefined: undefined }, boo: [ 1 ], circular: <ref *1> { bar: 2, c: [Circular *1] } }">
+ <testcase name="assertion errors display actual and expected properly" time="*" classname="test" file="*">
<failure type="testCodeFailure" message="Expected values to be loosely deep-equal: { bar: 1, baz: { date: 1970-01-01T00:00:00.000Z, null: null, number: 1, string: 'Hello', undefined: undefined }, boo: [ 1 ], foo: 1 } should loosely deep-equal { baz: { date: 1970-01-01T00:00:00.000Z, null: null, number: 1, string: 'Hello', undefined: undefined }, boo: [ 1 ], circular: <ref *1> { bar: 2, c: [Circular *1] } }">
[Error [ERR_TEST_FAILURE]: Expected values to be loosely deep-equal:
@@ -443,7 +443,7 @@ should loosely deep-equal
}
</failure>
</testcase>
- <testcase name="invalid subtest fail" time="*" classname="test" file="*" failure="test could not be started because its parent finished">
+ <testcase name="invalid subtest fail" time="*" classname="test" file="*">
<failure type="parentAlreadyFinished" message="test could not be started because its parent finished">
Error [ERR_TEST_FAILURE]: test could not be started because its parent finished
at Immediate.<anonymous> (<project-root>/test/fixtures/test-runner/output/output.js:197:7) {