I have a simple component that uses react-router (I'm aware this is the alpha build):
{props.app && props.app.health &&
<Match exactly pattern="/" component={HomeLogin} />
}
The docs recommending wrapping in <MemoryRouter /> to provide context to components while testing.
However, with Jest/Enzyme I'm not able to shallow() render - I have to use Enzyme's mount() or render(), which causes problems because HomeLogin is a connected component - I want to be able to test that my component renders the right thing, but not test the component rendered within it.
My test:
it('Renders based upon matched route', () => {
let props = {
app: { health: true },
};
const component = render(
<Provider store={store}>
<MemoryRouter location="/">
<Jumbotron {...props} />
</MemoryRouter>
</Provider>
);
expect(toJson(component)).toMatchSnapshot();
});
How can I test the output of this component based upon the route without having to provide the redux store or using shallow render?
Update: If I try to use shallow() the snapshot renders no output.