Skip to content

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:

bash
npx vitest-native doctor

Supported versions ​

0.15 needsAn older one
Node22.22.3+ on Node 22, 24.12+ on Node 24, or 26+stops at startup with UNSUPPORTED_NODE
Vitest5stops with UNSUPPORTED_PEER
Vite^8.0.5stops with UNSUPPORTED_PEER
React19+stops with UNSUPPORTED_PEER
React Native (native engine)0.86–0.88below 0.86 stops with UNSUPPORTED_PEER; above 0.88 warns
Expo SDK57 and 58warns
React Native Testing Library13–14warns
  1. Update Node in your machine, CI images and .nvmrc or engines.
  2. Install vitest@^5 with matching @vitest/* packages, and vite@^8.0.5.
  3. 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, fireEvent and act async: await render(<App />).
  4. Vitest 5 clears mock calls before every test. A suite that asserts on calls made before the test started sets test.clearMocks: false.
  5. Babel plugins your tests need go through babel() from @rolldown/plugin-babel: @vitejs/plugin-react 6 removed its babel option.
  6. Remove VITEST_NATIVE_LOADER_THREAD from 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:

bash
npx vitest run -u

Review 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. doctor names the ones that are now redundant.
  • @babel/core must be installed in the project. migrate, doctor and 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/Swipeable and the other modules Gesture Handler 3 does not ship no longer resolve.
  • A FlashList renders a window of rows, as under Jest, where it used to render every row.
  • To keep a preset, set presets: { gestureHandler: true } or presets: { flashList: true }.

Also new ​

  • The hot runtime fails a stuck run instead of waiting forever, naming the file and test. Set hangTimeout to 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, interpolateColor and clamp return real values. Snapshots of interpolated styles may change.
  • init, doctor and migrate exit 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.

Released under the MIT License.