Skip to content

Commit ba68062

Browse files
fossamagnaaduh95
authored andcommitted
test: improve lib/internal/test_runner/test.js coverage
PR-URL: nodejs/node#42745 Refs: https://coverage.nodejs.org/coverage-24adba675179ebba/lib/internal/test_runner/test.js.html#L371 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Akhil Marsonya <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 344e278 commit ba68062

File tree

2 files changed

+58
-5
lines changed

2 files changed

+58
-5
lines changed

test/message/test_runner_output.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// https://github.com/nodejs/node/blob/1aab13cad9c800f4121c1d35b554b78c1b17bdbd/test/message/test_runner_output.js
1+
// https://github.com/nodejs/node/blob/8cbc39068cd102e3bbdb6c5a1d14ce450e6ef093/test/message/test_runner_output.js
22
// Flags: --no-warnings
33
'use strict'
44
require('../common')
@@ -320,3 +320,12 @@ test('custom inspect symbol that throws fail', () => {
320320

321321
throw obj
322322
})
323+
324+
test('subtest sync throw fails', async (t) => {
325+
await t.test('sync throw fails at first', (t) => {
326+
throw new Error('thrown from subtest sync throw fails at first')
327+
})
328+
await t.test('sync throw fails at second', (t) => {
329+
throw new Error('thrown from subtest sync throw fails at second')
330+
})
331+
})

test/message/test_runner_output.out

+48-4
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,51 @@ not ok 55 - custom inspect symbol that throws fail
448448
}
449449
code: 'ERR_TEST_FAILURE'
450450
...
451-
not ok 56 - invalid subtest fail
451+
not ok 1 - sync throw fails at first
452+
---
453+
duration_ms: *
454+
failureType: 'testCodeFailure'
455+
error: 'thrown from subtest sync throw fails at first'
456+
code: 'ERR_TEST_FAILURE'
457+
stack: |-
458+
*
459+
*
460+
*
461+
*
462+
*
463+
*
464+
*
465+
*
466+
*
467+
*
468+
...
469+
not ok 2 - sync throw fails at second
470+
---
471+
duration_ms: *
472+
failureType: 'testCodeFailure'
473+
error: 'thrown from subtest sync throw fails at second'
474+
code: 'ERR_TEST_FAILURE'
475+
stack: |-
476+
*
477+
*
478+
*
479+
*
480+
*
481+
*
482+
*
483+
*
484+
*
485+
*
486+
...
487+
1..2
488+
not ok 56 - subtest sync throw fails
489+
---
490+
duration_ms: *
491+
failureType: 'subtestsFailed'
492+
error: '2 subtests failed'
493+
code: 'ERR_TEST_FAILURE'
494+
...
495+
not ok 57 - invalid subtest fail
452496
---
453497
duration_ms: *
454498
failureType: 'parentAlreadyFinished'
@@ -457,16 +501,16 @@ not ok 56 - invalid subtest fail
457501
stack: |-
458502
*
459503
...
460-
1..56
504+
1..57
461505
# Warning: Test "unhandled rejection - passes but warns" generated asynchronous activity after the test ended. This activity created the error "Error: rejected from unhandled rejection fail" and would have caused the test to fail, but instead triggered an unhandledRejection event.
462506
# Warning: Test "async unhandled rejection - passes but warns" generated asynchronous activity after the test ended. This activity created the error "Error: rejected from async unhandled rejection fail" and would have caused the test to fail, but instead triggered an unhandledRejection event.
463507
# Warning: Test "immediate throw - passes but warns" generated asynchronous activity after the test ended. This activity created the error "Error: thrown from immediate throw fail" and would have caused the test to fail, but instead triggered an uncaughtException event.
464508
# Warning: Test "immediate reject - passes but warns" generated asynchronous activity after the test ended. This activity created the error "Error: rejected from immediate reject fail" and would have caused the test to fail, but instead triggered an unhandledRejection event.
465509
# Warning: Test "callback called twice in different ticks" generated asynchronous activity after the test ended. This activity created the error "Error [ERR_TEST_FAILURE]: callback invoked multiple times" and would have caused the test to fail, but instead triggered an uncaughtException event.
466510
# Warning: Test "callback async throw after done" generated asynchronous activity after the test ended. This activity created the error "Error: thrown from callback async throw after done" and would have caused the test to fail, but instead triggered an uncaughtException event.
467-
# tests 56
511+
# tests 57
468512
# pass 24
469-
# fail 17
513+
# fail 18
470514
# skipped 10
471515
# todo 5
472516
# duration_ms *

0 commit comments

Comments
 (0)