Upgrading to 0.15
0.15 raises the supported versions and changes what some suites see. Start with doctor, which checks your versions and your config:
npx vitest-native doctorSupported versions
| 0.15 needs | An older one | |
|---|---|---|
| Node | 22.22.3+ on Node 22, 24.12+ on Node 24, or 26+ | stops at startup with UNSUPPORTED_NODE |
| Vitest | 5 | stops with UNSUPPORTED_PEER |
| Vite | ^8.0.5 | stops with UNSUPPORTED_PEER |
| React | 19+ | stops with UNSUPPORTED_PEER |
| React Native (native engine) | 0.86–0.88 | below 0.86 stops with UNSUPPORTED_PEER; above 0.88 warns |
| Expo SDK | 57 and 58 | warns |
| React Native Testing Library | 13–14 | warns |
- Update Node in your machine, CI images and
.nvmrcorengines. - Install
vitest@^5with matching@vitest/*packages, andvite@^8.0.5. - Upgrade React Native to 0.86 or later (Expo SDK 57 or later) and React to 19, and move from React Native Testing Library 12 to 13 or 14. Testing Library 14 makes
render,fireEventandactasync:await render(<App />). - Vitest 5 clears mock calls before every test. A suite that asserts on calls made before the test started sets
test.clearMocks: false. - Babel plugins your tests need go through
babel()from@rolldown/plugin-babel:@vitejs/plugin-react6 removed itsbabeloption. - Remove
VITEST_NATIVE_LOADER_THREADfrom scripts and CI. It no longer has an effect.
Re-record snapshots once
Snapshots of React Native trees now print in Jest's format, as Vitest prints any React tree, and no host prints a ref. Snapshots recorded by an earlier vitest-native fail once:
npx vitest run -uReview the diff before committing it. A host ref, such as a Text ref under the native engine or any host ref under the mock engine, is now an instance with measure, focus and the other native methods, where it used to be the test renderer's node or null; update assertions on ref.current.
For one release, the old format is still available, and deprecated: expect.addSnapshotSerializer(serializer) with serializer from vitest-native/serializer, in a setup file. Snapshots has the details, including which Jest-written snapshots need a re-record.
Manual mocks of node_modules packages apply
With jestMockTransform(), a file such as __mocks__/moti.ts in a __mocks__ folder under Jest's roots (by default the Vite root) now replaces that package with no jest.mock() call, as it does under Jest. Before, the real package ran.
If a test relied on the real package, delete or rename that mock, or keep the previous behaviour with jestMockTransform({ rootMocks: false }). A package a preset covers keeps its preset, and the run says the manual mock is not applied. Manual mocks of node_modules packages has the details.
Your Babel config applies where it is needed
A file that needs a plugin from your project's Babel config (legacy decorators, macros, react-native-dotenv, the worklets plugin, custom plugins, Flow) now compiles with that config, as under Metro and babel-jest. Every other file keeps Vite's own compiler.
- Remove any
babel()entry you added only to run those plugins.doctornames the ones that are now redundant. @babel/coremust be installed in the project.migrate,doctorand the mock engine's startup say when it is not.- To keep the previous behaviour, set
projectBabel: 'never'.
Gesture Handler and FlashList run as themselves
Under the native engine, react-native-gesture-handler and @shopify/flash-list now run as their installed packages, with the Jest setup each ships, as a Jest suite runs them.
react-native-gesture-handler/Swipeableand the other modules Gesture Handler 3 does not ship no longer resolve.- A
FlashListrenders a window of rows, as under Jest, where it used to render every row. - To keep a preset, set
presets: { gestureHandler: true }orpresets: { flashList: true }.
Also new
- The hot runtime fails a stuck run instead of waiting forever, naming the file and test. Set
hangTimeoutto change or turn this off. - Several presets are now each library's own Jest mock under the native engine (worklets, safe-area-context, keyboard-controller, bottom-sheet, netinfo), and Reanimated 4.7+ is its own mock. Snapshots of the presets' own output may change.
- Reanimated's
interpolate,interpolateColorandclampreturn real values. Snapshots of interpolated styles may change. init,doctorandmigrateexit 1 on a flag they do not take, instead of ignoring it. Check scripts that pass extra flags to them.
The full list of changes is in the changelog.