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: nodejs/node#42745
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 and aduh95 committed Jul 9, 2022
1 parent c6a39dd commit 39cce8a
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 5 deletions.
11 changes: 10 additions & 1 deletion test/message/test_runner_output.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// https://github.com/nodejs/node/blob/1aab13cad9c800f4121c1d35b554b78c1b17bdbd/test/message/test_runner_output.js
// https://github.com/nodejs/node/blob/8cbc39068cd102e3bbdb6c5a1d14ce450e6ef093/test/message/test_runner_output.js
// Flags: --no-warnings
'use strict'
require('../common')
Expand Down Expand Up @@ -320,3 +320,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 39cce8a

Please sign in to comment.