Skip to content

Commit b3157a0

Browse files
ognjenjevremovicrichardlau
authored andcommittedMar 25, 2024
doc: clarify execution of after hook on test suite completion
The `after` hook now explicitly mentions that it is executed once after all the tests in a test suite have completed, regardless of whether the tests passed or failed. This ensures that cleanup tasks or actions specified in the after hook are guaranteed to run. Refs: #50901 PR-URL: #51523 Reviewed-By: Marco Ippolito <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Moshe Atlow <[email protected]>
1 parent 8e84aad commit b3157a0

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed
 

‎doc/api/test.md

+6
Original file line numberDiff line numberDiff line change
@@ -1435,6 +1435,9 @@ describe('tests', async () => {
14351435
});
14361436
```
14371437

1438+
**Note:** The `after` hook is guaranteed to run,
1439+
even if tests within the suite fail.
1440+
14381441
## `beforeEach([fn][, options])`
14391442

14401443
<!-- YAML
@@ -1488,6 +1491,9 @@ added:
14881491
This function is used to create a hook running
14891492
after each subtest of the current test.
14901493

1494+
**Note:** The `afterEach` hook is guaranteed to run after every test,
1495+
even if any of the tests fail.
1496+
14911497
```js
14921498
describe('tests', async () => {
14931499
afterEach(() => console.log('finished running a test'));

0 commit comments

Comments
 (0)
Please sign in to comment.