Skip to content

Commit b3157a0

Browse files
ognjenjevremovicrichardlau
authored andcommitted
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 <marcoippolito54@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
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

Lines changed: 6 additions & 0 deletions
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)