Create mocks
When you create a renderer withcreateRenderer('pages'), the following mocks are available:
- Use
'pages'as the extension point location when creating a renderer - Mock the current route using
mocks.router.setCurrentRoute()with path and params - Always render the full
<AppPages />component with<PageRoutes>, not individual page components - Use
findByTestIdfor reliable component querying in tests
Testing app pages with routing and parameters
This example demonstrates the most common testing scenario: rendering an app with routing and testing that the correct page component displays with the right parameters.Always render the full
<AppPages /> component with <PageRoutes> in your tests. This ensures you’re testing the actual routing behavior, not just individual page components in isolation.Testing navigation
The following code blocks demonstrate how to test that your components callnavigateToPage with the correct arguments:
Testing route IDs
When your components userouteId from usePageRoute(), include the routeId field in your setCurrentRoute call to mock the matched route’s ID:
Testing recommendations and examples
The sections below provide guidance on how to test your app pages and their associated functionality:Always render the full app structure
Render<AppPages /> with <PageRoutes>, not individual page components:
Use findByTestId for reliable querying
AddtestId props to components for stable, maintainable tests: