Skip to main content
App pages support routing and navigation, which requires special consideration when writing tests. This guide shows you how to test app pages using the UI extensions SDK testing utilities with mocked routing state, paths, and parameters.

Create mocks

When you create a renderer with createRenderer('pages'), the following mocks are available:
Keep the following in mind as you mock out your components and their behavior:
  • 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 findByTestId for 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 call navigateToPage with the correct arguments:

Testing route IDs

When your components use routeId 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

Add testId props to components for stable, maintainable tests:

Mock only what you need

Only mock the parameters your component actually uses:

Test error states

Test how your pages handle missing or invalid parameters:

Remember parameters are strings

All parameters are strings. Convert types when needed:
Check out the following guides for additional guidance on testing and navigating between your pages:
Last modified on April 14, 2026