vitest-native 0.14.0-rc.8 → 0.14.0

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 (99) hide show
  1. package/README.md +91 -72
  2. package/dist/cli.d.mts +1 -3
  3. package/dist/cli.mjs +215 -76
  4. package/dist/context.d.mts +45 -0
  5. package/dist/context.mjs +243 -0
  6. package/dist/errors.d.mts +3 -0
  7. package/dist/helpers.cjs +53 -4
  8. package/dist/helpers.d.cts +1 -3
  9. package/dist/helpers.d.mts +1 -3
  10. package/dist/helpers.mjs +2 -3
  11. package/dist/host-5o48Ujzs.mjs +939 -0
  12. package/dist/{index-BSyUeoga.d.mts → index-DqU4YO3D.d.mts} +32 -53
  13. package/dist/index.d.mts +1 -3
  14. package/dist/index.mjs +464 -596
  15. package/dist/jest-compat/error-equality.mjs +127 -0
  16. package/dist/jest-compat/jest-object.mjs +149 -4
  17. package/dist/jest-compat/node-registry.mjs +233 -58
  18. package/dist/jest-compat/setup.mjs +34 -4
  19. package/dist/jest-compat.cjs +227 -52
  20. package/dist/jest-compat.d.cts +5 -6
  21. package/dist/jest-compat.d.mts +5 -6
  22. package/dist/jest-compat.mjs +204 -52
  23. package/dist/matchers.cjs +1 -2
  24. package/dist/matchers.d.cts +0 -2
  25. package/dist/matchers.d.mts +0 -2
  26. package/dist/matchers.mjs +1 -2
  27. package/dist/{memory-FYbP0_gg.mjs → memory-Couw0Esx.mjs} +31 -6
  28. package/dist/native/assets.d.mts +2 -0
  29. package/dist/native/assets.mjs +34 -0
  30. package/dist/native/babel-toolchain.mjs +190 -0
  31. package/dist/native/babel-worker.mjs +47 -0
  32. package/dist/native/boundary.mjs +23 -8
  33. package/dist/native/compile-cache.mjs +21 -9
  34. package/dist/native/coverage-v8.mjs +287 -0
  35. package/dist/native/esm-interop.mjs +216 -0
  36. package/dist/native/expo-native-modules.mjs +7 -1
  37. package/dist/native/globals.mjs +104 -6
  38. package/dist/native/hooks.mjs +271 -60
  39. package/dist/native/loader.mjs +409 -20
  40. package/dist/native/match.d.mts +24 -2
  41. package/dist/native/match.mjs +117 -12
  42. package/dist/native/metro-profile-compiler.mjs +2 -31
  43. package/dist/native/module-reset.mjs +37 -5
  44. package/dist/native/native-modules.d.mts +2 -3
  45. package/dist/native/native-modules.mjs +22 -21
  46. package/dist/native/ownership.d.mts +10 -0
  47. package/dist/native/ownership.mjs +96 -9
  48. package/dist/native/registry-compiler.mjs +6 -0
  49. package/dist/native/registry.mjs +138 -119
  50. package/dist/native/resident-health.mjs +133 -0
  51. package/dist/native/resolve.d.mts +6 -0
  52. package/dist/native/resolve.mjs +100 -9
  53. package/dist/native/rntl-hooks.mjs +157 -6
  54. package/dist/native/rntl-text-host.mjs +64 -0
  55. package/dist/native/runner.mjs +106 -1
  56. package/dist/native/setup.mjs +105 -77
  57. package/dist/native/state-manifest.mjs +14 -8
  58. package/dist/native/transform.d.mts +2 -0
  59. package/dist/native/transform.mjs +476 -59
  60. package/dist/native/worker.mjs +151 -46
  61. package/dist/{pool-DjpOjOf3.mjs → pool-CFSpNfyw.mjs} +37 -11
  62. package/dist/{preset-map-BlBriTA0.mjs → preset-map-CogjYmSw.mjs} +4 -19
  63. package/dist/preset-modules.mjs +2 -11
  64. package/dist/{presets--zrEWQC2.mjs → presets-CXDyg51l.mjs} +65 -82
  65. package/dist/presets.d.mts +1 -1
  66. package/dist/presets.mjs +1 -1
  67. package/dist/report-error.d.mts +20 -0
  68. package/dist/report-error.mjs +145 -0
  69. package/dist/rntl-support.d.mts +12 -0
  70. package/dist/rntl-support.mjs +189 -0
  71. package/dist/{rolldown-runtime-BhDjJH2R.mjs → rolldown-runtime-D70C1uOS.mjs} +1 -2
  72. package/dist/serializer.cjs +1 -2
  73. package/dist/serializer.d.cts +1 -3
  74. package/dist/serializer.d.mts +1 -3
  75. package/dist/serializer.mjs +1 -2
  76. package/dist/setup.mjs +95 -156
  77. package/dist/{worker-vitest-BGPo0ek6.mjs → worker-vitest-CILPFeRX.mjs} +2 -3
  78. package/docs/migrating-from-jest.md +76 -12
  79. package/docs/migrating-from-vitest-react-native.md +1 -1
  80. package/docs/release-readiness.md +6 -5
  81. package/docs/versioning.md +1 -1
  82. package/package.json +121 -103
  83. package/CHANGELOG.md +0 -2475
  84. package/dist/cli.cjs +0 -1924
  85. package/dist/cli.d.cts +0 -3
  86. package/dist/ecosystem-D6e1OVOg.mjs +0 -1019
  87. package/dist/ecosystem-MFwkbnaC.cjs +0 -1099
  88. package/dist/errors-B3lJK46O.cjs +0 -75
  89. package/dist/errors-CxoBUfVJ.mjs +0 -64
  90. package/dist/index-bZ7AHqLc.d.cts +0 -482
  91. package/dist/memory-6EPHrJA1.cjs +0 -144
  92. package/dist/pool-B4yesGhI.cjs +0 -121
  93. package/dist/preset-map-jSFsNy1Q.cjs +0 -241
  94. package/dist/preset-modules-BoLkaeEN.cjs +0 -53
  95. package/dist/preset-modules-CG8-G82P.mjs +0 -36
  96. package/dist/presets-9f83H0WW.cjs +0 -3939
  97. package/dist/rolldown-runtime-C0BPl7ul.cjs +0 -43
  98. package/dist/worker-vitest-BfiQB8ND.cjs +0 -62
  99. package/docs/hot-default-design.md +0 -216
package/README.md CHANGED
@@ -7,7 +7,7 @@ Run your React Native tests under Vitest, against **real React Native** — the
7
7
  > **Beta.** The release-supported native engine is validated across React Native 0.81–0.88,
8
8
  > Vite 6–8, Vitest 4–5, RNTL 12–14, bare apps, Expo SDK 58 and 57 (including expo-router's own testing
9
9
  > library), and hoisted monorepos. The hot
10
- > runtime (on by default where it can be bounded) is marked experimental because it uses Vitest's
10
+ > runtime (opt-in with `hotRuntime: 'auto'`) is marked experimental because it uses Vitest's
11
11
  > experimental custom-pool APIs.
12
12
  >
13
13
  > Maintained successor to [`vitest-community/vitest-react-native`](https://github.com/vitest-community/vitest-react-native) — same core idea (externalize RN, run its real JS under Node), rebuilt for modern Vitest (4+). Coming from it? See [Migrating from `vitest-react-native`](#migrating-from-vitest-react-native).
@@ -59,27 +59,23 @@ Testing React Native code with Jest has traditionally required a patchwork of co
59
59
 
60
60
  ```bash
61
61
  # bun
62
- bun add -d vitest-native
62
+ bun add -d vitest vite vitest-native @testing-library/react-native
63
63
 
64
64
  # npm
65
- npm install -D vitest-native
65
+ npm install -D vitest vite vitest-native @testing-library/react-native
66
66
 
67
67
  # yarn
68
- yarn add -D vitest-native
68
+ yarn add -D vitest vite vitest-native @testing-library/react-native
69
69
 
70
70
  # pnpm
71
- pnpm add -D vitest-native
71
+ pnpm add -D vitest vite vitest-native @testing-library/react-native
72
72
  ```
73
73
 
74
- A real React Native project already provides what the native engine needs —
74
+ `vitest` and `vite` are peer dependencies. `@testing-library/react-native` is optional, but the examples
75
+ below use it. A real React Native project already provides what the native engine needs —
75
76
  `react-native`, `@react-native/babel-preset`, and `@babel/core`. From Expo SDK 56,
76
77
  `babel-preset-expo` no longer depends on `@react-native/babel-preset`, and the engine compiles
77
- with Expo's own preset instead, as Metro does. Add
78
- `@testing-library/react-native` if you don't have it yet (the examples below use it):
79
-
80
- ```bash
81
- npm install -D @testing-library/react-native
82
- ```
78
+ with Expo's own preset instead, as Metro does.
83
79
 
84
80
  See [Requirements](#requirements) for exact versions.
85
81
 
@@ -121,8 +117,15 @@ test("renders a greeting", async () => {
121
117
 
122
118
  > Prefer Jest-style globals (`test`/`expect` without imports)? Set
123
119
  > `test: { globals: true }` in your Vitest config. vitest-native does not enable the full
124
- > globals mode; it only exposes `expect` when RNTL needs it to register matchers.
125
- > Awaiting `render` works with RNTL 12–13 and is required by RNTL 14.
120
+ > globals mode; it only exposes `expect` when RNTL needs it to register matchers, and
121
+ > registers RNTL's automatic cleanup after each test, which RNTL itself does only when
122
+ > `afterEach` is a global. That cleanup runs after the file's own `afterEach` hooks, as
123
+ > RNTL's does under Vitest with `globals: true` (Jest runs it first). Under the native engine,
124
+ > RNTL's `waitFor` and `findBy*` advance `vi.useFakeTimers()`'s clock with no extra setup. Under
125
+ > the mock engine they do so only with the
126
+ > [jest-compat layer](https://danfry1.github.io/vitest-native/guide/jest-compat); without it,
127
+ > advance the clock yourself (`await vi.advanceTimersByTimeAsync(ms)`). Awaiting
128
+ > `render` works with RNTL 12–13 and is required by RNTL 14.
126
129
 
127
130
  Run it:
128
131
 
@@ -145,12 +148,12 @@ export default defineConfig({
145
148
  reactNative({
146
149
  engine: "auto", // 'auto' | 'mock' | 'native' — auto → native when RN's babel deps are present, else mock
147
150
  platform: "ios", // 'ios' | 'android' (default: 'ios')
148
- presets: [], // Preset[] -- omit for auto-detect
149
- mocks: {}, // Custom mock overrides for the react-native module
151
+ // presets: omit to auto-detect; an array replaces auto-detection (`[]` means none)
152
+ mocks: {}, // engine: 'mock' only; non-empty under native is a config error
150
153
  diagnostics: false, // Enable verbose logging
151
154
  assetExts: [".lottie"], // Additional asset extensions to stub
152
155
  transform: [], // Extra native-engine packages to Flow/TS transform
153
- hotRuntime: "auto", // 'auto' (default) | true | false | HotRuntimeOptions
156
+ hotRuntime: false, // false (default) | 'auto' | true | HotRuntimeOptions
154
157
  }),
155
158
  ],
156
159
  });
@@ -160,12 +163,12 @@ export default defineConfig({
160
163
  | ------------- | ------------------------------ | ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
161
164
  | `engine` | `'auto' \| 'mock' \| 'native'` | `'auto'` | How React Native is provided to your tests. `auto` runs real RN (native) when available, else mock. See [`engine`](#engine) below. |
162
165
  | `platform` | `'ios' \| 'android'` | `'ios'` | Target platform. Controls `Platform.OS`, version defaults, and file extension resolution. |
163
- | `presets` | `Preset[]` | auto-detect | Built-in library presets. When omitted, installed packages are detected automatically. Only built-in presets are supported; for custom module mocking, use `vi.mock()` in a setup file. |
166
+ | `presets` | `(Preset \| string)[] \| Record<string, boolean>` | auto-detect | Library presets. When omitted, installed packages are detected automatically. An array uses only the presets it lists, so `[]` disables all of them; an object keeps auto-detection and switches presets on or off (`{ navigation: false }`). A string is the path of a module that exports your own preset. |
164
167
  | `mocks` | `Record<string, any>` | `{}` | **`engine: 'mock'` only.** JSON-serializable overrides merged into the `react-native` module mock. Function values are not supported; use `vi.mock()` in a setup file for function-based overrides. |
165
168
  | `diagnostics` | `boolean` | `false` | Log plugin activity to the console for debugging. |
166
169
  | `assetExts` | `string[]` | `[]` | Additional file extensions to stub as asset imports (beyond the built-in set). |
167
- | `transform` | `string[]` | `[]` | **`engine: 'native'` only.** Extra `node_modules` packages whose source the native engine should transform (Flow/TS/JSX stripped) as it loads them — for third-party RN libraries that ship untranspiled source (e.g. `react-native-reanimated`). Analogous to Jest's `transformIgnorePatterns` allowlist. |
168
- | `hotRuntime` | `boolean \| 'auto' \| HotRuntimeOptions` | `'auto'` | `engine: 'native'` only. Reuse workers while keeping app/test modules isolated per file. `'auto'` (the default) uses it when the run can be bounded and recycled, and per-file isolation otherwise; `false` always isolates per worker. See [Hot runtime](#hot-runtime). |
170
+ | `transform` | `string[]` | `[]` | **`engine: 'native'` only.** Extra `node_modules` packages whose source the native engine should transform (Flow/TS/JSX stripped) as it loads them — for packages that ship untranspiled source and are not detected automatically (packages your project depends on that declare `react-native` as a dependency or peer dependency, and their runtime dependencies, are compiled without being listed). Analogous to Jest's `transformIgnorePatterns` allowlist. |
171
+ | `hotRuntime` | `boolean \| 'auto' \| HotRuntimeOptions` | `false` | `engine: 'native'` only. Reuse workers while keeping app/test modules isolated per file. `false` (the default) gives each file a fresh worker; `'auto'` opts in where the run can be bounded and recycled, and keeps per-file isolation otherwise. See [Hot runtime](#hot-runtime). |
169
172
 
170
173
  ### Experimental Metro configuration
171
174
 
@@ -193,7 +196,7 @@ main fields and conditions remain governed by the engine's ownership policy;
193
196
  startup; changing it requires restarting the run.
194
197
 
195
198
  Default: `false`. Findings and remaining gates are recorded in
196
- [the investigation log](docs/metro-profile-investigation.md).
199
+ [the investigation log](https://github.com/danfry1/vitest-native/blob/main/packages/vitest-native/docs/metro-profile-investigation.md).
197
200
 
198
201
  ### `engine`
199
202
 
@@ -242,9 +245,11 @@ the cross-check/fidelity harnesses in the repository's `bench/` directory.
242
245
 
243
246
  #### Hot runtime
244
247
 
245
- Vitest's default isolation gives each test file a fresh worker, so React Native would reload for
246
- every file. By default (`hotRuntime: 'auto'`) the native engine instead reuses workers and resets
247
- modules per file whenever that can be done safely:
248
+ Vitest's default isolation gives each test file a fresh worker, so React Native reloads for every
249
+ file; that is the default (`hotRuntime: false`), as in 0.13.0. With `hotRuntime: 'auto'` the native
250
+ engine instead reuses workers and resets modules per file whenever that can be done safely. It has
251
+ known differences from per-file isolation, listed under "A test passes on its own but fails when
252
+ run with other files" in the troubleshooting guide.
248
253
 
249
254
  `'auto'` selects persistent workers when the current scheduler provides recyclable task boundaries,
250
255
  the host/container memory plan admits at least two workers, no other pool was explicitly
@@ -259,8 +264,8 @@ jest-compat surface — `jest.mock` in its forms, runtime mocks, spies, timers,
259
264
  Library cleanup — has its own cross-file isolation gate under the hot runtime. The decision runs
260
265
  after other Vite config hooks, so a pool contributed by a later plugin is included rather than
261
266
  producing a mixed runtime. When it falls
262
- back to per-file isolation it does so quietly; `diagnostics: true`, or setting `hotRuntime: 'auto'`
263
- explicitly, prints the reason. To always isolate per worker:
267
+ back to per-file isolation it prints the reason. Per-file isolation, the default, can also be set
268
+ explicitly:
264
269
 
265
270
  ```ts
266
271
  reactNative({
@@ -283,7 +288,7 @@ resetting the registry's module instances and the app/test module graph for ever
283
288
  state manifest also restores and verifies timers/Vitest stubs, direct `process.env` changes,
284
289
  process and RN listeners, complete global and console property descriptors, known RN state,
285
290
  ErrorUtils, Expo runtime state, and plugin boundary mocks. A mutation gate removes each of its
286
- eleven restore actions in turn and requires the cross-file isolation suite to fail by name.
291
+ restore actions in turn and requires the cross-file isolation suite to fail by name.
287
292
 
288
293
  When hot is enabled, the plugin derives a worker-total memory plan from the lower of host and
289
294
  container/cgroup memory. It reserves main-process and replacement headroom, caps automatic
@@ -312,8 +317,12 @@ reactNative({
312
317
  });
313
318
  ```
314
319
 
320
+ That object requires the hot runtime and fails where it cannot run. Add `mode: "auto"` to keep
321
+ these options and fall back to per-file isolation instead, as `'auto'` does:
322
+ `hotRuntime: { mode: "auto", memoryLimit: 2 * 1024 ** 3 }`.
323
+
315
324
  Recycling is applied between Vitest scheduler tasks. Current Vitest batches every file into one
316
- uninterruptible task at `maxWorkers: 1`, so the default `'auto'` keeps per-file isolation there and
325
+ uninterruptible task at `maxWorkers: 1`, so `'auto'` keeps per-file isolation there and
317
326
  `hotRuntime: true` fails that configuration rather than claim an inert memory bound. Use at least
318
327
  two workers for hot mode. If an external scheduler
319
328
  already provides a hard boundary, you can deliberately accept the risk with
@@ -480,7 +489,7 @@ Register a custom native module mock. The module becomes available through both
480
489
  ```ts
481
490
  import { mockNativeModule } from "vitest-native/helpers";
482
491
 
483
- test("uses a custom native module", () => {
492
+ test("uses a custom native module", async () => {
484
493
  mockNativeModule("MyBridge", {
485
494
  getValue: vi.fn().mockResolvedValue(42),
486
495
  });
@@ -581,8 +590,9 @@ JavaScript runs for real — `expo` itself, expo-router, React Navigation and Ex
581
590
  jest-expo: from the package's own `mocks/<Name>.ts` where it ships one, else from Expo's table
582
591
  of the native modules (`Device.modelName` is `'mock'`). An optional native module a package
583
592
  probes for, and that no installed package defines, is absent, as on a device.
584
- - **Expo SDK trails React Native.** Pin your `react-native` to the version your Expo SDK supports
585
- (SDK 54 and later are within this plugin's validated range), not the newest RN release.
593
+ - **Expo SDK 57 and 58 are supported.** Earlier SDKs are not: the plugin and `doctor` warn about
594
+ one, so upgrade to SDK 57 or 58. Pin your `react-native` to the version your Expo SDK
595
+ supports, not the newest RN release.
586
596
 
587
597
  Packed Expo SDK 58 and SDK 57 apps are installed from the release tarball and tested in CI: Expo
588
598
  module auto-detection and rendering, and expo-router's testing library against file-based `app/`
@@ -613,30 +623,30 @@ common case it's a config swap:
613
623
 
614
624
  Named import, and drop `@vitejs/plugin-react` (vitest-native handles the JSX runtime itself). The
615
625
  full walkthrough — install, gotchas, what's the same — is in
616
- **[docs/migrating-from-vitest-react-native.md](docs/migrating-from-vitest-react-native.md)**.
626
+ **[docs/migrating-from-vitest-react-native.md](https://github.com/danfry1/vitest-native/blob/main/packages/vitest-native/docs/migrating-from-vitest-react-native.md)**.
617
627
 
618
628
  ---
619
629
 
620
630
  ## Migrating from Jest
621
631
 
622
632
  vitest-native ships a small compat layer that clears the mechanical Jest-API coupling in an existing
623
- suite (the `jest` global, `@jest/globals`, jest-native's extend-expect):
633
+ suite (the `jest` global, top-level `jest.mock`, `@jest/globals`, jest-native's extend-expect):
624
634
 
625
635
  ```ts
626
636
  // vitest.config.mts
627
637
  import { reactNative } from "vitest-native";
628
- import { jestCompatAliases, jestCompatSetup } from "vitest-native/jest-compat";
638
+ import { jestCompatAliases, jestCompatSetup, jestMockTransform } from "vitest-native/jest-compat";
629
639
 
630
640
  export default defineConfig({
631
- plugins: [reactNative({ engine: "native" })],
641
+ plugins: [reactNative({ engine: "native" }), jestMockTransform()],
632
642
  resolve: { alias: { ...jestCompatAliases() } },
633
643
  test: { globals: true, setupFiles: [jestCompatSetup] },
634
644
  });
635
645
  ```
636
646
 
637
- This is **not** a turnkey drop-in — a real suite still needs a small per-suite cleanup (convert
638
- top-level `jest.mock` → `vi.mock`, RNTL ≥ 12, re-record snapshots once with `-u`). The full recipe,
639
- with a worked real-app example, is in **[docs/migrating-from-jest.md](docs/migrating-from-jest.md)**.
647
+ This is **not** a turnkey drop-in — a real suite still needs a small per-suite cleanup (mocks for
648
+ native libraries with no preset, RNTL ≥ 12, record snapshots for Vitest in their own directory). The full recipe,
649
+ with a worked real-app example, is in **[docs/migrating-from-jest.md](https://github.com/danfry1/vitest-native/blob/main/packages/vitest-native/docs/migrating-from-jest.md)**.
640
650
 
641
651
  ---
642
652
 
@@ -660,45 +670,42 @@ npm i -D @react-native/babel-preset @babel/core
660
670
  To silence the notice and stay on mock deliberately, set `reactNative({ engine: 'mock' })`.
661
671
 
662
672
  **`vi.mock('some-rn-library')` doesn't take effect (native engine)**
663
- Under `engine: 'native'`, React Native and its native-side libraries are _externalized_ to Node,
664
- so they load outside Vite's module graph — and Vitest's mocker only intercepts modules inside that
665
- graph. Your **own** source modules mock normally; the gap is third-party RN-side packages. Options:
673
+ Under `engine: 'native'`, React Native and third-party RN packages load through Node. `vi.mock`
674
+ applies to what your test and app source import, but not to `require()` calls inside a
675
+ Node-loaded library: a library's own import of a mocked package still gets the real one. Options:
666
676
 
667
677
  - Use a **[preset](#auto-detect-presets)** if one exists (it shadows the library the way Jest does).
668
- - For a pure-JS library shipping untranspiled source, add it to the [`transform`](#plugin-options)
669
- allowlist so the engine strips its Flow/TS as it loads.
670
678
  - Or test that boundary on the **mock engine**, where `vi.mock` applies normally.
671
679
 
672
680
  **`Unexpected token` / Flow syntax errors from a third-party library (native engine)**
673
- The require hook strips Flow/TS from `react-native` and active presets, but not from arbitrary
674
- packages. If a dependency ships untranspiled Flow/TS, add it to the
675
- [`transform`](#plugin-options) allowlist.
681
+ Packages your project depends on that declare `react-native` as a dependency or peer dependency,
682
+ and their runtime dependencies, are compiled automatically. If another package ships untranspiled
683
+ Flow/TS/JSX, add it to the
684
+ [`transform`](#plugin-options) list.
676
685
 
677
686
  **My `babel.config.js` plugin isn't running**
678
- Transforms go through Vite's JSX transformer, not your Babel config, so custom Babel plugins don't
679
- apply. Vite 6–7 use esbuild and Vite 8 uses Oxc; the plugin configures the automatic JSX runtime for
680
- both. RN/preset Flow-stripping is handled separately; for anything else, prefer a Vite plugin or a
681
- preset.
687
+ Files your tests `import` go through Vite's JSX transformer, not your Babel config, so custom Babel
688
+ plugins don't apply to them. Vite 6–7 use esbuild and Vite 8 uses Oxc; the plugin configures the
689
+ automatic JSX runtime for both. Project TypeScript files that Node loads (through `require()` or
690
+ `jest.requireActual`) are compiled with your Babel config, as babel-jest compiles them; plain `.js`
691
+ project files Node loads are not compiled.
692
+ `vitest-native doctor` lists the Babel plugins a run does not apply; one your tests depend on, such
693
+ as a macro plugin, runs through a Vite plugin that calls Babel
694
+ ([recipe](https://danfry1.github.io/vitest-native/migration/from-jest#babel-plugins-your-jest-run-applied)).
682
695
 
683
696
  **Snapshots differ after switching from Jest or the mock engine**
684
697
  Real RN computes host props (e.g. `<Text>`'s `accessible`, `allowFontScaling`) that mocks omit, so
685
- the tree is richer. Re-record once with `npx vitest -u` after migrating.
698
+ the tree is richer. Vitest also keys snapshots differently from Jest (`a > b 1`, not `a b 1`), so
699
+ it cannot check Jest's `.snap` files, and `vitest -u` rewrites them for Vitest. While both runners
700
+ run, give Vitest its own directory with `test.resolveSnapshotPath`; see
701
+ [docs/migrating-from-jest.md](https://github.com/danfry1/vitest-native/blob/main/packages/vitest-native/docs/migrating-from-jest.md#2d-snapshots-keep-jests-and-vitests-apart-then-record-vitests).
686
702
 
687
703
  **`Worker terminated due to reaching memory limit` / `JS heap out of memory` (large native suites)**
688
- Every test file that renders real React Native loads a full renderer, so a large suite can grow a
689
- worker's heap past Node's default ceiling. Cap it with Vitest's per-worker limit — Vitest recycles a
690
- worker once its heap exceeds the limit, so growth never reaches the hard OOM:
691
-
692
- ```ts
693
- // vitest.config.ts
694
- export default defineConfig({
695
- test: { poolOptions: { threads: { memoryLimit: "512MB" } } },
696
- });
697
- ```
698
-
699
- The hot runtime (the default where it can be bounded) also helps: it keeps React Native's precompiled
700
- factory registry warm, resets its module instances from memory per file, and recycles workers on a
701
- memory/file budget.
704
+ Every test file that renders real React Native loads a full renderer. Under the default per-file
705
+ isolation each file starts in a fresh worker, so heap does not accumulate across files. Under the
706
+ hot runtime (`hotRuntime: 'auto'`), workers
707
+ are reused and recycled on a memory budget; set your own heap threshold with
708
+ `hotRuntime: { mode: "auto", memoryLimit }` (bytes; see [Hot runtime](#hot-runtime)).
702
709
 
703
710
  **`Vitest caught N unhandled errors` in error-boundary tests**
704
711
  A test that intentionally throws inside a component (to exercise an error boundary) makes React log
@@ -959,6 +966,17 @@ reactNative({
959
966
 
960
967
  This prints details about which presets were detected, which modules are being mocked, and how imports are resolved. Useful for debugging unexpected behavior.
961
968
 
969
+ To turn it on for a single run, read an environment variable you choose, then run
970
+ `RN_TEST_DEBUG=1 vitest run`:
971
+
972
+ ```ts
973
+ reactNative({ diagnostics: process.env.RN_TEST_DEBUG === "1" });
974
+ ```
975
+
976
+ There is no `VITEST_NATIVE_DIAGNOSTICS` variable. Older releases' `VITEST_NATIVE_*` settings, such
977
+ as `VITEST_NATIVE_PLATFORM`, are no longer read; set the matching option. Startup warns when one
978
+ is set.
979
+
962
980
  ---
963
981
 
964
982
  ## Support Policy
@@ -971,7 +989,7 @@ that API.
971
989
 
972
990
  Every release must pass:
973
991
 
974
- - Linux on Node 20.19, 22.13, and 24, plus macOS and Windows on Node 22.13.
992
+ - Linux on Node 22.13 (with RNTL 12, 13 and 14) and 24, plus macOS and Windows on Node 22.13.
975
993
  - The mock, native iOS, native Android, hot-runtime, isolation, and 100-file soak suites.
976
994
  - React Native 0.81–0.88 against both locked and newest-supported Vitest, plus the Vitest 4 floor
977
995
  on 0.81 and 0.88.
@@ -986,11 +1004,11 @@ Every release must pass:
986
1004
  package export analysis.
987
1005
 
988
1006
  Current React Native edge releases are also tested weekly. See
989
- [the release-readiness policy](docs/release-readiness.md) for the exact gates and stability labels.
1007
+ [the release-readiness policy](https://github.com/danfry1/vitest-native/blob/main/packages/vitest-native/docs/release-readiness.md) for the exact gates and stability labels.
990
1008
 
991
1009
  For what is *promised* rather than what is tested — which exports and options are protected by
992
1010
  semver, which are experimental, how the version ranges above may move, and what 1.0 will mean —
993
- see [versioning and stability](docs/versioning.md).
1011
+ see [versioning and stability](https://github.com/danfry1/vitest-native/blob/main/packages/vitest-native/docs/versioning.md).
994
1012
 
995
1013
  ---
996
1014
 
@@ -1001,14 +1019,15 @@ see [versioning and stability](docs/versioning.md).
1001
1019
  | `react` | >= 18; use RN's matching React version |
1002
1020
  | `vite` | ^6.4.2, ^7.3.2, or ^8.0.5 |
1003
1021
  | `vitest` | 4.x or 5.x |
1004
- | `node` | >= 20.19; RN/RNTL may impose a higher floor |
1022
+ | `node` | 22.13+ on Node 22, or 24.3+ |
1005
1023
  | `react-native` (native engine) | 0.81–0.88 validated |
1006
1024
  | `@react-native/babel-preset` (native engine) | Match the installed React Native minor |
1007
1025
  | `@testing-library/react-native` (optional) | 12.x, 13.x, or 14.x |
1008
1026
 
1009
- RNTL 14 requires Node 22.13 or 24+ and uses async rendering APIs. React Native 0.86 requires
1010
- Node 20.19.4, 22.13, or 24.3 or newer. Those are upstream requirements; the mock engine itself
1011
- continues to support Node 20.
1027
+ Node 20 reached end of life in April 2026. Node 22.13 is the first Node 22 that both RNTL 14 and the
1028
+ engine's CommonJS entry points (`require(esm)`) support. On Node 24.0–24.2, `jest.mock`,
1029
+ `jest.isolateModules` and `jest.resetModules` do not reach modules Node loads, with either loader.
1030
+ Node 23 is past its end of life. RNTL 14 uses async rendering APIs.
1012
1031
 
1013
1032
  ---
1014
1033
 
package/dist/cli.d.mts CHANGED
@@ -1,3 +1 @@
1
- //#region src/cli/index.d.ts
2
- export declare function main(argv: string[], log?: (line: string) => void): number;
3
- //#endregion
1
+ export declare function main(argv: string[], log?: (line: string) => void): number;