Improvement: Add act to update call to support hooks (#137)

### Summary
Currently `render` and `fireEvent` are wrapped in `act` to support hooks. This pull request wraps the update call in `act` to support testing component updates (e.g. prop changes).

### Test plan
* I have added a test for update in `__tests__/act.test.js`.
* A useEffect hook should run again on `update` calls (if the hook dependency array is satisfied).
This commit is contained in:
Brad
2019-03-25 10:22:34 -04:00
committed by Kacper Wiszczuk
parent ccad8044ea
commit f96d782d26
3 changed files with 18 additions and 2 deletions
+1 -1
View File
@@ -384,4 +384,4 @@ 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]).
Useful function to help testing components that use hooks API. By default any `render`, `update`, 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]).