From 7cca5c1e7beca16341daa3a4fc9d6275d04b3ba2 Mon Sep 17 00:00:00 2001 From: devholic22 Date: Thu, 28 Aug 2025 21:42:46 +0900 Subject: [PATCH] test_runner: remove `failure` attribute from JUnit reporter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 and replacing it with a proper nested tag. --- lib/internal/test_runner/reporter/junit.js | 1 - .../output/junit_reporter.snapshot | 54 +++++++++---------- 2 files changed, 27 insertions(+), 28 deletions(-) diff --git a/lib/internal/test_runner/reporter/junit.js b/lib/internal/test_runner/reporter/junit.js index ed25a4bd5fbd..7f6d7122d43b 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_reporter.snapshot b/test/fixtures/test-runner/output/junit_reporter.snapshot index cef5f0b52da1..b49579fc4721 100644 --- a/test/fixtures/test-runner/output/junit_reporter.snapshot +++ b/test/fixtures/test-runner/output/junit_reporter.snapshot @@ -16,7 +16,7 @@ - + [Error [ERR_TEST_FAILURE]: thrown from sync fail todo] { @@ -28,7 +28,7 @@ } - + [Error [ERR_TEST_FAILURE]: thrown from sync fail todo with message] { @@ -48,7 +48,7 @@ - + [Error [ERR_TEST_FAILURE]: thrown from sync throw fail] { code: 'ERR_TEST_FAILURE', @@ -63,7 +63,7 @@ - + [Error [ERR_TEST_FAILURE]: thrown from async throw fail] { code: 'ERR_TEST_FAILURE', @@ -74,7 +74,7 @@ } - + [Error [ERR_TEST_FAILURE]: thrown from async throw fail] { @@ -86,7 +86,7 @@ } - + [Error [ERR_TEST_FAILURE]: Expected values to be strictly equal: @@ -112,7 +112,7 @@ true !== false - + [Error [ERR_TEST_FAILURE]: rejected from reject fail] { code: 'ERR_TEST_FAILURE', @@ -129,7 +129,7 @@ true !== false - + Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fail at TestContext.<anonymous> (/test/fixtures/test-runner/output/output.js:125:11) @@ -146,7 +146,7 @@ Error [ERR_TEST_FAILURE]: thrown from subtest sync throw 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) } @@ -170,7 +170,7 @@ Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fail - + [Error [ERR_TEST_FAILURE]: this should be executed] { code: 'ERR_TEST_FAILURE', @@ -196,7 +196,7 @@ Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fail - + [Error [ERR_TEST_FAILURE]: callback failure] { code: 'ERR_TEST_FAILURE', @@ -210,12 +210,12 @@ Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fail - + [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' } - + [Error [ERR_TEST_FAILURE]: thrown from callback throw] { code: 'ERR_TEST_FAILURE', @@ -226,7 +226,7 @@ Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fail } - + Error [ERR_TEST_FAILURE]: callback invoked multiple times at TestContext.<anonymous> (/test/fixtures/test-runner/output/output.js:272:3) @@ -238,7 +238,7 @@ Error [ERR_TEST_FAILURE]: callback invoked multiple times - + Error [ERR_TEST_FAILURE]: callback invoked multiple times at { @@ -253,7 +253,7 @@ Error [ERR_TEST_FAILURE]: callback invoked multiple times } - + Error [ERR_TEST_FAILURE]: thrown from callback async throw at { @@ -271,12 +271,12 @@ Error [ERR_TEST_FAILURE]: thrown from callback async throw - + [Error [ERR_TEST_FAILURE]: customized] { code: 'ERR_TEST_FAILURE', failureType: 'testCodeFailure', cause: customized } - + [Error [ERR_TEST_FAILURE]: { foo: 1, @@ -289,7 +289,7 @@ Error [ERR_TEST_FAILURE]: thrown from callback async throw - + Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fails at first at TestContext.<anonymous> (/test/fixtures/test-runner/output/output.js:334:11) @@ -304,7 +304,7 @@ Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fails at first } - + Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fails at second at TestContext.<anonymous> (/test/fixtures/test-runner/output/output.js:337:11) { @@ -319,12 +319,12 @@ Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fails at second - + [Error [ERR_TEST_FAILURE]: test timed out after 5ms] { code: 'ERR_TEST_FAILURE', failureType: 'testTimeoutFailure', cause: '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' } @@ -332,12 +332,12 @@ Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fails at second - + [Error [ERR_TEST_FAILURE]: custom error] { code: 'ERR_TEST_FAILURE', failureType: 'testCodeFailure', cause: 'custom error' } - + Error [ERR_TEST_FAILURE]: foo at { @@ -349,7 +349,7 @@ Error [ERR_TEST_FAILURE]: foo } - + Error [ERR_TEST_FAILURE]: bar at { @@ -361,7 +361,7 @@ Error [ERR_TEST_FAILURE]: bar } - + [Error [ERR_TEST_FAILURE]: Expected values to be loosely deep-equal: @@ -446,7 +446,7 @@ should loosely deep-equal } - + Error [ERR_TEST_FAILURE]: test could not be started because its parent finished at Immediate.<anonymous> (/test/fixtures/test-runner/output/output.js:197:7) {