Registry / testing / expo-test-runner

expo-test-runner

JSON →
library0.3.12jsnpmunverified

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-runner
INSTALL
IMPORT
SIG · EXPO-TEST-RUNNER
E
expo-test-runner
testingjavascriptv0.3.12
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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`.

{ "name": "my-expo-app", "version": "1.0.0", "main": "index.js", "scripts": { "start": "expo start", "android": "expo run:android", "ios": "expo run:ios", "web": "expo start --web", "test": "jest --watchAll" // Historically, expo-test-runner was often invoked via 'jest' }, "jest": { "preset": "jest-expo" // The modern recommendation for Expo testing }, "devDependencies": { "jest": "^29.2.1", "jest-expo": "^50.0.0", "@testing-library/react-native": "^12.1.0", "@types/jest": "^29.2.1", "react-test-renderer": "^18.2.0" } } // Example test file: __tests__/App-test.tsx import React from 'react'; import { Text, View } from 'react-native'; import { render } from '@testing-library/react-native'; function App() { return ( <View> <Text testID="welcome-text">Welcome to Expo!</Text> </View> ); } describe('App component', () => { it('renders welcome text correctly', () => { const { getByTestId } = render(<App />); expect(getByTestId('welcome-text')).toBeTruthy(); expect(getByTestId('welcome-text').props.children).toBe('Welcome to Expo!'); }); });
Debug
Known issues
breaking`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.
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.
affects: >=0.3.12
gotchaWhen 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.
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.
affects: All versions of Expo SDK with Jest testing
Errors
Common errors & fixes
Error: Jest encountered an unexpected token
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.
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)"]`.
[@RNC/AsyncStorage]: NativeModule: AsyncStorage is null
Certain native modules, like AsyncStorage or Linking, are not available in the Node.js test environment and need to be mocked.
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() }));`.
Module AppRegistry is not a registered callable module (calling runApplication)
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.
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.
Upgrade
Version history
0.3.12latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
10 hits · last 30 days
node
8
Resources
expo-test-runner — npm install expo-test-runner · libregistry