Ensure all React useEffect Effects Run Synchronously in Tests with react-testing-library
lessonDuration 2m 22s
Thanks to [`react-testing-library`](https://github.com/kentcdodds/react-testing-library) our tests are free of implementation details, so when we refactor components to hooks we generally don't need to make any changes to our tests. However, `useEffect` is slightly different from `componentDidMount` in that it's actually executed asynchronously _after_ the render has taken place. So all of our query tests which relied on the HTTP requests being sent immediately after render are failing. Let's use the `flushEffects` utility from `react-testing-library` to ensure that the pending effect callbacks are run before we make assertions.