Testing · Middle · Question 29 of 75
How do you test a component that depends on the current route (React Router)?
- ✓Correct answer: Render it inside
createMemoryRouter/MemoryRouterwithinitialEntries - 2Change
window.location.hrefin the test - 3Mock
useParamsglobally
Explanation
A memory router gives a real navigation context without a browser URL.