I am full rendering a component using mount
like this:
const wrapper = mount(<Component />);
And this component renders a child component which uses React-Redux. I want to provide the Redux mock store to only the child component. How do I do it?
A store should be provided to whole component hierarchy:
mount(<Provider store={mockStore}><Component /></Provider>)
This should create no problems if testing strategy was chosen properly. In case parent and child components need different conditions to be tested, this likely means that they should be tested in isolation with shallow
instead of mount
.
Component
a problem? There's no good way to do this, and the problem is likely in a way you test it. – Estus Flaskshallow
belongs to Enzyme, not Jest. – Estus Flask