Skip to content

Commit

Permalink
doc: improve clarity in after and afterEach hook documentation
Browse files Browse the repository at this point in the history
Refined the documentation for the `after` and `afterEach` hooks to
enhance clarity. Removed redundant information and retained the
essential details. The revised note now explicitly states that the
`after` and `afterEach` hooks are guaranteed to run, even if tests
within the suite fail.

Refs: nodejs#50901
  • Loading branch information
ognjenjevremovic committed Jan 20, 2024
1 parent 669ccaa commit 8a1bedd
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions doc/api/test.md
Original file line number Diff line number Diff line change
Expand Up @@ -1420,11 +1420,7 @@ describe('tests', async () => {
});
```

**Note:** The `after` hook is executed once after all the tests
in a test suite have completed, regardless of whether the tests
passed or failed. This hook is useful for performing cleanup tasks
or actions that should occur after the entire test suite has been run.
The `after` hook is guaranteed to run, even if tests within the suite fail.
**Note:** The `after` hook is guaranteed to run, even if tests within the suite fail.

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

Expand Down Expand Up @@ -1479,10 +1475,7 @@ added:
This function is used to create a hook running
after each subtest of the current test.

**Note:** The `afterEach` hook is executed after each individual test
in a test suite, regardless of whether the test passed or failed.
This hook is commonly used for cleaning up resources or resetting state
between tests. The `afterEach` hook is guaranteed to run after every test,
**Note:** The `afterEach` hook is guaranteed to run after every test,
even if any of the tests fail.

```js
Expand Down

0 comments on commit 8a1bedd

Please sign in to comment.