Using Jest to test a Link from react-router v4
I'm using jest to test a component with a <Link> from react-router v4. I get a warning that <Link /> requires the context from a react-router <Router /> component. How can I mock or provide a router context in my test? (Basically how do I resolve this warning?) Link.test.js import React from 'react'; import renderer from 'react-test-renderer'; import { Link } from 'react-router-dom'; test('Link matches snapshot', () => { const component = renderer.create( <Link to="#" /> ); let tree = component.toJSON(); expect(tree).toMatchSnapshot(); }); The warning when the test is run: Warning: Failed