I have a problem that I don\'t know how to solve, I get this error when running npm test
Invariant Violation: You should not use
The proper way to handle this, according to React Router devs, is to wrap your unit test in a Router. Using MemoryRouter
is recommended in order to be able to reset the router between tests.
You can still do something like the following:
Then in App
:
Your unit tests for App
would normally be something like:
const content = render( ); // Fails Unit test
Update the unit test to:
const content = render( ); // Passes Unit test