Skip to content

frontend


Function: renderWithRouter()

renderWithRouter(ui, options?): RenderResult\<__module, HTMLElement, HTMLElement>

Defined in: src/test/test-utils.tsx:89

Render component with Router and Mantine Provider

Use this for testing components that use routing (Link, useNavigate) and Mantine UI components.

If you need to test route parameters, provide both routePath and initialRoute:

Parameters

ui

ReactElement

options?

AllProvidersOptions

Returns

RenderResult\<__module, HTMLElement, HTMLElement>

Examples

// For a route with params like "/admin/patients/:patientId"
const { getByRole } = renderWithRouter(<PatientPage />, {
  routePath: "/admin/patients/:patientId",
  initialRoute: "/admin/patients/patient-123"
});
// For simple routes without params
const { getByRole } = renderWithRouter(<LoginPage />);