In this tutorial, I will share some code to help you test any of your React components that are connected to Redux. Let's start with this very simple component:

First, let's write the simplest test, writing a snapshot test for the rendered component:

In the code above we created a mock store, using configureStore. We pass the mock store into [Provider]( The component makes the Redux store available to any nested components that have been wrapped in the connect() function, perfect for our needs. Next, we write a simple test using toMatchSnapshot(), job done.

If you want to add some default state into your store you can do this by passing props into your mock store, like so:

If you want to test that certain actions have been triggered, you can mock the dispatch call like so: