Using React Router DOM (v6) with React Testing Library, I would like to know if there's a way to deal with "mocked" history from createMemoryHistoryor an alternative like it.
Based on the example of Testing Library, I could mock the history on the Router component but in v6 this component doesn't accept the history prop anymore.
So, my doubt is: how can I test history and location with RTL (React Testing Library) with React Router DOM v6? Should I keep using the MemoryRouter?
Using react router dom v6, Router use navigator prop to accept history.
const history = createMemoryHistory();
...
<MockedProvider mocks={[]}>
<Router navigator={history} location={"/"}>
<Home />
</Router>
</MockedProvider>
...
await waitFor(() => {
expect(history.location.pathname).toBe("/");
});