Testing a Redux Container, Actions, and Reducers
In this recipe, we are going to test a Redux Container, Actions, and Reducers. For this example, we will test the Todo list that we created in Chapter 11, Implementing Server-Side Rendering.
Note
Remember always that we use an existing recipe you must run npm install command first to restore all the project dependencies otherwise, you will get dependency errors.
Getting Ready
We need to install the redux-mock-store
, moxios
, and redux-thunk
packages to test our Redux containers. You will need to run npm install
first to install all the dependencies:
npm install // This is to install the previous packages
npm install redux-mock-store moxios redux-thunk
How to do it...
Let's test our Redux containers:
- Redux containers should not have any JSX code; the best practice is to have
mapStateToProps
andmapDispatchToProps
in ourconnect
method passing another component (such as aLayout
component) in the export, for example, let's see our Todo List Container...