Skip to content

Commit

Permalink
review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
phryneas committed Dec 4, 2024
1 parent b0d022f commit 4d2345b
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,17 +267,17 @@ await expect(snapshotStream).toRerender()
## Usage side-by side with `@testing-library/react` or other tools that use `act` or set `IS_REACT_ACT_ENVIRONMENT`
This library should not be used with `act`, and it will throw an error if `IS_REACT_ACT_ENVIRONMENT` is `true`
throw an error if `IS_REACT_ACT_ENVIRONMENT` is `true`.
React Testing Library sets `IS_REACT_ACT_ENVIRONMENT` to `true`
globally, and wraps some helpers like `userEvent.click` in `act` calls.
This library should not be used with `act`, and it will throw an error if
`IS_REACT_ACT_ENVIRONMENT` is `true`.
React Testing Library sets `IS_REACT_ACT_ENVIRONMENT` to `true` globally, and
wraps some helpers like `userEvent.click` in `act` calls.
To use this library side-by-side with React Testing Library, we ship the
`disableActEnvironment` helper to undo these changes temporarily.
It returns a `Disposable` and can be used together with the `using` keyword to
automatically clean up once the scope is left:
It returns a `Disposable` and can be used together with the
[`using` keyword](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-2.html#using-declarations-and-explicit-resource-management)
to automatically clean up once the scope is left:
```ts
test('my test', () => {
Expand All @@ -290,7 +290,8 @@ test('my test', () => {
```
If you cannot use `using`, you can also manually call the returned `cleanup`
function:
function. We recommend using `finally` to ensure the act environment is cleaned
up if your test fails, otherwise it could leak between tests:

```ts
test('my test', () => {
Expand Down

0 comments on commit 4d2345b

Please sign in to comment.