React testing library and react router v6 error

i start to learning react testing library a few days ago and i dont know how to make my tests works with react router v6. I have this two test below:

  describe('testing login page', () => {
  test('veryfy inputs and buttons in login page', () => {
    render(
      <MemoryRouter initialEntries={['/']}>
        <Routes>
          <Route path="/" element={<LoginPage />} />
        </Routes>
      </MemoryRouter>,
    );
    const userInput = screen.getByRole('textbox');
    expect(userInput).toBeInTheDocument();
  describe('testing Mine Page', () => {
  test('check table components', () => {
    render(
      <MemoryRouter initialEntries={['/mina']}>
        <Routes>
          <Route path="/mina" element={<MineTable />} />
        </Routes>
      </MemoryRouter>,
    );
    const pageTitle = screen.getByRole('heading', { name: /mina/i });
    expect(pageTitle).toBeInTheDocument();
  });

Only the first test works, the second don’t render the page MineTable, keeps rendering the last page Login. It’s like the history of the first test render remains. Someone can help me? I want to test every page component of my application.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.