Context
PR #1641 review noted that the PR correctly migrated most test files from BrowserRouter to MemoryRouter, which is React Router's recommended approach for unit tests (keeps location changes in memory without touching the browser's history API). Two test files were not part of the PR's scope and still use BrowserRouter.
Files
1. src/common-components/tests/EmbeddedRegistrationRoute.test.jsx
- 2
BrowserRouter usages (1 import, 1 render wrapper)
- Replace with
MemoryRouter and pass initialEntries as needed
2. src/common-components/tests/UnAuthOnlyRoute.test.jsx
- 2
BrowserRouter usages (1 import, 1 render wrapper)
- Replace with
MemoryRouter and pass initialEntries as needed
Migration pattern
Each file will:
- Replace
import { BrowserRouter } with import { MemoryRouter } from react-router-dom
- Replace
<BrowserRouter> wrapper with <MemoryRouter initialEntries={['/path']}> using the appropriate test route
Context
PR #1641 review noted that the PR correctly migrated most test files from
BrowserRoutertoMemoryRouter, which is React Router's recommended approach for unit tests (keeps location changes in memory without touching the browser's history API). Two test files were not part of the PR's scope and still useBrowserRouter.Files
1.
src/common-components/tests/EmbeddedRegistrationRoute.test.jsxBrowserRouterusages (1 import, 1 render wrapper)MemoryRouterand passinitialEntriesas needed2.
src/common-components/tests/UnAuthOnlyRoute.test.jsxBrowserRouterusages (1 import, 1 render wrapper)MemoryRouterand passinitialEntriesas neededMigration pattern
Each file will:
import { BrowserRouter }withimport { MemoryRouter }fromreact-router-dom<BrowserRouter>wrapper with<MemoryRouter initialEntries={['/path']}>using the appropriate test route