Skip to content

Commit bc5e877

Browse files
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>
1 parent ecd365e commit bc5e877

3 files changed

Lines changed: 28 additions & 29 deletions

File tree

lib/internal/test_runner/reporter/junit.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ module.exports = async function* junitReporter(source) {
149149
children: [inspectWithNoCustomRetry(error, inspectOptions)],
150150
});
151151
currentTest.failures = 1;
152-
currentTest.attrs.failure = error?.message ?? '';
153152
}
154153
}
155154
break;

test/fixtures/test-runner/output/junit_empty_diagnostic.snapshot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<testsuites>
3-
<testcase name="failing" time="*" classname="test" file="*" failure="error">
3+
<testcase name="failing" time="*" classname="test" file="*">
44
<failure type="testCodeFailure" message="error">
55
[Error [ERR_TEST_FAILURE]: error] {
66
code: 'ERR_TEST_FAILURE',

test/fixtures/test-runner/output/junit_reporter.snapshot

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<testcase name="sync pass todo with message" time="*" classname="test" file="*">
1717
<skipped type="todo" message="this is a passing todo"/>
1818
</testcase>
19-
<testcase name="sync fail todo" time="*" classname="test" file="*" failure="thrown from sync fail todo">
19+
<testcase name="sync fail todo" time="*" classname="test" file="*">
2020
<skipped type="todo" message="true"/>
2121
<failure type="testCodeFailure" message="thrown from sync fail todo">
2222
[Error [ERR_TEST_FAILURE]: thrown from sync fail todo] {
@@ -28,7 +28,7 @@
2828
}
2929
</failure>
3030
</testcase>
31-
<testcase name="sync fail todo with message" time="*" classname="test" file="*" failure="thrown from sync fail todo with message">
31+
<testcase name="sync fail todo with message" time="*" classname="test" file="*">
3232
<skipped type="todo" message="this is a failing todo"/>
3333
<failure type="testCodeFailure" message="thrown from sync fail todo with message">
3434
[Error [ERR_TEST_FAILURE]: thrown from sync fail todo with message] {
@@ -48,7 +48,7 @@
4848
</testcase>
4949
<testcase name="sync pass" time="*" classname="test" file="*"/>
5050
<!-- this test should pass -->
51-
<testcase name="sync throw fail" time="*" classname="test" file="*" failure="thrown from sync throw fail">
51+
<testcase name="sync throw fail" time="*" classname="test" file="*">
5252
<failure type="testCodeFailure" message="thrown from sync throw fail">
5353
[Error [ERR_TEST_FAILURE]: thrown from sync throw fail] {
5454
code: 'ERR_TEST_FAILURE',
@@ -63,7 +63,7 @@
6363
<skipped type="skipped" message="true"/>
6464
</testcase>
6565
<testcase name="async pass" time="*" classname="test" file="*"/>
66-
<testcase name="async throw fail" time="*" classname="test" file="*" failure="thrown from async throw fail">
66+
<testcase name="async throw fail" time="*" classname="test" file="*">
6767
<failure type="testCodeFailure" message="thrown from async throw fail">
6868
[Error [ERR_TEST_FAILURE]: thrown from async throw fail] {
6969
code: 'ERR_TEST_FAILURE',
@@ -74,7 +74,7 @@
7474
}
7575
</failure>
7676
</testcase>
77-
<testcase name="async skip fail" time="*" classname="test" file="*" failure="thrown from async throw fail">
77+
<testcase name="async skip fail" time="*" classname="test" file="*">
7878
<skipped type="skipped" message="true"/>
7979
<failure type="testCodeFailure" message="thrown from async throw fail">
8080
[Error [ERR_TEST_FAILURE]: thrown from async throw fail] {
@@ -86,7 +86,7 @@
8686
}
8787
</failure>
8888
</testcase>
89-
<testcase name="async assertion fail" time="*" classname="test" file="*" failure="Expected values to be strictly equal:&#10;&#10;true !== false&#10;">
89+
<testcase name="async assertion fail" time="*" classname="test" file="*">
9090
<failure type="testCodeFailure" message="Expected values to be strictly equal:&#10;&#10;true !== false">
9191
[Error [ERR_TEST_FAILURE]: Expected values to be strictly equal:
9292

@@ -112,7 +112,7 @@ true !== false
112112
</failure>
113113
</testcase>
114114
<testcase name="resolve pass" time="*" classname="test" file="*"/>
115-
<testcase name="reject fail" time="*" classname="test" file="*" failure="rejected from reject fail">
115+
<testcase name="reject fail" time="*" classname="test" file="*">
116116
<failure type="testCodeFailure" message="rejected from reject fail">
117117
[Error [ERR_TEST_FAILURE]: rejected from reject fail] {
118118
code: 'ERR_TEST_FAILURE',
@@ -129,7 +129,7 @@ true !== false
129129
<testcase name="immediate reject - passes but warns" time="*" classname="test" file="*"/>
130130
<testcase name="immediate resolve pass" time="*" classname="test" file="*"/>
131131
<testsuite name="subtest sync throw fail" time="*" disabled="0" errors="0" tests="1" failures="1" skipped="0" timestamp="*" hostname="HOSTNAME">
132-
<testcase name="+sync throw fail" time="*" classname="subtest sync throw fail" file="*" failure="thrown from subtest sync throw fail">
132+
<testcase name="+sync throw fail" time="*" classname="subtest sync throw fail" file="*">
133133
<failure type="testCodeFailure" message="thrown from subtest sync throw fail">
134134
Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fail
135135
at TestContext.&lt;anonymous> (<project-root>/test/fixtures/test-runner/output/output.js:125:11)
@@ -146,7 +146,7 @@ Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fail
146146
</testcase>
147147
<!-- this subtest should make its parent test fail -->
148148
</testsuite>
149-
<testcase name="sync throw non-error fail" time="*" classname="test" file="*" failure="Symbol(thrown symbol from sync throw non-error fail)">
149+
<testcase name="sync throw non-error fail" time="*" classname="test" file="*">
150150
<failure type="testCodeFailure" message="Symbol(thrown symbol from sync throw non-error fail)">
151151
[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) }
152152
</failure>
@@ -170,7 +170,7 @@ Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fail
170170
<testcase name="sync skip option with message" time="*" classname="test" file="*">
171171
<skipped type="skipped" message="this is skipped"/>
172172
</testcase>
173-
<testcase name="sync skip option is false fail" time="*" classname="test" file="*" failure="this should be executed">
173+
<testcase name="sync skip option is false fail" time="*" classname="test" file="*">
174174
<failure type="testCodeFailure" message="this should be executed">
175175
[Error [ERR_TEST_FAILURE]: this should be executed] {
176176
code: 'ERR_TEST_FAILURE',
@@ -196,7 +196,7 @@ Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fail
196196
<skipped type="skipped" message="true"/>
197197
</testcase>
198198
<testcase name="callback pass" time="*" classname="test" file="*"/>
199-
<testcase name="callback fail" time="*" classname="test" file="*" failure="callback failure">
199+
<testcase name="callback fail" time="*" classname="test" file="*">
200200
<failure type="testCodeFailure" message="callback failure">
201201
[Error [ERR_TEST_FAILURE]: callback failure] {
202202
code: 'ERR_TEST_FAILURE',
@@ -210,12 +210,12 @@ Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fail
210210
<testcase name="sync t is this in test" time="*" classname="test" file="*"/>
211211
<testcase name="async t is this in test" time="*" classname="test" file="*"/>
212212
<testcase name="callback t is this in test" time="*" classname="test" file="*"/>
213-
<testcase name="callback also returns a Promise" time="*" classname="test" file="*" failure="passed a callback but also returned a Promise">
213+
<testcase name="callback also returns a Promise" time="*" classname="test" file="*">
214214
<failure type="callbackAndPromisePresent" message="passed a callback but also returned a Promise">
215215
[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' }
216216
</failure>
217217
</testcase>
218-
<testcase name="callback throw" time="*" classname="test" file="*" failure="thrown from callback throw">
218+
<testcase name="callback throw" time="*" classname="test" file="*">
219219
<failure type="testCodeFailure" message="thrown from callback throw">
220220
[Error [ERR_TEST_FAILURE]: thrown from callback throw] {
221221
code: 'ERR_TEST_FAILURE',
@@ -226,7 +226,7 @@ Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fail
226226
}
227227
</failure>
228228
</testcase>
229-
<testcase name="callback called twice" time="*" classname="test" file="*" failure="callback invoked multiple times">
229+
<testcase name="callback called twice" time="*" classname="test" file="*">
230230
<failure type="multipleCallbackInvocations" message="callback invoked multiple times">
231231
Error [ERR_TEST_FAILURE]: callback invoked multiple times
232232
at TestContext.&lt;anonymous> (<project-root>/test/fixtures/test-runner/output/output.js:272:3)
@@ -238,7 +238,7 @@ Error [ERR_TEST_FAILURE]: callback invoked multiple times
238238
</failure>
239239
</testcase>
240240
<testcase name="callback called twice in different ticks" time="*" classname="test" file="*"/>
241-
<testcase name="callback called twice in future tick" time="*" classname="test" file="*" failure="callback invoked multiple times">
241+
<testcase name="callback called twice in future tick" time="*" classname="test" file="*">
242242
<failure type="uncaughtException" message="callback invoked multiple times">
243243
Error [ERR_TEST_FAILURE]: callback invoked multiple times
244244
at <node-internal-frames> {
@@ -253,7 +253,7 @@ Error [ERR_TEST_FAILURE]: callback invoked multiple times
253253
}
254254
</failure>
255255
</testcase>
256-
<testcase name="callback async throw" time="*" classname="test" file="*" failure="thrown from callback async throw">
256+
<testcase name="callback async throw" time="*" classname="test" file="*">
257257
<failure type="uncaughtException" message="thrown from callback async throw">
258258
Error [ERR_TEST_FAILURE]: thrown from callback async throw
259259
at <node-internal-frames> {
@@ -271,12 +271,12 @@ Error [ERR_TEST_FAILURE]: thrown from callback async throw
271271
<testcase name="running subtest 3" time="*" classname="only is set on subtests but not in only mode" file="*"/>
272272
<testcase name="running subtest 4" time="*" classname="only is set on subtests but not in only mode" file="*"/>
273273
</testsuite>
274-
<testcase name="custom inspect symbol fail" time="*" classname="test" file="*" failure="customized">
274+
<testcase name="custom inspect symbol fail" time="*" classname="test" file="*">
275275
<failure type="testCodeFailure" message="customized">
276276
[Error [ERR_TEST_FAILURE]: customized] { code: 'ERR_TEST_FAILURE', failureType: 'testCodeFailure', cause: customized }
277277
</failure>
278278
</testcase>
279-
<testcase name="custom inspect symbol that throws fail" time="*" classname="test" file="*" failure="{&#10; foo: 1,&#10; Symbol(nodejs.util.inspect.custom): [Function: [nodejs.util.inspect.custom]]&#10;}">
279+
<testcase name="custom inspect symbol that throws fail" time="*" classname="test" file="*">
280280
<failure type="testCodeFailure" message="{&#10; foo: 1,&#10; Symbol(nodejs.util.inspect.custom): [Function: [nodejs.util.inspect.custom]]&#10;}">
281281
[Error [ERR_TEST_FAILURE]: {
282282
foo: 1,
@@ -289,7 +289,7 @@ Error [ERR_TEST_FAILURE]: thrown from callback async throw
289289
</failure>
290290
</testcase>
291291
<testsuite name="subtest sync throw fails" time="*" disabled="0" errors="0" tests="2" failures="2" skipped="0" timestamp="*" hostname="HOSTNAME">
292-
<testcase name="sync throw fails at first" time="*" classname="subtest sync throw fails" file="*" failure="thrown from subtest sync throw fails at first">
292+
<testcase name="sync throw fails at first" time="*" classname="subtest sync throw fails" file="*">
293293
<failure type="testCodeFailure" message="thrown from subtest sync throw fails at first">
294294
Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fails at first
295295
at TestContext.&lt;anonymous> (<project-root>/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
304304
}
305305
</failure>
306306
</testcase>
307-
<testcase name="sync throw fails at second" time="*" classname="subtest sync throw fails" file="*" failure="thrown from subtest sync throw fails at second">
307+
<testcase name="sync throw fails at second" time="*" classname="subtest sync throw fails" file="*">
308308
<failure type="testCodeFailure" message="thrown from subtest sync throw fails at second">
309309
Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fails at second
310310
at TestContext.&lt;anonymous> (<project-root>/test/fixtures/test-runner/output/output.js:337:11) {
@@ -319,25 +319,25 @@ Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fails at second
319319
</failure>
320320
</testcase>
321321
</testsuite>
322-
<testcase name="timed out async test" time="*" classname="test" file="*" failure="test timed out after 5ms">
322+
<testcase name="timed out async test" time="*" classname="test" file="*">
323323
<failure type="testTimeoutFailure" message="test timed out after 5ms">
324324
[Error [ERR_TEST_FAILURE]: test timed out after 5ms] { code: 'ERR_TEST_FAILURE', failureType: 'testTimeoutFailure', cause: 'test timed out after 5ms' }
325325
</failure>
326326
</testcase>
327-
<testcase name="timed out callback test" time="*" classname="test" file="*" failure="test timed out after 5ms">
327+
<testcase name="timed out callback test" time="*" classname="test" file="*">
328328
<failure type="testTimeoutFailure" message="test timed out after 5ms">
329329
[Error [ERR_TEST_FAILURE]: test timed out after 5ms] { code: 'ERR_TEST_FAILURE', failureType: 'testTimeoutFailure', cause: 'test timed out after 5ms' }
330330
</failure>
331331
</testcase>
332332
<testcase name="large timeout async test is ok" time="*" classname="test" file="*"/>
333333
<testcase name="large timeout callback test is ok" time="*" classname="test" file="*"/>
334334
<testcase name="successful thenable" time="*" classname="test" file="*"/>
335-
<testcase name="rejected thenable" time="*" classname="test" file="*" failure="custom error">
335+
<testcase name="rejected thenable" time="*" classname="test" file="*">
336336
<failure type="testCodeFailure" message="custom error">
337337
[Error [ERR_TEST_FAILURE]: custom error] { code: 'ERR_TEST_FAILURE', failureType: 'testCodeFailure', cause: 'custom error' }
338338
</failure>
339339
</testcase>
340-
<testcase name="unfinished test with uncaughtException" time="*" classname="test" file="*" failure="foo">
340+
<testcase name="unfinished test with uncaughtException" time="*" classname="test" file="*">
341341
<failure type="uncaughtException" message="foo">
342342
Error [ERR_TEST_FAILURE]: foo
343343
at <node-internal-frames> {
@@ -349,7 +349,7 @@ Error [ERR_TEST_FAILURE]: foo
349349
}
350350
</failure>
351351
</testcase>
352-
<testcase name="unfinished test with unhandledRejection" time="*" classname="test" file="*" failure="bar">
352+
<testcase name="unfinished test with unhandledRejection" time="*" classname="test" file="*">
353353
<failure type="unhandledRejection" message="bar">
354354
Error [ERR_TEST_FAILURE]: bar
355355
at <node-internal-frames> {
@@ -361,7 +361,7 @@ Error [ERR_TEST_FAILURE]: bar
361361
}
362362
</failure>
363363
</testcase>
364-
<testcase name="assertion errors display actual and expected properly" time="*" classname="test" file="*" failure="Expected values to be loosely deep-equal:&#10;&#10;{&#10; bar: 1,&#10; baz: {&#10; date: 1970-01-01T00:00:00.000Z,&#10; null: null,&#10; number: 1,&#10; string: 'Hello',&#10; undefined: undefined&#10; },&#10; boo: [&#10; 1&#10; ],&#10; foo: 1&#10;}&#10;&#10;should loosely deep-equal&#10;&#10;{&#10; baz: {&#10; date: 1970-01-01T00:00:00.000Z,&#10; null: null,&#10; number: 1,&#10; string: 'Hello',&#10; undefined: undefined&#10; },&#10; boo: [&#10; 1&#10; ],&#10; circular: &lt;ref *1> {&#10; bar: 2,&#10; c: [Circular *1]&#10; }&#10;}">
364+
<testcase name="assertion errors display actual and expected properly" time="*" classname="test" file="*">
365365
<failure type="testCodeFailure" message="Expected values to be loosely deep-equal:&#10;&#10;{&#10; bar: 1,&#10; baz: {&#10; date: 1970-01-01T00:00:00.000Z,&#10; null: null,&#10; number: 1,&#10; string: 'Hello',&#10; undefined: undefined&#10; },&#10; boo: [&#10; 1&#10; ],&#10; foo: 1&#10;}&#10;&#10;should loosely deep-equal&#10;&#10;{&#10; baz: {&#10; date: 1970-01-01T00:00:00.000Z,&#10; null: null,&#10; number: 1,&#10; string: 'Hello',&#10; undefined: undefined&#10; },&#10; boo: [&#10; 1&#10; ],&#10; circular: &lt;ref *1> {&#10; bar: 2,&#10; c: [Circular *1]&#10; }&#10;}">
366366
[Error [ERR_TEST_FAILURE]: Expected values to be loosely deep-equal:
367367

@@ -446,7 +446,7 @@ should loosely deep-equal
446446
}
447447
</failure>
448448
</testcase>
449-
<testcase name="invalid subtest fail" time="*" classname="test" file="*" failure="test could not be started because its parent finished">
449+
<testcase name="invalid subtest fail" time="*" classname="test" file="*">
450450
<failure type="parentAlreadyFinished" message="test could not be started because its parent finished">
451451
Error [ERR_TEST_FAILURE]: test could not be started because its parent finished
452452
at Immediate.&lt;anonymous> (<project-root>/test/fixtures/test-runner/output/output.js:197:7) {

0 commit comments

Comments
 (0)