Question · JavaScript and React course · Module 6: React Router

Testing components with routing

Which React Router component is recommended for use in unit tests instead of BrowserRouter?

Answer options

  • MemoryRouter - allows controlling navigation history in tests without a browser
  • HashRouter - automatically mocks navigation in the test environment
  • StaticRouter - required in all React unit tests
  • TestRouter - a special React Router component designed for testing

You can check the correct answer by solving this task in the CodeWorlds game.