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:

import React, { PureComponent } from 'react';
import { connect } from 'react-redux';
import { getState } from './getFooterState';

class Footer extends PureComponent {
    render() {
        return (
            <div>
                Some Text
            </div>
        );
    }
}
export default connect(getState)(Footer);
```

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

import React from 'react';
import { shallow } from 'enzyme';
import Footer from '../';
import { Provider } from 'react-redux';
import configureStore from 'redux-mock-store';

const mockStore = configureStore();
const store = mockStore();

const props = {};

describe('My Footer Component', () => {
    it('should render correctly with default props and redux store', () => {
        const wrapper = shallow(
            <Provider store={store}>
                <Footer {...props} />
            </Provider>
        );
        expect(wrapper).toMatchSnapshot();
    });
});

In the code above we created a mock store, using configureStore. We pass the mock store into [Provider](https://react-redux.js.org/api/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:

const mockStore = configureStore();
const store = mockStore({
    myProp: "Hello"
});

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

it('should dispatch both', () => {
    const dispatch = jest.fn();
    store.dispatch = dispatch;

    const wrapper = shallow(
        <Provider store={store}>
            <Footer {...props} error={true} />
        </Provider>
    );

expect(dispatch).toHaveBeenCalledTimes(1);