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 pull[bot] committed Apr 10, 2024
1 parent e618ba1 commit d4667c8
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions doc/api/test.md
Expand Up @@ -1420,6 +1420,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 @@ -1473,6 +1476,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 d4667c8

Please sign in to comment.