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.
npm install expo-test-runnerNo compatibility data collected yet for this library.
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`.
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.
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.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)"]`.
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() }));`.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.
No dependency data recorded yet.