{"id":13164,"library":"expo-test-runner","title":"Expo Test Runner (Deprecated)","description":"The `expo-test-runner` package (version 0.3.12 is given) is officially deprecated and its GitHub repository was archived on September 30, 2022. It was designed as a script to enhance the test experience within Expo projects, primarily serving as a wrapper or preset for Jest. While it previously facilitated testing in Expo environments, its functionality has since been integrated into, or superseded by, other tools within the main Expo monorepo. For current Expo application testing, the recommended approach is to use `jest-expo` in conjunction with `@testing-library/react-native`. `jest-expo` acts as a Jest preset that handles much of the necessary configuration and mocks for the Expo SDK, enabling unit and snapshot testing across various platforms, including iOS, Android, web, and Node. Developers should migrate from `expo-test-runner` to `jest-expo` for active development and support.","status":"deprecated","version":"0.3.12","language":"javascript","source_language":"en","source_url":"https://github.com/expo/expo-test-runner","tags":["javascript","typescript"],"install":[{"cmd":"npm install expo-test-runner","lang":"bash","label":"npm"},{"cmd":"yarn add expo-test-runner","lang":"bash","label":"yarn"},{"cmd":"pnpm add expo-test-runner","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[],"quickstart":{"code":"{\n  \"name\": \"my-expo-app\",\n  \"version\": \"1.0.0\",\n  \"main\": \"index.js\",\n  \"scripts\": {\n    \"start\": \"expo start\",\n    \"android\": \"expo run:android\",\n    \"ios\": \"expo run:ios\",\n    \"web\": \"expo start --web\",\n    \"test\": \"jest --watchAll\" // Historically, expo-test-runner was often invoked via 'jest'\n  },\n  \"jest\": {\n    \"preset\": \"jest-expo\" // The modern recommendation for Expo testing\n  },\n  \"devDependencies\": {\n    \"jest\": \"^29.2.1\",\n    \"jest-expo\": \"^50.0.0\",\n    \"@testing-library/react-native\": \"^12.1.0\",\n    \"@types/jest\": \"^29.2.1\",\n    \"react-test-renderer\": \"^18.2.0\"\n  }\n}\n\n// Example test file: __tests__/App-test.tsx\nimport React from 'react';\nimport { Text, View } from 'react-native';\nimport { render } from '@testing-library/react-native';\n\nfunction App() {\n  return (\n    <View>\n      <Text testID=\"welcome-text\">Welcome to Expo!</Text>\n    </View>\n  );\n}\n\ndescribe('App component', () => {\n  it('renders welcome text correctly', () => {\n    const { getByTestId } = render(<App />);\n    expect(getByTestId('welcome-text')).toBeTruthy();\n    expect(getByTestId('welcome-text').props.children).toBe('Welcome to Expo!');\n  });\n});","lang":"typescript","description":"This quickstart demonstrates how testing was typically initiated in Expo projects, using `jest --watchAll` in `package.json` scripts. It then shows the recommended modern setup with `jest-expo` and `@testing-library/react-native` for unit testing a simple React Native component, highlighting the shift away from the deprecated `expo-test-runner`."},"warnings":[{"fix":"Migrate your testing setup to use `jest-expo` and `@testing-library/react-native` (or `react-test-renderer` for older React versions) directly within your `package.json` Jest configuration. Run `npx expo install jest-expo jest @testing-library/react-native` to ensure compatible versions.","message":"`expo-test-runner` is deprecated and its GitHub repository is archived. It is no longer actively maintained or developed. Continued use may lead to compatibility issues with newer Expo SDK versions or unaddressed bugs.","severity":"breaking","affected_versions":">=0.3.12"},{"fix":"Ensure your Jest configuration uses `jest-expo` as a preset, as it provides mocks for native Expo modules. Add `\"jest\": { \"preset\": \"jest-expo\" }` to your `package.json`. For more complex scenarios, you might need custom mocks.","message":"When running Jest tests in an Expo project, you might encounter 'The Expo SDK requires Expo to run' errors if native Expo modules are not properly mocked or the test environment isn't set up correctly. This happens because tests run in a Node.js environment, not a native Expo app.","severity":"gotcha","affected_versions":"All versions of Expo SDK with Jest testing"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Update your `jest.config.js` or `package.json` to include relevant modules in `transformIgnorePatterns`. For Expo projects, `jest-expo` preset usually handles common React Native modules, but custom ones might require additions like `\"transformIgnorePatterns\": [\"node_modules/(?!((jest-)?react-native|@react-native(-community)?)|expo(nent)?|@expo(nent)?/.*|react-navigation|@react-navigation/.*|@unimodules/.*|unimodules|sentry-expo|native-base|react-native-svg)\"]`.","cause":"This often occurs when Jest attempts to process a Node.js module (especially in `node_modules`) that uses non-standard JavaScript syntax (e.g., ES modules in a CJS environment) without proper transformation by Babel. By default, Jest ignores `node_modules` for transformation.","error":"Error: Jest encountered an unexpected token"},{"fix":"Provide a mock for the problematic module in your Jest setup file (e.g., `jest/setup.js` or `jest/setup-jest.ts`). A common pattern is `jest.mock('@react-native-async-storage/async-storage', () => ({ getItem: jest.fn(), setItem: jest.fn(), removeItem: jest.fn() }));`.","cause":"Certain native modules, like AsyncStorage or Linking, are not available in the Node.js test environment and need to be mocked.","error":"[@RNC/AsyncStorage]: NativeModule: AsyncStorage is null"},{"fix":"Verify your Babel configuration (`babel.config.js`) is correct and compatible with your Expo SDK version. Ensure all necessary presets and plugins are in place. Sometimes clearing the Metro cache (`npx expo start --clear`) or checking device logs for more detailed stack traces can help diagnose.","cause":"This error typically indicates an issue during the initialization of the React Native application's JavaScript bundle, often related to Babel configuration or a fundamental error preventing the app's entry point from registering correctly in the test environment.","error":"Module AppRegistry is not a registered callable module (calling runApplication)"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":""}