vitest-native 0.13.0 → 0.14.0-rc.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/CHANGELOG.md +746 -0
  2. package/README.md +205 -88
  3. package/dist/cli.cjs +1478 -145
  4. package/dist/cli.d.cts +2 -3
  5. package/dist/cli.d.mts +2 -3
  6. package/dist/cli.mjs +1475 -142
  7. package/dist/context.d.mts +40 -0
  8. package/dist/context.mjs +238 -0
  9. package/dist/errors.d.mts +19 -0
  10. package/dist/helpers.cjs +6 -9
  11. package/dist/helpers.d.cts +8 -9
  12. package/dist/helpers.d.mts +8 -9
  13. package/dist/helpers.mjs +6 -9
  14. package/dist/host-D3wzmsw8.cjs +1296 -0
  15. package/dist/host-DCPzgC3D.mjs +1180 -0
  16. package/dist/{index-CPGq6p95.d.cts → index-CPEAYjaQ.d.mts} +88 -19
  17. package/dist/{index-CmETArCM.d.mts → index-D5cOy_iY.d.cts} +89 -18
  18. package/dist/index.d.mts +4 -4
  19. package/dist/index.mjs +1366 -210
  20. package/dist/jest-compat/aliases.d.mts +5 -0
  21. package/dist/jest-compat/aliases.mjs +65 -0
  22. package/dist/jest-compat/caller.mjs +53 -0
  23. package/dist/jest-compat/error-equality.mjs +127 -0
  24. package/dist/jest-compat/interop.mjs +78 -4
  25. package/dist/jest-compat/jest-globals.mjs +5 -2
  26. package/dist/jest-compat/jest-object.mjs +348 -0
  27. package/dist/jest-compat/node-registry.mjs +489 -0
  28. package/dist/jest-compat/setup.mjs +167 -66
  29. package/dist/jest-compat.cjs +35 -5
  30. package/dist/jest-compat.d.cts +9 -5
  31. package/dist/jest-compat.d.mts +9 -5
  32. package/dist/jest-compat.mjs +35 -3
  33. package/dist/matchers.d.cts +9 -8
  34. package/dist/matchers.d.mts +9 -8
  35. package/dist/memory-BFxB285Z.mjs +137 -0
  36. package/dist/memory-bBnzadf6.cjs +155 -0
  37. package/dist/native/assets.d.mts +39 -0
  38. package/dist/native/assets.mjs +431 -0
  39. package/dist/native/babel-preset.d.mts +14 -0
  40. package/dist/native/babel-preset.mjs +56 -0
  41. package/dist/native/boundary.mjs +71 -8
  42. package/dist/native/bounded-process.mjs +165 -0
  43. package/dist/native/compile-cache.mjs +21 -9
  44. package/dist/native/expo-module-mocks.mjs +432 -0
  45. package/dist/native/expo-module-table-57.mjs +1925 -0
  46. package/dist/native/expo-module-table-58.mjs +2045 -0
  47. package/dist/native/expo-module-tables.mjs +6 -0
  48. package/dist/native/expo-native-modules.mjs +66 -0
  49. package/dist/native/export-condition-recovery-preload.mjs +5 -0
  50. package/dist/native/export-condition-recovery.mjs +195 -0
  51. package/dist/native/globals.mjs +289 -9
  52. package/dist/native/hooks.mjs +392 -114
  53. package/dist/native/loader.mjs +346 -75
  54. package/dist/native/match.d.mts +13 -0
  55. package/dist/native/match.mjs +127 -2
  56. package/dist/native/metro-profile-compiler.mjs +234 -0
  57. package/dist/native/metro-profile.mjs +115 -0
  58. package/dist/native/module-reset.mjs +172 -6
  59. package/dist/native/native-modules.d.mts +15 -0
  60. package/dist/native/native-modules.mjs +228 -0
  61. package/dist/native/nitro.mjs +60 -0
  62. package/dist/native/ownership.d.mts +105 -0
  63. package/dist/native/ownership.mjs +474 -0
  64. package/dist/native/registry-compiler.mjs +43 -0
  65. package/dist/native/registry-process.mjs +124 -0
  66. package/dist/native/registry.mjs +197 -39
  67. package/dist/native/reset.mjs +334 -135
  68. package/dist/native/resolve.d.mts +20 -3
  69. package/dist/native/resolve.mjs +103 -17
  70. package/dist/native/rntl-hooks.mjs +227 -0
  71. package/dist/native/rntl-text-host.mjs +64 -0
  72. package/dist/native/runner.mjs +33 -1
  73. package/dist/native/setup.mjs +284 -96
  74. package/dist/native/state-manifest.d.mts +22 -0
  75. package/dist/native/state-manifest.mjs +138 -0
  76. package/dist/native/transform.d.mts +2 -0
  77. package/dist/native/transform.mjs +270 -47
  78. package/dist/native/tsconfig-paths.d.mts +5 -0
  79. package/dist/native/tsconfig-paths.mjs +163 -0
  80. package/dist/native/worker.mjs +151 -40
  81. package/dist/pool-DUOe-n1k.mjs +125 -0
  82. package/dist/pool-DaTJRKJb.cjs +127 -0
  83. package/dist/preset-map-BlBriTA0.mjs +197 -0
  84. package/dist/preset-map-jSFsNy1Q.cjs +241 -0
  85. package/dist/preset-modules-Bt6k_Wdw.mjs +31 -0
  86. package/dist/preset-modules-C7gu3bPn.cjs +48 -0
  87. package/dist/preset-modules.d.mts +16 -0
  88. package/dist/preset-modules.mjs +92 -0
  89. package/dist/preset-ready.mjs +9 -0
  90. package/dist/{presets-CoNf4ByH.cjs → presets-DH7fC0YV.cjs} +1125 -102
  91. package/dist/{presets-DGProTaA.mjs → presets-DuXiUNAx.mjs} +1107 -103
  92. package/dist/presets.d.mts +2 -2
  93. package/dist/presets.mjs +1 -2
  94. package/dist/report-error.d.mts +20 -0
  95. package/dist/report-error.mjs +145 -0
  96. package/dist/rntl-matchers.d.ts +58 -12
  97. package/dist/rntl-support.d.mts +12 -0
  98. package/dist/rntl-support.mjs +189 -0
  99. package/dist/serializer.cjs +4 -2
  100. package/dist/serializer.d.cts +3 -4
  101. package/dist/serializer.d.mts +3 -4
  102. package/dist/serializer.mjs +4 -2
  103. package/dist/setup.mjs +463 -97
  104. package/dist/worker-vitest-BGPo0ek6.mjs +49 -0
  105. package/dist/worker-vitest-BfiQB8ND.cjs +62 -0
  106. package/docs/hot-default-design.md +181 -88
  107. package/docs/migrating-from-jest.md +74 -16
  108. package/docs/migrating-from-vitest-react-native.md +5 -5
  109. package/docs/release-readiness.md +55 -15
  110. package/docs/versioning.md +31 -22
  111. package/package.json +122 -98
  112. package/dist/ecosystem-CEIF_-jq.cjs +0 -659
  113. package/dist/ecosystem-Duw40-mO.mjs +0 -597
  114. package/dist/pool-BU-1ecIF.cjs +0 -122
  115. package/dist/pool-Bcxn9a3I.mjs +0 -118
  116. package/dist/preset-map-BoG19dLa.cjs +0 -35
  117. package/dist/preset-map-DuX0ocdn.mjs +0 -30
package/CHANGELOG.md CHANGED
@@ -1,5 +1,751 @@
1
1
  # vitest-native
2
2
 
3
+ ## 0.14.0
4
+
5
+ ### Upgrading from 0.13
6
+
7
+ - **Node 22.13 or later on Node 22, or Node 24.3 or later.** `engines.node` is
8
+ `>=22.13.0 <23 || >=24.3.0` (it was `>=20.19.0`): Node 20 reached end of life in April 2026, and
9
+ on Node 24.0–24.2 `jest.mock`, `jest.isolateModules` and `jest.resetModules` do not reach modules
10
+ Node loads. `vitest-native doctor` checks the range.
11
+ - **Per-file isolation stays the default.** `hotRuntime` defaults to `false`, as in 0.13.0: under
12
+ the native engine each test file runs in a fresh worker. The hot runtime, which reuses workers
13
+ across files and is faster on most suites, is available with `hotRuntime: 'auto'`. Five known
14
+ differences from per-file isolation are listed in
15
+ [troubleshooting](https://danfry1.github.io/vitest-native/guide/troubleshooting#a-test-passes-on-its-own-but-fails-when-run-with-other-files).
16
+ Release candidates 0.14.0-rc.1 to rc.8 defaulted to `'auto'`, so a project that relied on that
17
+ sets `hotRuntime: 'auto'` to keep it.
18
+ - **How to tell.** When the hot runtime is active, the startup banner names it, as in
19
+ `(platform ios, hot runtime)`. With `'auto'`, it keeps Vitest's per-file isolation whenever the run
20
+ cannot be bounded, or when you set a pool or `test.isolate` yourself, and prints the reason.
21
+ - **Hot workers leave Node's compile cache off when they re-evaluate ES modules**, so the cache no
22
+ longer grows with every test file. It costs about 15–20 ms per worker boot;
23
+ `hotRuntime: { esmGeneration: false }` keeps the cache on.
24
+ - **A project file imported and required in one test is one module.** Under the native engine, with
25
+ or without jest-compat, `vi.spyOn`, export assignments and `instanceof` reach both sides, as under
26
+ Jest.
27
+ - **Vite+ projects start.** The Vite and Vitest versions are read from the running instances, so
28
+ Vite+ no longer fails with `UNSUPPORTED_PEER`. Two physical copies of Vitest stop the run at startup
29
+ with `VITEST_TWIN_INSTANCE`, naming both.
30
+ - **RNTL works without jest-compat or globals.** `findBy*`, `waitFor` and `userEvent` advance
31
+ `vi.useFakeTimers()`, and RNTL's auto-cleanup runs without `test.globals: true`. A suite that relied
32
+ on trees staying mounted between tests imports `@testing-library/react-native/pure`.
33
+ - **Expo path aliases resolve.** In an Expo project on Vite 8, imports through tsconfig `paths` (the
34
+ template's `@/…`) now resolve as Metro resolves them; a `vite-tsconfig-paths` plugin or a hand-written
35
+ alias for them can go.
36
+ - **Vitest 5 keeps transformed modules on disk.** The plugin turns on Vitest's `fsModuleCache` unless
37
+ your config sets it, keyed so that upgrading vitest-native or any dependency invalidates it. Set
38
+ `test.fsModuleCache: false` to opt out.
39
+ - **react-native-mmkv 3 and later run as themselves.** They detect Vitest and use their own in-memory
40
+ backend, so the `mmkv` preset now applies to mmkv 2 only. Tests get mmkv's real API (v4's `remove`)
41
+ and change listeners instead of the preset's approximation.
42
+ - **jest-compat follows Jest more closely.** A name a `jest.mock` factory leaves out is `undefined`
43
+ instead of an error, `new` on a `jest.fn` with an arrow implementation works, and
44
+ `process.env.JEST_WORKER_ID` is set, so code that checks for Jest takes its test branch.
45
+ - **`hotRuntime: true` is stricter.** Combined with a configured pool, `test.isolate`, or a conflicting
46
+ CLI flag, it now fails at startup with `HOT_RUNTIME_OVERRIDDEN` instead of warning and overriding.
47
+ - **Native modules answer as on a device.** Under the native engine, `NativeModules[name]` and
48
+ `TurboModuleRegistry.get(name)` are `undefined`/`null` for a module no app registers, and a React
49
+ Native module's stub has only the methods its codegen spec declares. Register a module a test needs
50
+ with `mockNativeModule(name, impl)`; `nativeModules: 'permissive'` restores the earlier behaviour.
51
+ - **Assets are registered ids.** `require('./logo.png')` evaluates to the number React Native's asset
52
+ registry assigned, as with Metro, instead of the file name. Snapshots that contained an asset's name
53
+ change; re-record them with `-u`.
54
+ - **`jest.mock` reaches `require()`.** With jest-compat, a `jest.mock` factory now applies to
55
+ `require()`, `jest.requireActual`'s dependencies and React Native's own requires of a mocked internal;
56
+ `jest.isolateModules` and `jest.isolateModulesAsync` work. TypeScript app files that Node loads are
57
+ compiled with the project's Babel config, as babel-jest compiles them.
58
+ - **Unistyles and Skia are mocked automatically.** The new `unistyles` and `skia` presets are
59
+ auto-detected. Remove Unistyles' `react-native-unistyles/mocks` setup file, whose `jest.mock()` calls
60
+ would replace the preset (`vitest-native migrate` removes it), and a hand-written Skia mock, which the
61
+ preset replaces. Skia's preset loads CanvasKit before each test file, about 20–30 ms;
62
+ `presets: { skia: false }` turns it off.
63
+ - **Presets of your own are listed by path.** A preset object of a project's own passed to `presets`
64
+ used to shadow its packages with undefined exports; it is now refused at startup. List the module that
65
+ exports it instead: `presets: { './test/presets/my-lib.ts': true }`.
66
+ - **Expo SDK 56–58 projects run real React Native with nothing extra installed.** When
67
+ `@react-native/babel-preset` does not resolve (from SDK 56, `babel-preset-expo` no longer depends on
68
+ it), the native engine compiles with Expo's preset, as Metro does. `reactNative()` used the mock
69
+ engine there before.
70
+ - **Expo's globals are installed before your setup files, and `fetch` stays Node's.** A `fetch` mocked
71
+ in a setup file, an MSW server, nock and undici's `MockAgent` keep working whether or not a test
72
+ imports `expo`. Every test file in an Expo project now sees Expo's `URL`, `structuredClone` and
73
+ `DOMException` polyfills, as under jest-expo.
74
+ - **Expo modules' own native-module mocks are served.** Values that were `undefined` are the mock's
75
+ (`digestStringAsync` resolves `""`), and a member a mock leaves out is `undefined` where the generic
76
+ stub gave a function.
77
+ - **An optional native module that is not installed reads as absent.** `requireOptionalNativeModule`
78
+ returns `null` for a module a package only probes for and no installed package defines, as on a
79
+ device.
80
+ - **Expo modules run as their installed packages.** Under the native engine, the `expo` preset no
81
+ longer replaces `expo-constants`, `expo-status-bar`, `expo-font`, `expo-asset`, `expo-splash-screen`
82
+ and `expo-linking`, so their whole API is the installed SDK's (`hide()`, `setOptions()`,
83
+ `useAssets` …) and their values are jest-expo's: `Constants.expoConfig` is `{}`,
84
+ `Linking.createURL()` needs a scheme mocked into `expo-constants`, and `Font.isLoaded()` is `false`
85
+ until a font loads. The Minor Changes entry lists each value; `presets: { expo: true }` keeps the
86
+ preset while a suite moves off it.
87
+
88
+ ### Minor Changes
89
+
90
+ - c9de648: **With `hotRuntime` on, the memory plan is sized for the workers that actually run, and a worker count you set is limited only by memory.** No action needed. To keep the old ceiling of four, set `maxWorkers: 4`.
91
+
92
+ - Before, Vitest applied `--maxWorkers` and `VITEST_MAX_WORKERS` after the plugin had planned, so `VITEST_MAX_WORKERS=10` ran ten workers under a plan and per-worker heap threshold sized for four. The plan is now rebuilt for the count Vitest resolves, before any worker starts.
93
+ - A count set in the config, with `--maxWorkers` or with `VITEST_MAX_WORKERS` is now bounded only by what host or container memory admits; the cap of four applies only when the count is automatic. Before, a config-file `maxWorkers: 16` ran four workers on a 16 GB laptop; it now runs 16, each recycling at a 512 MiB heap. When memory does lower a count you set, `hotRuntime capped maxWorkers from N to M` is printed.
94
+ - On Vitest 5, a native project beside a plain project with no worker count set no longer fails with "Projects … have different 'maxWorkers' but same 'sequence.groupOrder'". When `hotRuntime: 'auto'` falls back for such a group, the native project gets Vitest's resolved worker count.
95
+
96
+ `hotRuntime: { allowUnboundedMemory: true }` still leaves the count to Vitest.
97
+
98
+ - 7cee4a7: **Breaking:** vitest-native supports Node 22.13 or later on Node 22, and Node 24.3 or later (`engines.node` is `>=22.13.0 <23 || >=24.3.0`; it was `>=20.19.0`). Node 20 reached end of life in April 2026. Node 22.13 is the first Node 22 that both RNTL 14 and the engine's CommonJS entry points (`require(esm)`) support. On Node 24.0–24.2, `jest.mock`, `jest.isolateModules` and `jest.resetModules` do not reach modules Node loads, with either loader. Node 23 is past its end of life. `doctor` checks the whole range. RNTL 12, 13 and 14 stay supported, and CI runs RNTL 12 and 13 on Node 22.13 instead of Node 20.
99
+
100
+ - 191c286: Under the native engine, Expo modules run as their installed packages, answering as they do under jest-expo. The `expo` preset no longer replaces `expo-constants`, `expo-status-bar`, `expo-font`, `expo-asset`, `expo-splash-screen` and `expo-linking` there; their own JavaScript runs, so their whole API is present and current with the installed SDK. `import { hide } from 'expo-splash-screen'`, Expo's call since SDK 52, was `undefined` under the preset (#319), as were `setOptions`, `useAssets`, `getLoadedFonts`, `canOpenURL` and others.
101
+
102
+ Their native modules answer as jest-expo answers them: from a package's own `mocks/`, else from Expo's table of the native modules, which jest-expo ships and vitest-native now carries for each SDK, extracted from jest-expo 57.0.6 and 58.0.12 (`src/native/expo-module-table-<sdk>.mjs`; a weekly check compares each with the newest jest-expo of its SDK, and fails when a new SDK has no table). The installed `expo`'s SDK picks the table. This also gives every other Expo module jest-expo's values: `Device.modelName` is `'mock'`, `Constants.statusBarHeight` is `54`. A constant the installed SDK's table does not list is `undefined`, as under jest-expo; on an SDK with no table of its own, the nearest SDK's table answers the members it lists and such a member keeps the stub's no-op function. On an Expo SDK 58 app, every probe of these six packages matches jest-expo (17 of 17, against 4 with the preset). One difference is deliberate: an asset a test `require`s is registered as Metro registers it, so `Asset.fromModule()` and `Font.loadAsync()` of it load, where jest-expo throws that it is missing from the asset registry.
103
+
104
+ What a suite that relied on the preset sees instead, each as under jest-expo:
105
+
106
+ - `Constants.expoConfig` is `{}` (was `{ name: 'test-app', slug: 'test-app', version: '1.0.0', extra: {} }`), so `expoConfig.name` and `expoConfig.extra` are `undefined`. `Constants.appOwnership` is `null` (was `'standalone'`), `executionEnvironment` is `'mock'` (was `'storeClient'`), and `getWebViewUserAgentAsync()` resolves `undefined`.
107
+ - `Linking.createURL()` and `Linking.parse()` throw for want of a scheme in the Expo manifest (they returned `exp://localhost:19000/…` URLs). A test that needs them mocks `expo-constants` with a scheme through `jest.mock` (the jest-compat layer), which now reaches expo-linking's own import of it, or mocks `expo-linking`; a `vi.mock` of `expo-constants` does not reach it yet (#322).
108
+ - `Font.isLoaded()` is `false` until a font is loaded (was always `true`), and `Asset.fromModule()` of a number that is not a bundled asset throws (it returned a made-up asset). Bundled images and fonts load through the real expo-asset and expo-font.
109
+ - `preventAutoHideAsync()` and `hideAsync()` resolve `undefined` (were `true`).
110
+
111
+ A suite can keep the preset while it moves off it with `reactNative({ presets: { expo: true } })`. The mock engine keeps the preset, whose `expo-splash-screen` now has `hide()` and `setOptions()`.
112
+
113
+ Three engine changes come with it. A module the ESM loader compiles is now loaded through Node's CommonJS loader, so an import and a require share one instance (expo-asset 57's asset registry was a second, empty copy) and a `jest.mock` factory reaches a package's own require of the mocked module. TypeScript under node_modules from a package nothing selected for compiling is compiled rather than refused (an Expo module installed without `expo`). `doctor` and `migrate` describe the new behaviour.
114
+
115
+ - 7b9b795: React Native 0.88 and Expo SDK 58 join the supported matrix
116
+
117
+ The verified range is now 0.81–0.88: the CI matrix gains a 0.88 row (and the Vitest 4 floor's newest-RN cell moves up to it), the workspace pins 0.88, and the published range statements follow. All 85 cross-check probes match on 0.88 and `check-compat` covers every stable export.
118
+
119
+ The packed Expo consumer moves to SDK 58 (React Native 0.88, RNTL 14), and an SDK 57 consumer stays alongside it. The SDK 58 consumer also checks that the presets provide every `expo-linking` and `expo-constants` member expo-router's build uses, and that loading `expo` and `expo-router` leaves Node's timers and `Promise` in place.
120
+
121
+ - 13f79b0: Under the native engine, an Expo module whose package ships a mock of its native module (`mocks/<Name>.ts`, generated by Expo for `expo-crypto`, `expo-file-system`, `expo-clipboard`, `expo-localization` and others) gets that mock as its native module, as under jest-expo. Its functions are `vi.fn`s that return the mock's values and reset between test files, classes keep their prototype, and members the mock leaves out are `undefined`. Before, every native module was a generic stub, so a package that read a value as it loaded failed: importing `expo-file-system/legacy` threw `p.replace is not a function`. Native modules without a package mock keep the generic stub.
122
+
123
+ - f107c6a: A `unistyles` preset for `react-native-unistyles` 3, which resolves styles in native code and could not load in tests. It is auto-detected when the package is installed. It covers everything Unistyles' own Jest mock does (themes from `StyleSheet.configure`, `StyleSheet.create`, `useUnistyles`, `withUnistyles`, `UnistylesRuntime`), and it follows the library's source where that mock does less:
124
+
125
+ - styles resolve as the device parses them: breakpoint values and `mq` keys against the screen, `_web` styles dropped;
126
+ - variants and compound variants apply by the device's rules, selected with `useVariants`;
127
+ - `StyleSheet.configure()` validates its input and picks the theme with the device runtime's messages; adaptive themes follow the colour scheme, and `setTheme`, `updateTheme` and `setAdaptiveThemes` take effect;
128
+ - `useUnistyles()`, `withUnistyles`, `Display`, `Hide` and `ScopedTheme` re-render on a theme or screen change;
129
+ - `ScopedTheme` scopes a theme to its children, and `withUnistyles` applies `uniProps`;
130
+ - `Display` and `Hide` follow `mq` against the screen size;
131
+ - `StyleSheet.flatten`, `compose`, `absoluteFill` and `hairlineWidth` are React Native's, as on a device;
132
+ - `resetAllMocks()` returns the theme to what `StyleSheet.configure()` set.
133
+
134
+ `vitest-native migrate` now deletes a library's own test setup file (such as `react-native-unistyles/mocks`) when a detected preset shadows that library, since its `jest.mock()` calls would replace the preset.
135
+
136
+ - 12a6dc5: A `skia` preset for Skia, which threw at import in tests ("Native Skia Module failed to correctly install JSI Bindings"). It covers both of Skia's package names, `react-native-skia` (2.15.0 and 3.x) and `@shopify/react-native-skia` (up to 2.14.0), shadows whichever is installed, and works under both engines.
137
+
138
+ - It loads CanvasKit, Skia compiled to WebAssembly, and serves Skia's own test mock over it, so the `Skia` API computes with real Skia, and `Canvas` and its drawing render as Views.
139
+ - Its named exports are read from the installed version's ESM build, since Skia's API changes between releases.
140
+ - It adds Skia's Reanimated helpers (`usePathValue`, `useTexture`, …), which the mock leaves out, and makes `matchFont` return a font.
141
+
142
+ The `Preset` type gains an optional async `prepare()`, which completes before any of the user's setup files or test files load, and `PresetModule` an optional `exportsFor()`, which reads the module's named exports from the installed package (or returns `null` when it is not installed, leaving it unshadowed). The skia preset uses both.
143
+
144
+ The project root given to test workers now follows `test.root` (or `--root`), as Vitest's does; a run started from a parent directory resolved packages from that directory in every worker.
145
+
146
+ - 51c351d: Presets of a project's own now work. A preset object passed to `presets: [...]` shadowed its packages with modules whose every export was undefined, under both engines: each test worker rebuilds the presets by name from vitest-native's own, and a preset's factories, being functions, cannot reach a worker from the config. A preset is now listed by the path of a module that default-exports it (or a function returning it): `presets: { './test/presets/my-lib.ts': true }` beside auto-detection, or `presets: ['./test/presets/my-lib.ts']` in a full list. The plugin reads its name and export names while loading the config, and each worker imports it, through Vitest so a TypeScript module loads. A preset object that is not exactly what one of vitest-native's factories returned, such as a built-in preset copied or extended, is refused at configuration time, naming the module form.
147
+
148
+ - 6724815: Native engine: native module lookups answer the way a device does
149
+
150
+ `NativeModules[name]` and `TurboModuleRegistry.get(name)` returned a stub for every name, so a module that no app registers looked present. Library feature detection then took the wrong branch: expo-constants checks `NativeModules.EXDevLauncher` and, finding it, threw at import while parsing the stub's `manifestString` as JSON.
151
+
152
+ React Native returns `undefined` from `NativeModules[name]` and `null` from `TurboModuleRegistry.get(name)` for an unregistered module, and Jest's React Native preset does the same. The native engine now does too:
153
+
154
+ - React Native's own native modules stay present for every lookup. The set is read from the installed `react-native`: every name its JavaScript passes to `TurboModuleRegistry.get` or `getEnforcing`, so it follows the project's React Native version.
155
+ - A React Native module's stub has only the members of its codegen spec, read from the same installed copy. Any other property is `undefined`, as on a device. A stub that answered every name with a function broke code that probes objects for optional properties: Node's `EventEmitter` read `captureRejections` from `NativeKeyboardObserver` when a test mocked `NativeEventEmitter` with it.
156
+ - `TurboModuleRegistry.getEnforcing(name)` still returns a stub for any name, where React Native would throw, so code that requires a native module keeps running without setup.
157
+ - A module registered with `mockNativeModule()` is present for all three lookups. Under the hot runtime, a registration a test file leaves behind is removed before the next file runs.
158
+
159
+ `nativeModules: 'permissive'` restores the earlier behaviour (every name present, every member a method) for a suite that depends on it.
160
+
161
+ If a test relied on an unregistered module being present through `NativeModules` or `TurboModuleRegistry.get`, or on a method a React Native module's spec does not declare, register it with `mockNativeModule(name, impl)` from `vitest-native/helpers`, in the test or a setup file.
162
+
163
+ - 3d20592: jest-compat: one module registry per test file, as in Jest. A `jest.mock(spec, factory)` (and `jest.doMock`, `jest.setMock`) now applies to `require()` from a test, to the modules `jest.requireActual` loads, and to React Native's own requires of a mocked internal such as `react-native/Libraries/AppState/AppState`, with the same mock instance the file's imports see. `jest.requireActual` unmocks only the module requested, `jest.requireMock` returns the registered mock instead of the real module, and `jest.resetModules()` gives `require()` fresh project modules and re-runs mock factories while React Native stays loaded. `jest.isolateModules` and `jest.isolateModulesAsync`, which previously threw, are implemented with Jest's semantics. A project module the test has imported is the instance `require()` returns. Registrations last for one test file, including in a reused worker. Factory-less mocks (automock and `__mocks__`) still apply to imports only.
164
+
165
+ TypeScript project files that Node loads are now compiled as babel-jest compiles them, with the options `@babel/core` loads for each file (any config format, `overrides`, and env- or caller-dependent configs). In a project with Expo, Babel sees jest-expo's Metro caller for the configured platform. The transform cache is keyed on those options, and a file the config ignores fails with "Babel ignores …", as under babel-jest. Relative requires from any file Node loads resolve as Metro resolves them: in its platform-extension order, with a trailing `/` naming the directory, and through a directory's `package.json` `react-native`, `browser` or `main` field. `jest.isolateModules` nesting throws Jest's exact error. Without `jestCompatSetup`, a `jest.mock` factory now fails with an error naming it (`JEST_COMPAT_SETUP_MISSING`).
166
+
167
+ - 12d413a: Asset imports and requires evaluate to what Metro gives an app: a registered asset id
168
+
169
+ `require('./logo.png')`, `import font from './Icon.ttf'` and every other asset now evaluate to a
170
+ number — the id React Native's asset registry assigned to the asset — instead of the file's name.
171
+ The module is the one Metro generates (`module.exports = require(assetRegistryPath).registerAsset({…})`),
172
+ with the descriptor Metro's `getAssetData` produces: `name`, `type`, `scales`, `hash`,
173
+ `httpServerLocation` and, for images, `width` and `height` in points. React Native code that consumes
174
+ assets therefore behaves as on device. `Image.resolveAssetSource(require('./splash.png'))` used to
175
+ return `null`, because a file name is not a registered id, so code such as
176
+ `Image.resolveAssetSource(source)!.uri` threw.
177
+
178
+ - **Native engine.** Assets register with React Native's own registry — the module Metro's
179
+ `assetRegistryPath` names (`react-native/asset-registry` on 0.87 and later,
180
+ `react-native/Libraries/Image/AssetRegistry` before) — on every load path: Vite-graph imports,
181
+ requires and imports through Node, and React Native's own image assets. `resolveAssetSource`,
182
+ `<Image source={require(…)}>` and `AssetRegistry.getAssetByID` resolve them.
183
+ - **Mock engine.** Assets register with the mock `AssetRegistry`, and the mock
184
+ `Image.resolveAssetSource` resolves a registered id as React Native does (the same URI the native
185
+ engine produces, on iOS and Android). The mock `AssetRegistry` now keeps its entries across
186
+ `resetAllMocks()`: React Native's registry has no reset, and an asset module's id must stay valid
187
+ for every test in the file.
188
+ - **Expo.** In a project `expo` resolves from, assets carry what Expo's bundler adds: `fileHashes`
189
+ and the Expo CLI dev server's asset location. expo-asset then resolves them through Expo, as in an
190
+ Expo app. The descriptor is checked against `getUniversalAssetData` from the installed Expo.
191
+ - **Scales and platforms.** `@2x`/`@3x` variants group as in Metro: `scales` lists them, the
192
+ dimensions are the smallest variant's divided by its scale, and resolution picks the variant for
193
+ the device's pixel ratio. A `.ios`/`.android` variant is preferred for the configured platform.
194
+ - **Dimensions** are read from PNG, JPEG, GIF, BMP and WebP headers, with no new dependency. SVG,
195
+ TIFF, PSD and KTX images, which Metro also measures, and files that are not valid images register
196
+ without `width` and `height`; Metro would fail the build on the latter.
197
+
198
+ ### Upgrading
199
+
200
+ Snapshots that contained an asset's file name now contain its registered id (a number), and under
201
+ the native engine a rendered `<Image source={require('./logo.png')} />` snapshots the resolved
202
+ source (`uri`, `width`, `height`, `scale`). Ids are assigned in registration order within a test
203
+ file, so they are stable for a given file. Update affected snapshots with `vitest -u`. Assertions
204
+ that compared an asset to its file name can compare `Image.resolveAssetSource(asset).uri` instead.
205
+
206
+ - 52e80aa: Turn on Vitest 5's persistent transform cache, with a complete cache key
207
+
208
+ On Vitest 5 the plugin turns on Vitest's persistent transform cache (`fsModuleCache`) unless the
209
+ config sets it, and contributes its own part of the cache key through Vitest's cache key
210
+ generator: the vitest-native version, the plugin's resolved options, and a digest of the project's
211
+ lockfile. Vitest's own key does not cover plugin versions or what a plugin reads from disk, so
212
+ without this an upgrade could serve modules transformed by the previous version. Warm runs of a
213
+ 104-file production Expo suite were about 11% faster. Set `test.fsModuleCache: false` to opt out.
214
+
215
+ - 87d8dd0: Use the hot runtime for suites migrated from Jest under `hotRuntime: 'auto'`
216
+
217
+ `'auto'`, the default, no longer keeps per-file isolation for suites set up with
218
+ `jestMockTransform()` or the jest-compat setup. The jest-compat surface — `jest.mock` in
219
+ its hoisted, partial, factory-less and runtime forms, spies on React Native APIs, `console`
220
+ and package exports, fake timers and `jest.setSystemTime`, `jest.setTimeout`, globals,
221
+ `process.env`, snapshot state, React Native Testing Library cleanup, and a project setup
222
+ file's top-level mocks, matchers and globals — now has its own cross-file isolation gate
223
+ under the hot runtime. `hotRuntime: false` keeps
224
+ per-file isolation for a suite that needs it.
225
+
226
+ - d0d968a: Use the hot runtime by default where it can be bounded
227
+
228
+ `hotRuntime` now defaults to `'auto'` under the native engine. A run reuses workers and resets
229
+ React Native's registry, the app/test module graph and the verified process state per file
230
+ whenever the scheduler provides recyclable boundaries (at least two workers within the memory
231
+ plan), no other pool is configured, and the worker and the project resolve the same Vitest
232
+ version; otherwise it keeps Vitest's per-file isolation, as before. Suites set up for Jest
233
+ migration are included (see the separate entry on admitting them).
234
+
235
+ When hot is selected, concurrency follows the hot memory plan, which caps automatic workers at
236
+ four. Set implicitly, `'auto'` is quiet about both its fallbacks and that cap;
237
+ `diagnostics: true`, or setting `hotRuntime: 'auto'` explicitly, reports them.
238
+ `hotRuntime: false` restores per-file isolation unconditionally, and `hotRuntime: true` still
239
+ requires hot mode and fails closed when it cannot be bounded — including on a Vitest version
240
+ mismatch, which `'auto'` treats as a reason to fall back.
241
+
242
+ - 2581950: Add an experimental `metroConfig` option that reads the project's Metro resolution profile
243
+
244
+ `reactNative({ metroConfig: true })` evaluates the project's Metro config (or Expo's defaults)
245
+ in a short-lived, memory-bounded child process and applies its declarative resolution profile:
246
+ source extensions and their order, and asset extensions. Main fields and conditions are
247
+ reported under `diagnostics`. `metroConfig: { configFile }` points at a config outside the
248
+ project root. A custom `resolver.resolveRequest` is code and does not run under Vitest; the
249
+ extensions still apply and one warning names the gap. Default: `false`.
250
+
251
+ ### Patch Changes
252
+
253
+ - 0ffc361: **A copied checkout no longer fails with "more than one copy of React" under the native engine.** A project copied together with `node_modules/.cache/vitest-native` reused the original's precompiled React Native registry, which loads React Native from the original checkout. Every test failed until the cache was deleted. No action needed: the copy now builds its own registry on its first run.
254
+
255
+ The same fix covers a project whose `react-native` starts resolving to a different installed copy, for example a workspace package that gains its own. A symlinked path to the same project keeps its cache.
256
+
257
+ - 7596cea: **`vitest-native init` and `vitest-native migrate` say how to turn on the hot runtime.** No action needed. Both commands now end with a short note: the hot runtime is off by default (`hotRuntime: false`), `hotRuntime: 'auto'` reuses workers between test files and can make large native-engine suites faster, and it has known differences from per-file isolation, linked to the troubleshooting guide. The generated config is unchanged.
258
+
259
+ - 8319b1f: **React Native Testing Library's automatic cleanup runs without `test.globals: true`** (RNTL 12–14, both engines, the hot runtime and `isolate: false`). No action needed. If a suite relied on trees staying mounted between tests, import `@testing-library/react-native/pure` or set `RNTL_SKIP_AUTO_CLEANUP`.
260
+
261
+ RNTL registers its cleanup `afterEach` only when `afterEach` is a global, so with Vitest's default every rendered tree stayed mounted for the rest of the file and later tests saw earlier screens. The setup file now registers the same cleanup through Vitest's `afterEach`, for files that load RNTL's main entry directly or through a package that re-exports it, such as a shared test-utils. It calls RNTL 13's `cleanupAsync`, and 12's and 14's `cleanup`, as each version's own hook does. `/pure` and `RNTL_SKIP_AUTO_CLEANUP` still opt out, also in a worker where an earlier file loaded RNTL.
262
+
263
+ With `isolate: false`, Vitest keeps fake timers from one file to the next, so a setup file that calls `vi.useFakeTimers()`, or a file that ends with fake timers on, no longer makes every later file's cleanup time out: the cleanup waits on `node:timers`' `setImmediate`, which fake timers do not replace.
264
+
265
+ Under the mock engine with `test.globals: true`, a file that imports `@testing-library/react-native/pure` is no longer cleaned up automatically, as RNTL documents: the mock engine's setup used to load RNTL's main entry itself, which registered RNTL's cleanup for every file.
266
+
267
+ The cleanup runs after the file's own `afterEach` hooks, as RNTL's does under Vitest with globals on; Jest runs it first.
268
+
269
+ - b5f40d5: **Under the native engine's hot runtime, Node's compile cache no longer grows with every test file.** No action needed. ESM generation is on by default under the hot runtime: each test file re-evaluates the externalized ES modules it imports under a new URL, and Node's on-disk V8 compile cache, keyed by URL, gained an entry per module per file. In a measured case, a suite importing a 301-module ES package, a cold run wrote about 18,500 entries (147 MB). Workers wrote them when they exited, inside Vitest's `teardownTimeout`, which could end in `Timeout terminating`.
270
+
271
+ Hot workers with ESM generation now leave the compile cache off. That costs about 15–20 ms per hot worker boot, including each recycle (measured in one fixture: 451 → 471 ms median with 1 worker, and 614 → 658 ms for 4 workers and 8 files), in exchange for no cache growth and no teardown timeouts from it. Per-file isolation, and the hot runtime with `hotRuntime: { esmGeneration: false }`, keep the cache on.
272
+
273
+ Not covered: with `NODE_COMPILE_CACHE` set, Node enables the cache in every worker before vitest-native runs, and hot ESM-generation workers still write per-generation entries. Unset it for hot runs, or set `esmGeneration: false`. To reclaim space already used, delete `node_modules/.cache/vitest-native/v8`.
274
+
275
+ - 838b1a8: **Under the native engine with RNTL 12 or 13, `getByText` finds a nested `<Text>` by its own text**, as it already did with RNTL 14. No action needed. The mock engine is unaffected.
276
+
277
+ Real React Native renders a nested `<Text>` as the host `RCTVirtualText`, which RNTL 12 and 13 do not treat as text, so `getByText` matched only the outer text. The native setup now extends their `isHostText` check with it, as it already extended RNTL 14's list of text hosts.
278
+
279
+ Not covered: role queries on RNTL 12. A nested `<Text accessibilityRole="link">` is still not found by `getByRole("link")` there; RNTL 13 and 14 find it.
280
+
281
+ - 838b1a8: **The react-native-screens preset renders a native-stack screen's header**, so `headerLeft`, `headerRight` and a custom title can be queried. Both engines. No action needed, but a test asserting that a hidden header's buttons are absent must now expect them.
282
+
283
+ native-stack hands those elements to `ScreenStackItem` as `headerConfig.children`, and the preset's `ScreenStackItem` rendered only the screen's content, so back buttons and header actions were missing (for example with `presets: { navigation: false }`, where the real native-stack runs). It now renders `ScreenStackHeaderConfig` with `headerConfig` after the content, as react-native-screens does, and no longer passes `headerConfig` as a host prop. As in react-native-screens, the header config and its children are rendered even with `headerShown: false`.
284
+
285
+ - cd55d7b: **RNTL's `findBy*` and `waitFor` advance `vi.useFakeTimers()` without jest-compat.** Under the native engine, stock and hot runtime, RNTL 12, 13 and 14 now advance Vitest's fake clock, where they used to wait in real time until they timed out. `userEvent` delays advance it too. No action needed. If you were calling `vi.advanceTimersByTime` before a query as a workaround, you can drop it.
286
+
287
+ **A setup file that calls `vi.useFakeTimers()` no longer hangs RNTL.** RNTL loaded while fake timers were on captured the fake `setImmediate`, so its auto-cleanup after each test never finished. It now captures the real one, as under Jest.
288
+
289
+ RNTL's own files get a `jest` with five timer calls backed by `vi`, and `globalThis.jest` is still not defined. Tests that do not use fake timers keep RNTL's real-timer path. With fake timers, RNTL behaves as it does under Jest:
290
+
291
+ - A `setTimeout` replaced by a mock function (`vi.spyOn(globalThis, "setTimeout")`) counts as fake timers, so `waitFor`'s timeout runs in fake time.
292
+ - Loading RNTL while fake timers are on reinstalls them with the project's `fakeTimers` config, dropping per-call options, the system time and pending timers. Under the hot runtime this happens only in the first file that loads RNTL (see Troubleshooting).
293
+
294
+ The mock engine is unchanged.
295
+
296
+ - f312a7e: **The startup banner names the presets a run applies**, for example `[vitest-native] engine: native — real react-native@0.81.5 · mocked: navigation, safeAreaContext, screens (platform ios)`. No action needed.
297
+
298
+ Each preset replaces its whole library, and before, nothing in the output said one was active: an app that rendered its real navigator under the navigation preset got a `NavigationContainer` that never calls `onReady` and a `navigate` that does nothing. Under the native engine the names are the list the workers build their mocks from; the project's own preset modules (`presets: ['./my-preset.ts']`) are named as the config writes them. In a multi-project run the banner prints once, for the first project. The presets guide now says what the navigation preset replaces and how to turn it off: `presets: { navigation: false }`, plus `screens: false` for a native-stack navigator's header.
299
+
300
+ - f312a7e: **Under an isolated install (pnpm, or bun's isolated linker), the native engine compiles the transitive dependencies of React Native packages.** No action needed. Hoisted layouts are unaffected.
301
+
302
+ Before, each dependency was looked up from the project root, where an isolated install links only the project's direct dependencies, so none was found. With `presets: { navigation: false }`, the uncompiled `@react-navigation/elements` then failed at import with "The requested module '@react-navigation/native' does not provide an export named 'useTheme'". Each dependency is now resolved from the package that declares it, as Node resolves it. The build toolchain (Metro, `@babel/runtime`, `babel-preset-expo`, `@expo/metro`) is found where React Native and Expo install it, so its dependencies stay out of the transform.
303
+
304
+ - d425b0e: **Under `vitest-native/jest-compat`, two errors that differ only in per-instance methods are equal, so identical zod 3 `ZodError`s match.** No action needed.
305
+
306
+ zod 3's `ZodError` assigns `addIssue` and `addIssues` as arrow functions in its constructor, and Vitest compares an error's own properties, so `toEqual`, `rejects.toEqual` and `toThrow(error)` failed with "Compared values have no visual difference" where Jest passes. Now an own property that is a function on both errors is ignored. Everything else is compared as before: name, message, `cause`, `AggregateError`'s `errors`, other own properties, and `toStrictEqual`'s type check. So `toStrictEqual` between a `TypeError` and an `Error`, or `toThrow` with a different `cause`, still fails.
307
+
308
+ The jest-compat `expect` is shared, so Vitest-style assertions in the same project get the same comparison.
309
+
310
+ - 5fc9188: **Under the native engine, `process.env.EXPO_OS` is the test platform (`ios` or `android`) in a project that resolves `expo`.** No action needed. A value already set in the environment or `test.env` is kept, and `vi.stubEnv("EXPO_OS", …)` overrides it per test.
311
+
312
+ babel-preset-expo inlines `EXPO_OS` as it compiles, but the engine compiles `node_modules` with React Native's Babel preset, so Expo's packages read the variable at runtime and found it unset: expo-modules-core warned that it "should be inlined by babel-preset-expo", its `Platform.select` returned `undefined`, and expo-router took its non-iOS branches on iOS. The hot runtime keeps the value between test files. The mock engine does not set it.
313
+
314
+ - 5fc9188: **With RNTL 12 or 13 (React 19's `react-test-renderer`), a recoverable React error is logged instead of failing the run.** Both engines. No action needed.
315
+
316
+ Before, when a component threw once during a concurrent render and React rendered it again successfully, Node reported the error as an uncaught exception, so Vitest exited 1 with an unhandled error while every test passed. React's recoverable errors are now logged with `console.error`, as React 18.3's test renderer and RNTL 14's renderer log them (a device logs them as a warning). Any other error the renderer reports, such as an uncaught render error outside `act()`, still fails the run.
317
+
318
+ `globalThis.reportError` is defined only while the renderer loads and removed after, so other code that feature-detects it behaves as before. The handler is recognised by React's function name; a React release that renames it would bring the failure back, and a test pinned to the installed renderer catches that.
319
+
320
+ On Node 26, an uncaught render error is now reported as that error. React's own fallback checks only for a global `ErrorEvent`, which Node 26 adds, and then calls `window.dispatchEvent`, which React Native's `window` (the global object) does not have, so the error surfaced as `TypeError: window.dispatchEvent is not a function`.
321
+
322
+ - 1111062: **Under `vitest-native/jest-compat`, `jest.useFakeTimers(options)` honours Jest's options.** No action needed. If a suite depended on a date set with `setSystemTime` carrying into the next test, pass `now` to `jest.useFakeTimers()`.
323
+
324
+ Before, the options went to `vi.useFakeTimers`, which ignores Jest-only keys, so `{ advanceTimers: true }` never advanced and `doNotFake` faked the named APIs anyway. They are now translated as Jest 30 translates them: `advanceTimers` (`true` or a step in ms), `doNotFake`, `now`, and `timerLimit` (Jest's default of 100,000). As in Jest, each call starts the clock at the real time unless given `now`. `legacyFakeTimers: true` fakes only the timer functions, leaves `Date` real, and warns once that assertions on the timer functions are not supported. `jest.useFakeTimers()` and `jest.useRealTimers()` return `jest`, so calls chain. `process.nextTick` and `queueMicrotask` stay real, as under `vi.useFakeTimers`.
325
+
326
+ Options given at the top level of a setup file are lost once React Native Testing Library loads; call `jest.useFakeTimers()` in a `beforeEach`, or use Vitest's `test.fakeTimers`. The migration guide now explains why Jest's `.snap` files cannot be shared with Vitest and how to keep each runner's snapshots apart with `resolveSnapshotPath`.
327
+
328
+ - 3e6428a: **On Vitest 4 with `hotRuntime` on, a test file no longer receives an earlier file's `vi.mock` factory.** No action needed.
329
+
330
+ Before, when one file mocked a module with a factory and a later file in the same worker mocked it any other way (an automock with `vi.mock(path)`), the later file got the earlier factory's result, and calls such as `mockReturnValue` failed with `is not a function`. Each file now fetches such a module again under its own mocks. The same holds inside one file: a factoryless `vi.doMock` after `jest.resetModules()`, or inside `jest.isolateModules`, now gets an automock. Vitest 5 and the default per-file isolation were not affected.
331
+
332
+ - a5592d2: **Under the native engine, an ES-module project file that a test imports and a project module `require`s is now one module, with or without jest-compat.** Before, Node's `require` got Vite's instance only when jest-compat or a library's Jest setup file was in use, and otherwise loaded a second copy, so state the test set was not the state the required module read.
333
+
334
+ No action needed. A suite that relied on getting a fresh module after deleting a `require.cache` entry for a file the test imported now gets the imported one, as under Jest.
335
+
336
+ For projects without jest-compat, as in Jest:
337
+
338
+ - `vi.spyOn` on a required module, and an assignment to one of its exports, now reach the files that `import` it (before: only the required copy changed).
339
+ - `instanceof` now holds for a class the test imported and a required module checks (before: `false`).
340
+ - With a partial `vi.mock(path, async (importOriginal) => ({ ...(await importOriginal()), … }))`, Node's `require(path)` now gets the real module Vite evaluated and shares its state (before: a separate copy).
341
+
342
+ Not covered yet: a project file that is required before it is imported is still loaded twice, and so is a CommonJS (`.cjs`) project file Vite evaluated.
343
+
344
+ - 95a6466: **On Node 26, a library loaded again in each test file is no longer resolved again each time.** No action needed. Node 26 passes a plain `require` the options `{ paths: undefined, conditions }`. The resolution memo treated the unset `paths` as a `require.resolve` with `paths` and left every such request to Node, so it saved nothing on Node 26. An unset option is now ignored; a `require.resolve` with `paths` set is still left to Node.
345
+
346
+ - 36e7de0: **Vite+ projects start, and two copies of Vitest fail by name.** vitest-native now reads the Vite and Vitest versions from the instances that are running, not from the `vite` and `vitest` packages found from the project root. No action needed for an ordinary install.
347
+
348
+ - Under Vite+, whose `vite` package reports Vite+'s own version, runs no longer stop with `UNSUPPORTED_PEER` ("requires vite >= 6.4.2 … found 1.3.0"). A pnpm project that gets `vitest` only through Vite+ no longer fails with "vitest … was not found". `doctor` reports the Vite actually in use. The JSX transform and Expo's tsconfig `paths` support follow the running Vite.
349
+ - When vitest-native would load a different physical copy of Vitest from the one running, the run stops at startup with `VITEST_TWIN_INSTANCE`, naming both paths, instead of every test file failing. Two copies of the same version in an ordinary install are not an error, because Vitest's resolver maps them to the running copy. To fix it, install one Vitest that both resolve: remove the project's own `vitest` when Vite+ provides it, or deduplicate the install. When the error comes from the hot runtime's worker, `hotRuntime: false` also works.
350
+ - `vitest-native init` with vite-plus installed writes `vite.config.ts` using `defineConfig` from `'vite-plus'` and points to `vp test`. When a Vite+ config already exists, it shows the lines to add instead of offering `--force`. `migrate` suggests the same shape.
351
+ - Vitest 2 and 3 still fail at startup with `UNSUPPORTED_PEER`.
352
+
353
+ Not covered yet: under the hot runtime, a project with two physical copies of Vitest is refused rather than bound to the running copy.
354
+
355
+ - 432b86c: Workers now read their configuration from one validated project context file instead of about twenty `VITEST_NATIVE_*` environment variables, and fail by name (`CONTEXT_INVALID`) when it is missing, stale or malformed, where a bad value used to become a default silently. The file is rewritten if the cache is cleared during a watch session, and falls back to the system temp directory when the cache cannot be written. Those variables were never documented: one given in the shell or in `test.env` no longer reaches the workers, and the plugin warns once, naming each one still set. Test results are unchanged.
356
+
357
+ - 1e7ae98: A library graph that a worker loads again in each test file, such as a library run as itself or a library's own Jest mock, no longer has its imports re-resolved and its sources re-read every time. Node does not cache a resolution that goes through a package's `exports` map, so each bare import ran Node's full resolution again, and each compiled source was read again just to find its cached output. Resolutions of bare and extensionless relative requests are now kept per requiring directory for the life of the worker. A kept resolution of a bare request whose file has since been removed is resolved again, so removing a nested copy falls back to the outer one, as with Node. A copy installed nearer than the kept one during a run is not seen until the worker restarts. Node behaves the same way for packages resolved through `main`, and watch mode does not watch `node_modules`. A source whose compiled output is already held for its current size and modification time is no longer read, so a file edited between test files is still recompiled.
358
+
359
+ - 1785957: `hotRuntime` stays `false` by default, as in 0.13.0: under the native engine each test file runs in a fresh worker. The hot runtime, which reuses workers across files and is faster on most suites, is available with `hotRuntime: 'auto'`; four known differences from per-file isolation are listed in the troubleshooting guide. Release candidates 0.14.0-rc.1 to rc.8 defaulted to `'auto'`, so a project that relied on that sets `hotRuntime: 'auto'` to keep it.
360
+
361
+ - ff23fde: The hot runtime no longer drops test files from a run. When a test file `jest.mock`ed a module that the per-file reset restores through Node, such as `jest.mock('react-native/Libraries/Utilities/Appearance', () => null)`, the reset for the next file threw before that file was collected. The file then had no result in any reporter, and the JSON report did not show it at all. With one worker, every later file of the run was lost the same way. On react-native-paper this dropped one file per run with four workers and 19 of 52 files with one. The `jest.mock` registrations are now cleared before the React Native state is restored. A reset that fails now fails the file it was for, with the error. A file that never runs because its worker's task broke is now reported as failed by name, and the run fails.
362
+
363
+ - cbade8c: The native engine runs its ESM loader in-thread (`module.registerHooks`) only on Node 22.22.3 and later on Node 22, 24.12 and later on Node 24, and Node 26 on; other Node versions use the threaded loader (`module.register`), as Node 22.13 always has. On the earlier releases that have `registerHooks`, the in-thread hooks broke the engine: expo-router failed to load its navigation elements ("request for 'node:module' is from a module not been linked") through Node 22.22.2 and 24.11, and the hot runtime's module reset did not behave as on other versions. `VITEST_NATIVE_LOADER_THREAD=1` still forces the threaded loader anywhere.
364
+
365
+ - 0c45e87: The native engine no longer reads every `require()` as an `import` on Node 22.15–22.18 and early Node 24 releases (24.3 and 24.4 measured), which 0.14.0's supported range now leaves out. Its in-thread loader hooks tell a `require()` from an `import` by the conditions Node passes them, and on those versions a `require()` reports its conditions as an empty object instead of a list. Every `require()` was read as an `import` and reached the engine's loader, which compiled Babel's own files as Babel loaded them, so every test failed with "Reentrant preset detected". Node 22.19 and 24.6 onwards list them and were unaffected, and so was Node 22.13, which uses the threaded loader.
366
+
367
+ - ce3be7a: Under the native engine, a test that imports `expo` or `expo-router` from Expo SDK 58 (React Native 0.88) no longer hangs. Expo's runtime requires `react-native/setup-env`, which replaced Node's timers with React Native's native-driven ones, so the first awaited timer never fired. That entry is now skipped, as `InitializeCore` already was. The `expo-linking` preset also adds `getLinkingURL`, `openURL` and `unwrapDevLaunchURL`, which expo-router 58 calls while rendering a route tree.
368
+
369
+ - 2ede5df: In an Expo project, the native engine installs Expo's runtime globals (`URL`, `structuredClone`, `DOMException` and the rest) before the project's setup files run, in every test file, as jest-expo does, instead of at a test's first `expo` import. A file that never imports Expo now sees Expo's polyfills for those globals, as under jest-expo. A `fetch` mocked in a setup file is no longer replaced once a test imports Expo. Global `fetch` stays Node's, so MSW, nock and undici's `MockAgent` keep intercepting, where Expo's native-driven `fetch` failed with `request.start is not a function`. Node's `FormData` also keeps working after Expo loads: Expo's patch for React Native's FormData made `append()` and `set()` throw.
370
+
371
+ - 2ac4de3: The native engine runs in an Expo project without `@react-native/babel-preset`. From SDK 56, `babel-preset-expo` carries React Native's Babel plugins itself and no longer depends on that preset, so a project created from the SDK 56, 57 or 58 template has none installed, and `reactNative()` fell back to the mock engine, where Expo modules failed to load. When `@react-native/babel-preset` does not resolve, the engine now compiles with Expo's preset (`expo/internal/babel-preset`), which Expo's Metro and jest-expo use in a project without a Babel config. A project that has `@react-native/babel-preset` keeps using it.
372
+
373
+ - 306b27a: Under the native engine, `expo-image` can be imported. `globalThis.expo.modules` answered every native module name, so a package probing for an optional module with `requireOptionalNativeModule` called into a stub instead of taking its fallback: expo-image found expo-observe's `ExpoObserve` and failed with `Cannot read properties of undefined (reading 'expo-image')`. A module that an installed package only probes for, and that no installed or local Expo module defines in its native sources, now reads as absent, as on a device. Every other module stays present, so a module that exists cannot read as missing. The scan is cached until the install changes.
374
+
375
+ - 61ae436: Preset mocks keep their behaviour through `vi.resetAllMocks()` and `mockReset: true`. A gesture-handler gesture built before a reset, such as `Gesture.Pan()` at module scope, keeps chaining. In the mock engine, `Platform.select()` follows `Platform.OS` after a reset, so a setup file's `setPlatform('android')` is no longer undone for `select()` while `Platform.OS` stays `"android"`. `Platform.select()` also picks by key presence, as React Native does, so an explicit `ios: undefined` selects `undefined`.
376
+
377
+ - de438fc: The reanimated preset's animation builders keep chaining after `vi.resetAllMocks()` or `mockReset: true`, so `LinearTransition.springify().damping(20)` and `SharedTransition.duration(300).custom(...)` no longer throw.
378
+
379
+ - df06716: Under the native engine, an imported BMP image's `width` and `height` are read as Metro 0.87.1 reads them. An OS/2 bitmap (12-byte header) now has its real dimensions instead of a misread width, and a file whose header size is not a bitmap's registers without dimensions, as other unreadable images do.
380
+
381
+ - dc2543b: `migrate` writes Jest's mock-clearing behaviour correctly:
382
+
383
+ - Jest's `resetMocks` becomes `test.mockReset`, Vitest's name for it. It was written as `test.resetMocks`, which Vitest ignores.
384
+ - When the Jest config does not set `clearMocks`, the generated config sets `clearMocks: false`, Jest's default. Vitest 5 defaults it to `true`, which clears calls mocks received while modules loaded before each test.
385
+
386
+ - b10cce3: `migrate` no longer says the test script's flags were "mapped above" when the script has no flags.
387
+ - 3d20592: Native engine: a module the require hooks resolve themselves (Metro's platform-extension scan, the project's aliases, React Native's deep paths) is now keyed by its real path, as Node keys its own resolutions. A file reached through a symlink, or on Windows an alias target written with `/`, loaded a second time and gave two instances of one module.
388
+
389
+ - 041fd77: Fix native-engine gaps found running a production Expo app's existing suite
390
+
391
+ - React Native's setup now runs before the project's own setup files. A setup file that imported `react-native` or `@testing-library/react-native` failed on React Native's Flow source whenever the hot runtime was not in use.
392
+ - Importing `expo` (directly, or through packages such as `expo-location`) works: Expo's dev-server message socket is stubbed on every load path, and packages a compiled CommonJS module requires internally stay shadowed by their presets instead of loading the real native packages.
393
+ - `require('#/…')` and `jest.requireActual('#/…')` resolve the project's `resolve.alias` entries and, when Vite resolves them for imports, its tsconfig `paths`.
394
+ - App source required through Node compiles `export * as ns from '…'` when the project's toolchain provides the Babel plugin, as Expo's does.
395
+ - `react-native-nitro-modules` imports under the native engine: its native install step provides a proxy with no hybrid objects, and creating one throws `NITRO_HYBRID_OBJECT_UNAVAILABLE`.
396
+ - `react-native-mmkv` 3 and later run their own built-in test mode, with their real API and change listeners; the `mmkv` preset now applies to mmkv 2 only.
397
+
398
+ - dbb9c74: Match Jest for four behaviours migrated suites depend on in jest-compat
399
+
400
+ - **Getters in a `jest.mock` factory are read lazily.** The CommonJS interop copied the factory's return with an object spread, which ran every getter while the factory was evaluated. A factory such as `() => ({ get IS_WEB() { return mockIsWeb } })` runs during the hoisted imports, before the test file's `let mockIsWeb` is initialised, so it threw `Cannot access 'mockIsWeb' before initialization`, and later changes to the variable were never seen. Accessors are now read from the module on each access, as an importer reads them in Jest.
401
+ - **An export a `jest.mock` factory leaves out is `undefined`.** Jest reads named imports as properties of `module.exports`; Vitest throws `No "x" export is defined on the "m" mock`. Factories passed through `jestMockTransform` now follow Jest. A plain `vi.mock` factory keeps Vitest's strict check.
402
+ - **`new` on a `jest.fn` with an arrow implementation returns the implementation's result.** Jest applies a mock's implementation whether or not it is called with `new`, so `jest.fn().mockImplementation(() => ({ fetch }))` works as a class mock; Vitest constructs the implementation and throws `… is not a constructor`. Mocks created by `jest.fn` and `jest.spyOn` now follow Jest, including `mockReturnValue` and `mockResolvedValue` under `new`, and a `jest.spyOn` spy with no implementation set calls an arrow-function original under `new` (also after `mockReset()`). A mock that already existed, which `jest.spyOn` returns as it is, is left unchanged, and `vi.fn` is unchanged.
403
+ - **`process.env.JEST_WORKER_ID` is set.** The compat setup sets it from Vitest's 1-based `VITEST_POOL_ID` when it is not already set, so code that detects a Jest run (for example `__DEV__ && !process.env.JEST_WORKER_ID`) takes its test branch.
404
+
405
+ - 52e80aa: Run the native engine's ESM loader hooks in-thread where Node supports it
406
+
407
+ The native engine's ESM loader hooks now run in-thread through `module.registerHooks()` where Node
408
+ provides it (22.15+, 23.5+), instead of on a separate loader thread through `module.register()`.
409
+ Every resolve and load of an externalized module previously waited on a synchronous cross-thread
410
+ request; profiled on a 104-file production Expo suite, that wait was 18% of worker CPU time. Older
411
+ Node versions keep the threaded hooks, and `VITEST_NATIVE_LOADER_THREAD=1` forces them.
412
+
413
+ - 52e80aa: Reuse externalized resolutions across test files under the hot runtime
414
+
415
+ Under the hot runtime, externalized imports are no longer re-resolved from scratch for every test
416
+ file. The per-file generation stamp on parent URLs defeated Node's resolve cache; the loader now
417
+ keeps successful resolutions per unstamped parent, so Node stops re-reading package.json scopes to
418
+ decide module formats on every file.
419
+
420
+ - 6100732: Make `migrate` reproduce Jest's effective test set and settings, and report Babel plugins
421
+
422
+ `migrate` translated only an explicit `testMatch`, so a project that took its patterns from a
423
+ preset or from Jest's defaults was migrated to Vitest's default include instead. On a jest-expo
424
+ app this collected about twice as many files as Jest ran and missed some of Jest's own tests.
425
+ The suggested config now uses Jest's effective patterns: the config's `testMatch`, otherwise the
426
+ installed preset's (read from it the way Jest loads it), otherwise Jest's defaults for the
427
+ installed major. `testPathIgnorePatterns` and `modulePathIgnorePatterns` become `test.exclude`
428
+ globs where the regex has an exact glob form (and are reported where it does not), and
429
+ extensions missing from `moduleFileExtensions` are excluded, since Jest never sees those files.
430
+
431
+ Other changes:
432
+
433
+ - Flags that the `test` script passes to Jest are applied over the config as Jest applies them:
434
+ `--testTimeout`, `--maxWorkers`, `--runInBand` and `--config`. `--bail` is reported rather than
435
+ mapped because Vitest's `bail` counts failed tests, not suites.
436
+ - Anchored `moduleNameMapper` keys (`^name$`) become exact `resolve.alias` entries. A mapper whose
437
+ target is a file of the same package, for a specifier that package's `exports` already serves, is
438
+ dropped; a redirect to another package is kept.
439
+ - `transformIgnorePatterns` allowlists with nested and optional groups are now parsed. A package
440
+ goes into `transform` only when it ships a `.js` file under its entry point that is not standard
441
+ JavaScript (JSX or Flow) and the engine does not already compile it; the report names that file.
442
+ - Packages that run their own test mode under Vitest (react-native-mmkv 3 and later) are not
443
+ credited to a preset by either command, and the engine-detection baseline both commands use
444
+ is computed with the presets the plugin would actually enable.
445
+ - The project's Babel config is read, and its plugins are sorted into required (macro plugins),
446
+ mapped (`module-resolver` aliases become `resolve.alias`), not needed (worklets/reanimated
447
+ plugins, React Compiler) and unknown. `migrate` adds required plugins through
448
+ `@rolldown/plugin-babel` when Vite 8 and that package are installed, and otherwise prints the
449
+ snippet to add. `doctor` warns about the same plugins.
450
+ - The CLI no longer claims more than the presets do. The report and `doctor` name the modules the
451
+ expo preset shadows instead of saying Expo modules are covered. A manual `__mocks__` file is
452
+ called redundant only when an active preset shadows that module. Asset mappers are compared with
453
+ the extensions the plugin stubs by default.
454
+
455
+ - 2233866: Stop a circular-dependency warning on an Expo project's first run
456
+
457
+ Babel loads its presets and plugins with `require` during a transform, and those requires went
458
+ through the native engine's CommonJS hook like any other. `babel-plugin-syntax-hermes-parser` and
459
+ `hermes-parser`, which `@react-native/babel-preset` uses, keep an `@flow` header in their published
460
+ builds and sit under an `@react-native` package, so the hook sent them back through Babel
461
+ mid-transform. Babel then read a half-loaded plugin's exports and Node printed "Accessing
462
+ non-existent property 'then' of module exports inside circular dependency" on a cold cache, for
463
+ example on a fresh `create-expo-app` project. Code Babel loads during a transform now runs as
464
+ published, as it does under Jest.
465
+
466
+ - 84591de: Depend on `flow-remove-types` ^2.333.0 (was ^2.332.0).
467
+
468
+ - bb9cf45: Fix `./App` resolving to `app.json` on macOS and Windows
469
+
470
+ The React Native CLI template ships `App.tsx` and `app.json` side by side, and its own test
471
+ imports `../App`. Metro's extension order tries `.json` before `.tsx`, and macOS and Windows disks
472
+ are case-insensitive, so asking whether `App.json` exists answered yes for `app.json`. The template's
473
+ test then rendered `{ name, displayName }` and failed with "Element type is invalid … got: object",
474
+ while it passes under Jest. Metro resolves from a case-sensitive file map, and Linux CI is
475
+ case-sensitive, which is why neither caught it. Extensionless relative imports now match file
476
+ names exactly, under both engines.
477
+
478
+ - e2fa36e: Resolve tsconfig path aliases in Expo projects, as Expo's Metro does
479
+
480
+ Expo CLI resolves the `paths` in `tsconfig.json` by default, and the SDK 57 template imports its
481
+ own components through `@/…`, so the first component test in a new Expo project failed with
482
+ "Cannot find package '@/components/…'". In an Expo project with a `tsconfig.json`, the plugin now
483
+ turns on Vite 8's `resolve.tsconfigPaths`. An explicit `resolve.tsconfigPaths` and
484
+ `experiments.tsconfigPaths: false` in `app.json` both take precedence. On Vite 6 and 7, which
485
+ cannot resolve tsconfig paths, it warns once with the remedy. Bare React Native projects are
486
+ unchanged, matching their Metro.
487
+
488
+ - d23ecfa: Stop warning about `jest.mock()` in files the project does not own
489
+
490
+ The warning that a file calls `jest.mock()` without `jestMockTransform()` also fired on
491
+ dependencies and on vitest-native's own files: the jest-compat setup, which implements `jest.mock`,
492
+ and the plugin source, which only names it. A project using `vitest-native/jest-compat/setup`
493
+ without the transform was told to fix a file inside `node_modules/vitest-native`. The warning now
494
+ applies only to the project's own files.
495
+
496
+ - d93d80d: Fix Expo packages whose TypeScript source has no type syntax failing to load
497
+
498
+ Expo packages publish their TypeScript source (`expo-modules-core`'s `main` is `src/index.ts`),
499
+ and the native engine compiles it before Node runs it. A file that Node could already parse was
500
+ handed to Node unchanged, which is right for JavaScript but not for TypeScript: Node refuses any
501
+ `.ts` file under `node_modules`, whatever it contains. `expo-modules-core/src/polyfill/index.ts`
502
+ is a bare `// noop`, so a test rendering the Expo SDK 57 template's `Collapsible` (through
503
+ `expo-symbols`) failed with "Stripping types is currently unsupported for files under
504
+ node_modules". TypeScript files are now always compiled.
505
+
506
+ - 7f70965: Fix multi-project runs failing when a native project uses the hot runtime
507
+
508
+ Vitest runs projects that share a `sequence.groupOrder` (0 unless set) as one group, and stops
509
+ the run when they resolve to different `maxWorkers` ("Projects … have different 'maxWorkers'
510
+ but same 'sequence.groupOrder'"). The hot runtime's memory plan caps workers at four, while a
511
+ project beside it, such as a mock-engine or non-React-Native project, gets Vitest's default of one
512
+ fewer than the CPUs. So a config with a native project and another project failed on any machine
513
+ with more than five cores. `hotRuntime: 'auto'` now keeps Vitest's isolation and worker count for
514
+ that project and says why. An explicit `hotRuntime: true` fails with `HOT_RUNTIME_OVERRIDDEN`,
515
+ because a distinct `test.sequence.groupOrder` is what lets the two run as separate groups.
516
+
517
+ - 0063f23: Fix `environment: 'jsdom'` failing to start any test worker
518
+
519
+ Vitest forwards the project's resolve conditions, including the `react-native` condition both
520
+ engines add, to each worker as Node `--conditions` flags. Vitest also loads the test environment
521
+ in that worker. jsdom depends on lru-cache, whose 11.5.3 export map names a `react-native`
522
+ CommonJS build it does not publish, so every worker failed with "Cannot find module
523
+ …/lru-cache/dist/commonjs/react-native/index.min.js". The plugin now preloads a resolver
524
+ recovery in each worker. When Node fails because a package's `react-native` export target does
525
+ not exist, the same export is resolved with the process's other conditions, as Node would
526
+ without `react-native`. Every other resolution is left exactly as Node makes it. jsdom and
527
+ happy-dom now work with both engines, with and without the hot runtime.
528
+
529
+ - 49975e0: Keep Vitest's own settings under `hotRuntime: 'auto'`, including CLI flags
530
+
531
+ - An explicit `test.isolate` (or `--isolate` / `--no-isolate`) is now a reason for `'auto'` to keep
532
+ Vitest's semantics instead of selecting the hot runtime: `true` gets a fresh worker per file,
533
+ `false` one module graph shared across files, as Vitest documents them.
534
+ - On Vitest 4, CLI flags such as `--maxWorkers=1`, `--no-file-parallelism`, `--pool` and
535
+ `--no-isolate` reach the resolved config only after plugins' config hooks run, so `'auto'` chose
536
+ the hot runtime without seeing them. `vitest run --maxWorkers=1` then failed with
537
+ `HOT_MEMORY_UNBOUNDED` and did not exit. The choice is now re-checked against the resolved config
538
+ before any worker starts, per project and on both Vitest majors: `'auto'` falls back to Vitest's
539
+ settings (including its worker count) and says so.
540
+ - An explicit `hotRuntime: true` no longer overrides a configured pool or `test.isolate` with a
541
+ warning, or a conflicting CLI flag silently: it fails at startup with `HOT_RUNTIME_OVERRIDDEN`.
542
+ - `--pool=vmThreads` / `--pool=vmForks` on the command line now fail with `UNSUPPORTED_POOL`, as
543
+ the same pools in the config already did.
544
+ - The engine banner names the hot runtime when it is in use, so a cross-file failure points at
545
+ `hotRuntime: false` from the first line of the log.
546
+
547
+ - 49975e0: Fix inline `test.projects` on Vitest 5 running without vitest-native's setup
548
+
549
+ Vitest 5 lets an inline project (`projects: [{ extends: true, … }]`) share the declaring
550
+ config's Vite server and builds its `test` options from the raw user config, before any
551
+ plugin's `config` hook runs. Those projects lost everything vitest-native adds to `test` —
552
+ setup files, module ownership, env, the hot runtime — and their tests failed to load. The
553
+ plugin now pins each inline project's `root` to the root it inherits anyway, which makes Vitest
554
+ resolve it through the config file with the plugin, as on Vitest 4. This works in a nested
555
+ config too, where `test.sharedViteServer` (read only from the top-level config) cannot help. A
556
+ project that still reaches the run without the plugin's setup fails with `SHARED_VITE_SERVER`.
557
+
558
+ - 49975e0: Fix React Native 0.87 failing to load in a project with no `node_modules` of its own
559
+
560
+ A project whose dependencies are hoisted to a parent directory — a monorepo package, or a Vitest
561
+ project rooted in a subdirectory — had its precompiled React Native registry cached in the OS
562
+ temp directory. Code in that registry resolved React Native's deep self-imports from the cache
563
+ file's location, which cannot see the install, and failed with "Cannot find module
564
+ 'react-native/src/private/…'". The cache now lives under the project's own `node_modules`, or else the nearest
565
+ one above it that contains React Native, and resolution from the registry's own code starts at the
566
+ project, so a cache in the temp directory (a read-only `node_modules`, or macOS's symlinked `/var`)
567
+ works too.
568
+
569
+ - 9ab8270: Report project-source ownership risks consistently for extensionless and platform-specific Node resolution. The warning now distinguishes resolution from proven execution or duplicate instances, and respects Node-owned, delegated and overridden ownership policies. Resolution warnings remain nonfatal.
570
+ - 9ab8270: Bound the native hot runtime by effective host/container memory
571
+
572
+ Hot mode now derives one worker-total plan from `os.totalmem()` and
573
+ `process.constrainedMemory()`, reserves main-process and worker-replacement RSS,
574
+ caps automatic concurrency at four, and recycles one worker at a time on local heap
575
+ or process RSS. It fails before starting more work at the hard RSS boundary so a
576
+ container reports a useful `HOT_MEMORY_BUDGET_EXCEEDED` error instead of relying on
577
+ an OOM kill.
578
+
579
+ Current Vitest batches every file into one unrecyclable task at one worker. Hot mode
580
+ now rejects that configuration with `HOT_MEMORY_UNBOUNDED` rather than silently
581
+ claiming its limits are active. An externally bounded run can explicitly accept the
582
+ risk with `hotRuntime: { allowUnboundedMemory: true }`.
583
+
584
+ The policy is covered by unit and recycle-soak gates plus a packed RN 0.87 / RNTL 14
585
+ Docker gate: 512 MiB and 1 GiB fail closed before registry compilation, while 2 GiB
586
+ caps an eight-worker request to four, passes 405 files, and demonstrably recycles.
587
+
588
+ - 9ab8270: Bound cold React Native registry compilation outside the long-lived Vite process
589
+
590
+ Cold registry cache misses now compile in a short-lived child with a 96 MiB old-space
591
+ cap and a 256 MiB retry only for a recognized V8 heap OOM. The parent validates the
592
+ atomic cache result, warm runs remain spawn-free, and ordinary failures keep the
593
+ visible correctness-preserving per-file fallback. Registry keys now include
594
+ normalized asset extensions, which affect emitted module code.
595
+
596
+ A real 438-module production gate checks artifact parity, persistent-parent RSS,
597
+ warm lookup, bounded latency, and concurrent cold writers.
598
+
599
+ - 290bc53: `vitest-native doctor` no longer warns that Expo core and expo-router setups "can hit known limits" and points at a migration-guide section that no longer exists. Those setups work under the native engine; doctor now reports the Expo version as covered and links the Expo guide, mentioning `vitest-native migrate` for jest-expo projects.
600
+ - ff77511: Install React Native's ErrorUtils under the native engine; gate expo-router end to end
601
+
602
+ `global.ErrorUtils` — React Native's error-guard polyfill, installed on device by
603
+ InitializeCore — is read at module scope by Expo's `Expo.fx`
604
+ (`ErrorUtils.getGlobalHandler()`), so importing anything from `expo` under the
605
+ native engine failed with "ErrorUtils is not defined". The engine now installs the
606
+ real `@react-native/js-polyfills` implementation, resolved through the installed
607
+ React Native and compiled by the same hooks as the rest of its sources, once per
608
+ realm; nothing is hand-mocked.
609
+
610
+ The packed Expo consumer fixture gains an expo-router leg: a real SDK 56 project
611
+ with file-based `app/` routes (a stack layout, a home screen, a dynamic
612
+ `details/[id]` route), tested through expo-router's own `expo-router/testing-library`
613
+ — `renderRouter("./app")`, `testRouter.push`/`back`, `toHavePathname`,
614
+ `useLocalSearchParams` — exactly as its documentation shows and as a jest-expo
615
+ suite already contains. It runs against the real `@react-navigation/*` stack with
616
+ `presets: { navigation: false }` and the jest-compat layer, from a packed install
617
+ in the consumer gate.
618
+
619
+ - 9ab8270: Preserve CommonJS re-exports across hot worker file boundaries
620
+
621
+ Hot cleanup now invalidates stale Node relative-resolution lookups after deleting
622
+ per-file CommonJS cache entries. This prevents later ESM imports of direct CJS
623
+ re-exports from silently receiving empty exports on affected Node versions.
624
+
625
+ The compatibility layer preserves named exports, cycles, retry behavior and fresh
626
+ module identities. It does not evaluate user modules during cleanup; incompatible
627
+ loader behavior fails with an actionable worker-isolation fallback. Runtime
628
+ defaults are unchanged. The Node upstream fix remains the long-term replacement
629
+ for this internal-loader compatibility layer.
630
+
631
+ - e3faa95: Fix three cross-file leaks under the hot runtime and relative paths in `jest.setMock`
632
+
633
+ - A `jest.doMock`/`vi.doMock` issued after a file's last import was applied to the next
634
+ file's imports. Vitest queues such mocks until the next import, and the per-file reset
635
+ cleared the mock registries but not that queue; it now clears it too.
636
+ - React Native Testing Library, which the hot runtime keeps loaded once per worker,
637
+ registered its automatic cleanup and act-environment hooks only in the first file that
638
+ imported it. Later files left their trees mounted, and `screen` could return the previous
639
+ file's tree. When a file imports a resident RNTL, its entry module now re-runs against the
640
+ resident instances, so each file that imports RNTL gets RNTL's own hooks and a file that
641
+ does not import it gets none, as under per-file isolation.
642
+ - `jest.setMock` and `jest.dontMock` resolved a relative path against the jest-compat shim
643
+ instead of the calling test file, so the mock (or unmock) applied to the wrong module.
644
+ Relative paths are now anchored at the caller, as Jest resolves them. Finding the caller
645
+ also no longer skips a test file that lives in a directory named `jest-compat`.
646
+
647
+ - 9ab8270: Reset hot-runtime state before a test file's own setup files run
648
+
649
+ The hot runtime restored the previous file's realm state (fake timers, stubbed
650
+ globals and environment, listeners) from this package's setup file, which Vitest
651
+ runs after the project's own setup files. A project setup file that installs fake
652
+ timers therefore found the previous file's timers still installed and failed with
653
+ "Can't install fake timers twice", failing every file after the first. The reset
654
+ now runs at the file boundary, before any setup file.
655
+
656
+ - 01a9afc: Stop printing React Native's deprecation notices on every import under the native engine. The `react-native` facade read every export while it initialised, and React Native prints the notice for a deprecated or extracted member (`SafeAreaView`, `Clipboard`, `PushNotificationIOS`, …) from that member's getter, so importing only `Pressable` printed all of them. Deprecated members are now exposed as getters and read only when used, so a notice appears only in tests that use the member. The export-name parser also no longer picks up keys from code after the exports object.
657
+ - 8300ec6: Build native-engine preset mocks on first use in each test file
658
+
659
+ The native setup rebuilt every auto-detected preset mock for every test file — in
660
+ a project with twenty presets, about 900 `vi.fn()` mocks per file, most for
661
+ packages the file never imports. Vitest keeps every mock it has created (for
662
+ `vi.clearAllMocks()`), so under the hot runtime each file's unused mocks stayed
663
+ reachable for the rest of the run: worker heap grew about 4 MB per file and a
664
+ 1,000-file single-worker run ran out of memory. Each preset mock is now built
665
+ the first time a file uses it, and still fresh for every file. On the same run,
666
+ worker heap after 562 tests fell from about 2.4 GB to about 0.45 GB and 1,000
667
+ files complete in about 1.5 GB.
668
+
669
+ - 99f3013: Fix the matcher type augmentations for Vitest 4 and Vitest 5. Under Vitest 4, `expect(x).toHaveAnimatedStyle(...)` and `toHaveAnimatedProps(...)` from `vitest-native/matchers` were untyped: the published declaration file augmented the `vitest` module without referencing it, which Vitest 4's type layout needs for the augmentation to merge. The declarations now reference `vitest`, and both `vitest-native/matchers` and `vitest-native/rntl-matchers` use Vitest 5's `Assertion<R, T>` type parameters. The matchers are typed on both majors; a Vitest 4 project that checks declaration files (`skipLibCheck: false`) reports TS2428 for the differing type parameters.
670
+ - 525eb42: Translate jest-expo presets in `vitest-native migrate`
671
+
672
+ `migrate` reported `preset: 'jest-expo'` as needing attention and pointed at known limits
673
+ that no longer apply. It now translates the preset: `jest-expo` and `jest-expo/ios` become
674
+ `reactNative()`, `jest-expo/android` becomes `reactNative({ platform: 'android' })`, and
675
+ `jest-expo/universal`, `jest-expo/web` and `jest-expo/node` are reported with what to do
676
+ instead. jest-expo does not mock React Navigation, so when a `@react-navigation/*` package is
677
+ installed (which activates the navigation preset) the suggested config sets
678
+ `presets: { navigation: false }`, keeping screens in real navigators as under Jest; a
679
+ project with its own root `__mocks__/@react-navigation` keeps the preset. The packed Expo
680
+ SDK 57 consumer gate now also runs expo-router's testing library under the configuration
681
+ `migrate --write` generates from a jest-expo setup.
682
+
683
+ - 4e5130f: Navigation preset matches @react-navigation/native's shape; a disabled preset's package detects like any other
684
+
685
+ Two gaps that both surfaced by rendering router-driven screens under the native
686
+ engine — the shape most Expo apps have.
687
+
688
+ `createNavigatorFactory(Navigator)` now returns the real factory shape, yielding
689
+ `{ Navigator, Screen, Group }`. It returned a bare mock function whose result was
690
+ undefined, so any library building on the public factory API — expo-router extracts
691
+ its `Screen`/`Group` primitives through `createNavigatorFactory({})()` — failed at
692
+ import with "Cannot read properties of undefined (reading 'Screen')". The preset
693
+ also gains the exports `@react-navigation/native` adds on top of core:
694
+ `LinkingContext`, `LocaleDirContext`, `UNSTABLE_UnhandledLinkingContext`,
695
+ `DefaultTheme`, `DarkTheme` (real colors and platform font stacks), `createStaticNavigation`,
696
+ `ServerContainer`, `useLinkBuilder`, `useLinkProps`, `useLocale`, `useRoutePath`.
697
+ `ThemeContext` is seeded with `DefaultTheme`, as in the real package.
698
+
699
+ Disabling a preset — `presets: { navigation: false }` — now returns its packages to
700
+ ordinary ecosystem detection. Detection used to skip every preset package
701
+ unconditionally, so turning the preset off un-shadowed `@react-navigation/*` but
702
+ left it undetected: nothing compiled its untranspiled `lib/module` source and it
703
+ failed at load. That is the configuration under which the real React Navigation
704
+ stack, and expo-router's own `expo-router/testing-library` on top of it, run under
705
+ the native engine — `renderRouter` renders and `router.push` navigates.
706
+
707
+ - 3f62964: `jest.requireActual` and `jest.requireMock` now apply the project's `resolve.alias` string entries. A partial mock such as `jest.mock('@/services/api', () => ({ ...jest.requireActual('@/services/api'), fn: jest.fn() }))` threw "Cannot find module" because `requireActual` resolves through Node, which does not apply Vite's aliases. Aliases match on the whole specifier or a `/` boundary (an `@` alias does not capture `@scope/pkg`), the longest match wins, and an extensionless result is resolved with the platform's extension order (`@/Button` → `Button.ios.tsx`). Regex aliases and custom resolvers cannot reach the test worker; when one is configured, an unresolved specifier reports that instead of a bare "Cannot find module".
708
+ - d4ae5bf: Report the resolver-agreement warning (`'x' resolves to two different files`) only under `diagnostics`. The check compares Node's resolution against the package manifest and cannot see Vite's module graph, so it fired for packages that only Node ever requires — `test-renderer` (required by React Native Testing Library), `nanoid` (required by postcss) and Babel's source-map packages — printing on every test file. The warning now also states that it is a risk rather than a proven duplicate, and that its comparison uses Vite's default main fields.
709
+ - 963b35e: Type React Native Testing Library's matchers on RNTL 12 and 13
710
+
711
+ `vitest-native/rntl-matchers` imported RNTL's matcher interface from
712
+ `dist/matchers/types`, a path that exists only from RNTL 14; RNTL 12 and 13 keep it
713
+ under `build/`. On those versions the import resolved to nothing, and under
714
+ `skipLibCheck: true` the failure was silent: `toHaveTextContent`, `toBeVisible`,
715
+ `toBeDisabled` and the other matchers stayed untyped although the peer range is
716
+ `>=12 <15`. The entry now declares the interface itself, taking the element type from
717
+ RNTL's public `screen` API, and a test compares its members with the installed RNTL's
718
+ on each supported major. Typechecked against RNTL 12.9, 13.3 and 14.0 with Vitest 4
719
+ and 5 and TypeScript 6 and 7.
720
+
721
+ - 8893464: Fix `vitest-native/rntl-matchers` under TypeScript 7 with RNTL 14. RNTL 14 adds its matchers to the global `jest.Matchers<R>`, which Vitest's `JestAssertion` extends with `R = void`; the entry added them again with Vitest's assertion type, and TypeScript 7 rejects the two differing declarations (TS2320) for projects that typecheck declaration files (`skipLibCheck: false`). The entry now uses the same instantiation, so the declarations agree and the matchers stay typed.
722
+ - 9ab8270: Add conservative automatic selection for the bounded native hot runtime
723
+
724
+ `hotRuntime: "auto"` enables persistent native workers only when the current
725
+ configuration has recyclable task boundaries, enough host/container memory for at
726
+ least two workers, and no explicitly selected pool; otherwise it preserves stock
727
+ per-file isolation. Selection runs after other Vite config hooks, so
728
+ later-contributed pools and setup files cannot create a mixed runtime. (In this
729
+ release `'auto'` also becomes the default, falls back quietly unless set explicitly
730
+ or `diagnostics` is on, and includes suites migrated from Jest — see the minor
731
+ changes above.)
732
+
733
+ A packed consumer gate proves safe enablement and the one-worker and explicit-pool
734
+ fallbacks. Explicit `hotRuntime: true` keeps its existing fail-closed semantics.
735
+
736
+ - 9ab8270: Verify and restore hot-runtime shared-realm state between test files
737
+
738
+ Hot mode now uses an ordered state manifest for Vitest timers and stubs, native
739
+ boundary overrides, known React Native state, environment changes, process and RN
740
+ listeners, global and console property descriptors, ErrorUtils, and the Expo
741
+ compatibility runtime. Every restore is followed by final-realm verification, and a
742
+ failure names the responsible entry instead of surfacing later as an order-dependent
743
+ test failure.
744
+
745
+ An adversarial two-file suite contaminates every supported surface. A mutation gate
746
+ disables all eleven restore actions one at a time and requires each omission to fail,
747
+ covering both the normal precompiled registry and the resident-RN fallback path.
748
+
3
749
  ## 0.13.0
4
750
 
5
751
  ### Minor Changes