-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test_runner: run after hooks even if test is aborted
If a test is run, but aborted, any after hooks should still be run, as they may need to perform cleanup. PR-URL: #54151 Reviewed-By: Chemi Atlow <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Jake Yuesong Li <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Raz Luvaton <[email protected]>
- Loading branch information
Showing
4 changed files
with
40 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
'use strict'; | ||
const { test } = require('node:test'); | ||
|
||
test('test that aborts', (t, done) => { | ||
t.after(() => { | ||
// This should still run. | ||
console.log('AFTER'); | ||
}); | ||
|
||
setImmediate(() => { | ||
// This creates an uncaughtException, which aborts the test. | ||
throw new Error('boom'); | ||
}); | ||
}); |
23 changes: 23 additions & 0 deletions
23
test/fixtures/test-runner/output/abort-runs-after-hook.snapshot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
TAP version 13 | ||
AFTER | ||
# Subtest: test that aborts | ||
not ok 1 - test that aborts | ||
--- | ||
duration_ms: * | ||
location: '/test/fixtures/test-runner/output/abort-runs-after-hook.js:(LINE):1' | ||
failureType: 'uncaughtException' | ||
error: 'boom' | ||
code: 'ERR_TEST_FAILURE' | ||
stack: |- | ||
* | ||
* | ||
... | ||
1..1 | ||
# tests 1 | ||
# suites 0 | ||
# pass 0 | ||
# fail 1 | ||
# cancelled 0 | ||
# skipped 0 | ||
# todo 0 | ||
# duration_ms * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters