Testing components that use Redux
This section will teach you how to test components that use the popular Redux library to manage the application state. The strategies used in this section will be very similar to those used in the previous section, with a few differences. While testing components using the Context API in the last section, we learned that those components must be used within Context Provider.
To test components using Redux, components must be used within the Redux state providing context:
ReactDOM.render(
  <Provider store={store}>
    <App />
  </Provider>,
  document.getElementById('root')
)
In the preceding code, we have a top-level App passed in as a child component of the Redux Provider component. Wrapping the top-level App component is a common pattern in Redux that allows any child component in the application to access the stateful data provided by Redux. Stateful data and...