I'm on Jest today
Find out what changes on your own suite before you switch anything.
- Compare · see what differs on your suite
npx vitest-native compare - Migrate · write the Vitest config
npx vitest-native migrate --write
Your components run React Native's real JavaScript, and only its native side is mocked.
npm i -D vitest vite vitest-native @testing-library/react-nativePre-1.0React Native 0.86–0.88Expo SDK 57 and 58Vitest 5Node 22.22.3+, 24.12+ or 26+
import { beforeEach, expect, it } from 'vitest'
import { fireEvent, render, screen } from '@testing-library/react-native'
import { Counter } from './Counter'
beforeEach(async () => { await render(<Counter />) })
it('is a button', () => {
expect(screen.getByRole('button')).toBeOnTheScreen()
})
it('starts at zero', () => {
expect(screen.getByText('Count: 0')).toBeOnTheScreen()
})
it('counts a press', async () => {
await fireEvent.press(screen.getByRole('button'))
expect(screen.getByText('Count: 1')).toBeOnTheScreen()
})Find out what changes on your own suite before you switch anything.
npx vitest-native comparenpx vitest-native migrate --writeSet up a bare React Native or Expo app and run your first test.
npx vitest-native initnpx vitestPick the engine by what your library does.
engine: 'native'engine: 'mock'Either way, the same tests and the same Testing Library API.
Choose an engineJest's React Native preset also runs React Native's JavaScript, but it swaps the core components for stand-ins. vitest-native mocks a layer lower, so View, Text and ScrollView run as they ship.
<View>the host it shows up as<View><RCTView><View>A second engine, engine: 'mock', runs without React Native at all, for pure-logic suites. Choosing an engine →
npx vitest-native init writes the config, or add the plugin yourself:
import { defineConfig } from 'vitest/config'
import { reactNative } from 'vitest-native'
export default defineConfig({
plugins: [reactNative()],
})import { expect, it } from 'vitest'
import { render, screen } from '@testing-library/react-native'
import { Greeting } from './Greeting'
it('renders the name', async () => {
await render(<Greeting name="Ada" />)
expect(screen.getByText('Hello, Ada!')).toBeTruthy()
})Run it with npx vitest. The plugin sets up React Native Testing Library, assets and platform files, so there is no setupFiles, Jest preset or transformIgnorePatterns to write. Quick start →
npx vitest-native compare runs your Jest and your Vitest, and lists every test that passes under Jest and not under Vitest. compare →Pinned public apps are run too, as observations rather than evidence of capability. Validation model →
compare shows how far there is to go, and both runners can run side by side. Migrating from Jest →Maintained successor to vitest-community/vitest-react-native.