Skip to content

Instantly share code, notes, and snippets.

@ncpope
Created November 8, 2018 17:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ncpope/a9da1698d919108f104cd1d7e4bec5e9 to your computer and use it in GitHub Desktop.
Save ncpope/a9da1698d919108f104cd1d7e4bec5e9 to your computer and use it in GitHub Desktop.
Testing a redux connected ReactJS component using Jest, Enzyme
import React from 'react';
import { shallow } from 'enzyme';
import configureStore from 'redux-mock-store';
import thunk from 'redux-thunk';
import Example from './Example';
const middlewares = [thunk]
const mockStore = configureStore(middlewares)
const initialState = {
example: {}
}
const store = mockStore(initialState)
describe('Example', () => {
it('matches the snapshot', () => {
const wrapper = shallow(
<Example store={store} />,
).dive();
expect(wrapper).toMatchSnapshot();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment