Skip to content

Commit c735349

Browse files
committed
update tap reporter
1 parent 78e76d3 commit c735349

13 files changed

+177
-5
lines changed

lib/internal/test_runner/reporter/tap.js

+11-5
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,14 @@ async function * tapReporter(source) {
3131
yield `TAP version ${kDefaultTAPVersion}\n`;
3232
for await (const { type, data } of source) {
3333
switch (type) {
34-
case 'test:fail':
34+
case 'test:fail': {
3535
yield reportTest(data.nesting, data.testNumber, 'not ok', data.name, data.skip, data.todo);
36-
yield reportDetails(data.nesting, data.details);
36+
const location = `${data.file}:${data.line}:${data.column}`;
37+
yield reportDetails(data.nesting, data.details, location);
3738
break;
38-
case 'test:pass':
39+
} case 'test:pass':
3940
yield reportTest(data.nesting, data.testNumber, 'ok', data.name, data.skip, data.todo);
40-
yield reportDetails(data.nesting, data.details);
41+
yield reportDetails(data.nesting, data.details, null);
4142
break;
4243
case 'test:plan':
4344
yield `${indent(data.nesting)}1..${data.count}\n`;
@@ -81,13 +82,18 @@ function reportTest(nesting, testNumber, status, name, skip, todo) {
8182
return line;
8283
}
8384

84-
function reportDetails(nesting, data = kEmptyObject) {
85+
function reportDetails(nesting, data = kEmptyObject, location) {
8586
const { error, duration_ms } = data;
8687
const _indent = indent(nesting);
8788
let details = `${_indent} ---\n`;
8889

8990
details += jsToYaml(_indent, 'duration_ms', duration_ms);
9091
details += jsToYaml(_indent, 'type', data.type);
92+
93+
if (location) {
94+
details += jsToYaml(_indent, 'location', location);
95+
}
96+
9197
details += jsToYaml(_indent, null, error, new SafeSet());
9298
details += `${_indent} ...\n`;
9399
return details;

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

+14
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ TAP version 13
2424
not ok 5 - not ok 1
2525
---
2626
duration_ms: *
27+
location: '/test/fixtures/test-runner/output/abort.js:11:7'
2728
failureType: 'cancelledByParent'
2829
error: 'test did not finish before its parent and was cancelled'
2930
code: 'ERR_TEST_FAILURE'
@@ -32,6 +33,7 @@ TAP version 13
3233
not ok 6 - not ok 2
3334
---
3435
duration_ms: ZERO
36+
location: '/test/fixtures/test-runner/output/abort.js:12:7'
3537
failureType: 'cancelledByParent'
3638
error: 'test did not finish before its parent and was cancelled'
3739
code: 'ERR_TEST_FAILURE'
@@ -40,6 +42,7 @@ TAP version 13
4042
not ok 7 - not ok 3
4143
---
4244
duration_ms: ZERO
45+
location: '/test/fixtures/test-runner/output/abort.js:13:7'
4346
failureType: 'testAborted'
4447
error: 'This operation was aborted'
4548
code: 20
@@ -60,6 +63,7 @@ TAP version 13
6063
not ok 8 - not ok 4
6164
---
6265
duration_ms: ZERO
66+
location: '/test/fixtures/test-runner/output/abort.js:14:7'
6367
failureType: 'testAborted'
6468
error: 'This operation was aborted'
6569
code: 20
@@ -80,6 +84,7 @@ TAP version 13
8084
not ok 9 - not ok 5
8185
---
8286
duration_ms: ZERO
87+
location: '/test/fixtures/test-runner/output/abort.js:15:7'
8388
failureType: 'testAborted'
8489
error: 'This operation was aborted'
8590
code: 20
@@ -100,6 +105,7 @@ TAP version 13
100105
not ok 1 - promise timeout signal
101106
---
102107
duration_ms: *
108+
location: '/test/fixtures/test-runner/output/abort.js:5:1'
103109
failureType: 'testAborted'
104110
error: 'The operation was aborted due to timeout'
105111
code: 23
@@ -114,6 +120,7 @@ not ok 1 - promise timeout signal
114120
not ok 2 - promise abort signal
115121
---
116122
duration_ms: *
123+
location: '/test/fixtures/test-runner/output/abort.js:21:1'
117124
failureType: 'testAborted'
118125
error: 'This operation was aborted'
119126
code: 20
@@ -154,6 +161,7 @@ not ok 2 - promise abort signal
154161
not ok 5 - not ok 1
155162
---
156163
duration_ms: *
164+
location: '/test/fixtures/test-runner/output/abort.js:30:5'
157165
failureType: 'cancelledByParent'
158166
error: 'test did not finish before its parent and was cancelled'
159167
code: 'ERR_TEST_FAILURE'
@@ -162,6 +170,7 @@ not ok 2 - promise abort signal
162170
not ok 6 - not ok 2
163171
---
164172
duration_ms: ZERO
173+
location: '/test/fixtures/test-runner/output/abort.js:31:5'
165174
failureType: 'cancelledByParent'
166175
error: 'test did not finish before its parent and was cancelled'
167176
code: 'ERR_TEST_FAILURE'
@@ -170,6 +179,7 @@ not ok 2 - promise abort signal
170179
not ok 7 - not ok 3
171180
---
172181
duration_ms: ZERO
182+
location: '/test/fixtures/test-runner/output/abort.js:32:5'
173183
failureType: 'testAborted'
174184
error: 'This operation was aborted'
175185
code: 20
@@ -190,6 +200,7 @@ not ok 2 - promise abort signal
190200
not ok 8 - not ok 4
191201
---
192202
duration_ms: ZERO
203+
location: '/test/fixtures/test-runner/output/abort.js:33:5'
193204
failureType: 'testAborted'
194205
error: 'This operation was aborted'
195206
code: 20
@@ -210,6 +221,7 @@ not ok 2 - promise abort signal
210221
not ok 9 - not ok 5
211222
---
212223
duration_ms: ZERO
224+
location: '/test/fixtures/test-runner/output/abort.js:34:5'
213225
failureType: 'testAborted'
214226
error: 'This operation was aborted'
215227
code: 20
@@ -230,6 +242,7 @@ not ok 2 - promise abort signal
230242
not ok 3 - callback timeout signal
231243
---
232244
duration_ms: *
245+
location: '/test/fixtures/test-runner/output/abort.js:25:1'
233246
failureType: 'testAborted'
234247
error: 'The operation was aborted due to timeout'
235248
code: 23
@@ -244,6 +257,7 @@ not ok 3 - callback timeout signal
244257
not ok 4 - callback abort signal
245258
---
246259
duration_ms: *
260+
location: '/test/fixtures/test-runner/output/abort.js:39:1'
247261
failureType: 'testAborted'
248262
error: 'This operation was aborted'
249263
code: 20

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

+10
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ TAP version 13
1212
not ok 1 - test 1
1313
---
1414
duration_ms: ZERO
15+
location: '/test/fixtures/test-runner/output/abort_hooks.js:11:3'
1516
failureType: 'cancelledByParent'
1617
error: 'test did not finish before its parent and was cancelled'
1718
code: 'ERR_TEST_FAILURE'
@@ -20,6 +21,7 @@ TAP version 13
2021
not ok 2 - test 2
2122
---
2223
duration_ms: ZERO
24+
location: '/test/fixtures/test-runner/output/abort_hooks.js:14:3'
2325
failureType: 'cancelledByParent'
2426
error: 'test did not finish before its parent and was cancelled'
2527
code: 'ERR_TEST_FAILURE'
@@ -29,6 +31,7 @@ not ok 1 - 1 before describe
2931
---
3032
duration_ms: *
3133
type: 'suite'
34+
location: '/test/fixtures/test-runner/output/abort_hooks.js:4:1'
3235
failureType: 'hookFailed'
3336
error: 'This operation was aborted'
3437
code: 20
@@ -61,6 +64,7 @@ not ok 2 - 2 after describe
6164
---
6265
duration_ms: *
6366
type: 'suite'
67+
location: '/test/fixtures/test-runner/output/abort_hooks.js:19:1'
6468
failureType: 'hookFailed'
6569
error: 'This operation was aborted'
6670
code: 20
@@ -82,6 +86,7 @@ not ok 2 - 2 after describe
8286
not ok 1 - test 1
8387
---
8488
duration_ms: *
89+
location: '/test/fixtures/test-runner/output/abort_hooks.js:41:3'
8590
failureType: 'hookFailed'
8691
error: 'This operation was aborted'
8792
code: 20
@@ -102,6 +107,7 @@ not ok 2 - 2 after describe
102107
not ok 2 - test 2
103108
---
104109
duration_ms: *
110+
location: '/test/fixtures/test-runner/output/abort_hooks.js:44:3'
105111
failureType: 'hookFailed'
106112
error: 'This operation was aborted'
107113
code: 20
@@ -123,6 +129,7 @@ not ok 3 - 3 beforeEach describe
123129
---
124130
duration_ms: *
125131
type: 'suite'
132+
location: '/test/fixtures/test-runner/output/abort_hooks.js:34:1'
126133
failureType: 'subtestsFailed'
127134
error: '2 subtests failed'
128135
code: 'ERR_TEST_FAILURE'
@@ -132,6 +139,7 @@ not ok 3 - 3 beforeEach describe
132139
not ok 1 - test 1
133140
---
134141
duration_ms: *
142+
location: '/test/fixtures/test-runner/output/abort_hooks.js:56:3'
135143
failureType: 'hookFailed'
136144
error: 'This operation was aborted'
137145
code: 20
@@ -152,6 +160,7 @@ not ok 3 - 3 beforeEach describe
152160
not ok 2 - test 2
153161
---
154162
duration_ms: *
163+
location: '/test/fixtures/test-runner/output/abort_hooks.js:59:3'
155164
failureType: 'hookFailed'
156165
error: 'This operation was aborted'
157166
code: 20
@@ -173,6 +182,7 @@ not ok 4 - 4 afterEach describe
173182
---
174183
duration_ms: *
175184
type: 'suite'
185+
location: '/test/fixtures/test-runner/output/abort_hooks.js:49:1'
176186
failureType: 'subtestsFailed'
177187
error: '2 subtests failed'
178188
code: 'ERR_TEST_FAILURE'

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

+7
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ TAP version 13
2424
not ok 5 - not ok 1
2525
---
2626
duration_ms: *
27+
location: '/test/fixtures/test-runner/output/abort_suite.js:10:3'
2728
failureType: 'cancelledByParent'
2829
error: 'test did not finish before its parent and was cancelled'
2930
code: 'ERR_TEST_FAILURE'
@@ -32,6 +33,7 @@ TAP version 13
3233
not ok 6 - not ok 2
3334
---
3435
duration_ms: ZERO
36+
location: '/test/fixtures/test-runner/output/abort_suite.js:11:3'
3537
failureType: 'cancelledByParent'
3638
error: 'test did not finish before its parent and was cancelled'
3739
code: 'ERR_TEST_FAILURE'
@@ -40,6 +42,7 @@ TAP version 13
4042
not ok 7 - not ok 3
4143
---
4244
duration_ms: ZERO
45+
location: '/test/fixtures/test-runner/output/abort_suite.js:12:3'
4346
failureType: 'testAborted'
4447
error: 'This operation was aborted'
4548
code: 20
@@ -60,6 +63,7 @@ TAP version 13
6063
not ok 8 - not ok 4
6164
---
6265
duration_ms: ZERO
66+
location: '/test/fixtures/test-runner/output/abort_suite.js:13:3'
6367
failureType: 'testAborted'
6468
error: 'This operation was aborted'
6569
code: 20
@@ -80,6 +84,7 @@ TAP version 13
8084
not ok 9 - not ok 5
8185
---
8286
duration_ms: ZERO
87+
location: '/test/fixtures/test-runner/output/abort_suite.js:14:3'
8388
failureType: 'testAborted'
8489
error: 'This operation was aborted'
8590
code: 20
@@ -101,6 +106,7 @@ not ok 1 - describe timeout signal
101106
---
102107
duration_ms: *
103108
type: 'suite'
109+
location: '/test/fixtures/test-runner/output/abort_suite.js:5:1'
104110
failureType: 'testAborted'
105111
error: 'The operation was aborted due to timeout'
106112
code: 23
@@ -116,6 +122,7 @@ not ok 2 - describe abort signal
116122
---
117123
duration_ms: *
118124
type: 'suite'
125+
location: '/test/fixtures/test-runner/output/abort_suite.js:19:1'
119126
failureType: 'testAborted'
120127
error: 'This operation was aborted'
121128
code: 20

0 commit comments

Comments
 (0)