Test React Native with Vitest, against real React Native.
vitest-native is a Vitest plugin. Your tests run React Native's real JavaScript, the same code that ships in your app, and only the native modules and native host components are mocked. It works the same for bare React Native and Expo apps.
📖 Documentation: vitest-native.danfry.dev
Jest's React Native preset also runs real React Native JavaScript, but it swaps the core components
(View, Text, ScrollView, TextInput, Image, Modal) for simple stand-ins. vitest-native's
mock boundary sits lower, so your tests run React Native's real component code.
| Jest + RN preset | vitest-native | |
|---|---|---|
Core components (View, Text, …) |
Stand-ins | Real |
| Native modules and host components | Mocked | Mocked |
| Rendered host names | View, Text |
RCTView, RCTText |
A lightweight pure-JS mock engine is also available (engine: 'mock') for tests that need no React
Native at all. See the comparison with Jest and
choosing an engine.
- New React Native projects, and new tests. There is nothing to migrate.
- Teams that want real-React-Native fidelity in component, accessibility and integration tests.
- Teams already on Vitest for web or server code who want one runner.
- Teams adopting incrementally: new tests run on vitest-native while an existing Jest suite keeps running.
Migrating a large Jest suite is incremental, not turnkey.
- Behavioral cross-check. The same probes run under the mock engine and under real React Native, across every React Native version CI supports, and any difference fails the build. The badge above shows the current count; the fidelity report lists every probe.
- Packed consumers in CI. The release tarball is installed into bare React Native, Expo SDK 57 and 58 apps (with expo-router), and npm and pnpm workspace monorepos, and their tests run in CI.
- Real apps, as observations. Public apps are run in the bake-offs repository, with each app's setup in the repository. Their results are not capability claims; see the validation model.
- Performance. vitest-native is not a speed play. Each test file gets a fresh worker by default; the opt-in hot runtime reuses workers, and whether that is faster depends on your suite, so measure it.
npm install -D vitest vite vitest-native @testing-library/react-nativevitest and vite are peer dependencies, and @testing-library/react-native is optional. React
Native and Expo apps already have the Babel packages the default engine uses.
npx vitest-native init writes this config (as vitest.config.mts in a TypeScript project), or add it yourself:
// vitest.config.mts
import { defineConfig } from "vitest/config";
import { reactNative } from "vitest-native";
export default defineConfig({
plugins: [reactNative()],
});Write a test:
// Greeting.test.tsx
import { expect, test } from "vitest";
import { render, screen } from "@testing-library/react-native";
import { Text } from "react-native";
test("renders a greeting", async () => {
await render(<Text>Hello, World</Text>);
expect(screen.getByText("Hello, World")).toBeTruthy();
});Run it with npx vitest, or add "test": "vitest" to your scripts. If something looks off,
npx vitest-native doctor checks your versions, engine and presets.
npx vitest-native migrate reads your Jest config and reports what maps over; --write saves the
suggested Vitest config. Existing jest.fn, jest.mock and jest.useFakeTimers calls keep working
through the jest-compat layer. See migrating from Jest and the
Expo guide.
| Supported | |
|---|---|
| Node.js | 22.22.3+ on Node 22, 24.12+ on Node 24, or 26+ |
| Vitest | 5.x (5.1.0 or later recommended) |
| Vite | ^8.0.5 |
| React | 19 or later |
| React Native | 0.86–0.88 |
| Expo SDK | 57 and 58 |
| React Native Testing Library | 13.x or 14.x (optional) |
Use the React version your React Native release requires, and a @react-native/babel-preset
that matches its minor version. Each Node line starts at the release where Node's in-thread
module hooks work; on an older Node the plugin stops at startup with UNSUPPORTED_NODE.
- Choosing an engine and the hot runtime
- Third-party presets (Reanimated, Gesture Handler, Navigation, …)
- Expo · Plugin options · Test helpers
- Coverage · CLI · Troubleshooting
- Release notes for 0.14 · Changelog
Beta. What is covered by semver, what is experimental and what 1.0 will mean are set out in
versioning and stability.
vitest-native is the maintained successor to
vitest-community/vitest-react-native,
rebuilt for Vitest 5; see migrating from it.
bun install
bun run --filter vitest-native build
bun run --filter vitest-native testThanks to everyone who has opened an issue or a pull request, or landed a commit. Each one has shaped vitest-native.
MIT









