Created
November 8, 2018 17:15
-
-
Save ncpope/a9da1698d919108f104cd1d7e4bec5e9 to your computer and use it in GitHub Desktop.
Testing a redux connected ReactJS component using Jest, Enzyme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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