Testing Action Creators
Understand how to test Redux action creators that return plain JavaScript objects without side effects. This lesson guides you through writing clear tests using Jest's expect and toEqual functions, ensuring your action creators produce consistent and correct results.
We'll cover the following...
We'll cover the following...
We have tried to keep asynchronous flows out of action creators throughout this course by moving them into middleware and utility functions. This approach allows for easy testing of action creators, as they are functions that return plain JavaScript objects:
import * as actions from 'constants/actionTypes';
export const setRecipes = recipes => ({
type: actions.SET_RECIPES,
payload: recipes
});
Our ...