feat: wrap render with act() for better React Hooks support (#122)

This commit is contained in:
Kacper Wiszczuk
2019-02-28 21:53:26 +01:00
committed by Michał Pierzchała
parent 747e864369
commit 11489b0e5e
11 changed files with 144 additions and 35 deletions
+4
View File
@@ -379,3 +379,7 @@ const { queryAllByText } = render(<Forms />);
const submitButtons = queryAllByText('submit');
expect(submitButtons).toHaveLength(3); // expect 3 elements
```
## `act`
Useful function to help testing components that use hooks API. By default any `render` and `fireEvent` calls are wrapped by this function, so there is no need to wrap it manually. This method is re-exported from [`react-test-renderer`](https://github.com/facebook/react/blob/master/packages/react-test-renderer/src/ReactTestRenderer.js#L567]).