Error: useHref() may be used only in the context of a <Router> component when testing

Solution 1:

When a component requires context of some sort (e.g. with Redux's connect()ed components, or here with react-router), instead of just rendering the component itself,

render(<IngredientsCenter />);

you'll need to wrap it in the provider(s) it requires:

render(<Router><IngredientsCenter /></Router>);

If you find yourself needing to do that a lot, you can of course write a wrapper:

function renderWithProviders(el) {
  render(<Providers><Router>{el}</Router></Providers>);
}