Learn how to create integration tests for your app when using Expo Router.

Expo Router relies on your file system, which can present challenges when setting up mocks for integration tests. Expo Router's submodule, expo-router/testing-library, is a set of testing utilities built on top of the popular @testing-library/react-native and allows you to quickly create in-memory Expo Router apps that are pre-configured for testing.


Before you proceed, ensure you have set up jest-expo according to the Unit Testing and @testing-library/react-native.


renderRouter extends the functionality of render to simplify testing with Expo Router. It returns the same query object as render, and is compatible with screen, allowing you to use the standard query API to locate components.

renderRouter accepts the same options as render and introduces an additional option initialUrl, which sets an initial route for simulating deep-linking.

Inline file system

renderRouter(mock: Record<string, ReactComponent>, options: RenderOptions)

renderRouter can provide inline-mocking of a file system by passing an object to this function as the first parameter. The keys of the object are the mock filesystem paths. Do not use leading relative (./) or absolute (/) notation when defining these paths and exclude file extension.

import { renderRouter, screen } from 'expo-router/testing-library';

it('my-test', async () => {
  const MockComponent = jest.fn(() => <View />);

      index: MockComponent,
      'folder/a': MockComponent,
      '(group)/b': MockComponent,
      initialUrl: '/folder/a',


Path to fixture

renderRouter(fixturePath: string, options: RenderOptions)

renderRouter can accept a directory path to mock an existing fixture. Ensure that the provided path is relative to the current test file.

it('my-test', async () => {
  const MockComponent = jest.fn(() => <View />);

Path to the fixture with overrides

renderRouter({ appDir: string, overrides: Record<string, ReactComponent>}, options: RenderOptions)

For more intricate testing scenarios, renderRouter can leverage both directory path and inline-mocking methods simultaneously. The appDir parameter takes a string representing a pathname to a folder. The overrides parameter is an inline mock that can be used to override specific paths within the appDir. This combination allows for fine-tuned control over the mock environment.

it('my-test', async () => {
  const MockAuthLayout = jest.fn(() => <View />);
    appDir: './my-test-fixture',
    overrides: {
      'folder/(auth)/_layout': MockAuthLayout,

Jest matchers

The following matches have been added to expect and can be used to asset values on screen.


Assert the current pathname against a given string. The matcher uses the value of the usePathname hook on the current screen.



Assert the current segments against an array of strings. The matcher uses the value of the useSegments hook on the current screen.



Assert the current local search parameters against an object. The matcher uses the value of the useLocalSearchParams hook on the current screen.

expect(screen).useLocalSearchParams({ first: 'abc' });


Assert the current screen's pathname that matches a value. Compares using the value of useGlobalSearchParams hook.

Assert the current global search parameters against an object. The matcher uses the value of the useGlobalSearchParams hook on the current screen.

expect(screen).useGlobalSearchParams({ first: 'abc' });