We use Enzyme and Jest for testing. Updated to the latest version of react-redux in our code base, and all of the connected component test cases started failing (Version 6). Using
import { createMockStore } from 'redux-test-utils';
to create store
Test cases that worked with older version:
const wrapper = shallow(<SomeConnectedComponent />, {context: { store }});
This fails giving error
Invariant Violation: Could not find "store" in the context of "Connect(SomeConnectedComponent )".
Reading few posts, got a suggestion to mount and wrap with provider wrapper
const wrapper = mount(<Provider store={store}><SomeConnectedComponent /></Provider>);
Above code works, but I want it to work with swallow for unit testing.
Edit :
const wrapper = shallow(<Provider store={store}>
<SomeConnectedComponent />
</Provider>)
Above code returns empty shallowWraper object.
What is the best way to swallow connected component with react-redux version > 6