You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When you want to test a React component after an operation that dispatches a Redux action, you need to make it sure that before your test code goes, all the React components connected to the Redux store are thoroughly updated based on the new state. You can easily assure it with `act()` provided by [React Test Utility](https://reactjs.org/docs/test-utils.html#act) or [Testing Library for React](https://testing-library.com/docs/react-testing-library/api#act).
7
+
When you want to test a React component after an operation that dispatches a Redux action, you need to make it sure that before your test code goes on, all the React components connected to the Redux store are thoroughly updated based on the new state. We can easily assure it with `act()` provided by [React Test Utility](https://reactjs.org/docs/test-utils.html#act) or [Testing Library for React](https://testing-library.com/docs/react-testing-library/api#act).
8
8
9
9
However, it cannot help when a test target operation dispatches Redux actions asynchronously, like the thunk action below.
`listenAsync()` function runs `act` property of its parameter object over the [`act()` of React Test Utility](https://reactjs.org/docs/test-utils.html#act), and waits for a Redux action to be dispatched. When the dispatched action matches one of the action types specified in the `targets` property, Stethoscope calls back the function in the corresponding `onUpdated` property. `listenAsync()` keeps waiting until all the action types in the `targets` are dispatched.
0 commit comments