Skip to content

Commit

Permalink
doc: clarify execution of after hook on test suite completion
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
ognjenjevremovic authored and richardlau committed Mar 25, 2024
1 parent 8e84aad commit b3157a0
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions doc/api/test.md
Original file line number Diff line number Diff line change
Expand Up @@ -1435,6 +1435,9 @@ describe('tests', async () => {
});
```

**Note:** The `after` hook is guaranteed to run,
even if tests within the suite fail.

## `beforeEach([fn][, options])`

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

**Note:** The `afterEach` hook is guaranteed to run after every test,
even if any of the tests fail.

```js
describe('tests', async () => {
afterEach(() => console.log('finished running a test'));
Expand Down

0 comments on commit b3157a0

Please sign in to comment.