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 <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Moshe Atlow <[email protected]>
  • Loading branch information
ognjenjevremovic authored and targos committed Feb 15, 2024
1 parent 1999719 commit c9be260
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 @@ -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 c9be260

Please sign in to comment.