Skip to content

Commit

Permalink
test: improve lib/internal/test_runner/test.js coverage
Browse files Browse the repository at this point in the history
PR-URL: #42745
Refs: https://coverage.nodejs.org/coverage-24adba675179ebba/lib/internal/test_runner/test.js.html#L371
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Akhil Marsonya <akhil.marsonya27@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
fossamagna authored Apr 27, 2022
1 parent 8d0f49c commit 8cbc390
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 4 deletions.
9 changes: 9 additions & 0 deletions test/message/test_runner_output.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,3 +319,12 @@ test('custom inspect symbol that throws fail', () => {

throw obj;
});

test('subtest sync throw fails', async (t) => {
await t.test('sync throw fails at first', (t) => {
throw new Error('thrown from subtest sync throw fails at first');
});
await t.test('sync throw fails at second', (t) => {
throw new Error('thrown from subtest sync throw fails at second');
});
});
52 changes: 48 additions & 4 deletions test/message/test_runner_output.out
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,51 @@ not ok 55 - custom inspect symbol that throws fail
}
code: 'ERR_TEST_FAILURE'
...
not ok 56 - invalid subtest fail
not ok 1 - sync throw fails at first
---
duration_ms: *
failureType: 'testCodeFailure'
error: 'thrown from subtest sync throw fails at first'
code: 'ERR_TEST_FAILURE'
stack: |-
*
*
*
*
*
*
*
*
*
*
...
not ok 2 - sync throw fails at second
---
duration_ms: *
failureType: 'testCodeFailure'
error: 'thrown from subtest sync throw fails at second'
code: 'ERR_TEST_FAILURE'
stack: |-
*
*
*
*
*
*
*
*
*
*
...
1..2
not ok 56 - subtest sync throw fails
---
duration_ms: *
failureType: 'subtestsFailed'
error: '2 subtests failed'
code: 'ERR_TEST_FAILURE'
...
not ok 57 - invalid subtest fail
---
duration_ms: *
failureType: 'parentAlreadyFinished'
Expand All @@ -457,16 +501,16 @@ not ok 56 - invalid subtest fail
stack: |-
*
...
1..56
1..57
# 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.
# 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.
# 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.
# 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.
# 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.
# 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.
# tests 56
# tests 57
# pass 24
# fail 17
# fail 18
# skipped 10
# todo 5
# duration_ms *

0 comments on commit 8cbc390

Please sign in to comment.