mirror of
https://github.com/reactjs/react.dev.git
synced 2026-02-23 20:23:08 +00:00
react-testing-library now supports act (#1635)
* react-testing-library now supports `act` * fix typo
This commit is contained in:
committed by
Dan Abramov
parent
2a5b6cc103
commit
f846c4da1b
@@ -50,7 +50,7 @@ Even while Hooks were in alpha, the React community created many interesting [ex
|
||||
|
||||
## Testing Hooks
|
||||
|
||||
We have added a new API called `ReactTestUtils.act()` in this release. It ensures that the behavior in your tests matches what happens in the browser more closely. We recommend to wrap any code rendering and triggering updates to your components into `act()` calls. Testing libraries like [`react-testing-library`](https://github.com/kentcdodds/react-testing-library) can also wrap their APIs with it.
|
||||
We have added a new API called `ReactTestUtils.act()` in this release. It ensures that the behavior in your tests matches what happens in the browser more closely. We recommend to wrap any code rendering and triggering updates to your components into `act()` calls. Testing libraries can also wrap their APIs with it (for example, [`react-testing-library`](https://github.com/kentcdodds/react-testing-library)'s `render` and `fireEvent` utilities do this).
|
||||
|
||||
For example, the counter example from [this page](/docs/hooks-effect.html) can be tested like this:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user