Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: improve lib/internal/test_runner/test.js coverage #42745

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 *