vitest-native 0.14.0-rc.9 → 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.
- package/README.md +76 -60
- package/dist/cli.d.mts +1 -3
- package/dist/cli.mjs +175 -63
- package/dist/context.d.mts +45 -0
- package/dist/context.mjs +243 -0
- package/dist/errors.d.mts +3 -0
- package/dist/helpers.cjs +53 -4
- package/dist/helpers.d.cts +1 -3
- package/dist/helpers.d.mts +1 -3
- package/dist/helpers.mjs +2 -3
- package/dist/host-5o48Ujzs.mjs +939 -0
- package/dist/{index-CzQazgp9.d.cts → index-DqU4YO3D.d.mts} +27 -49
- package/dist/index.d.mts +1 -3
- package/dist/index.mjs +463 -595
- package/dist/jest-compat/error-equality.mjs +127 -0
- package/dist/jest-compat/jest-object.mjs +149 -4
- package/dist/jest-compat/node-registry.mjs +233 -58
- package/dist/jest-compat/setup.mjs +28 -4
- package/dist/jest-compat.cjs +227 -52
- package/dist/jest-compat.d.cts +5 -6
- package/dist/jest-compat.d.mts +5 -6
- package/dist/jest-compat.mjs +204 -52
- package/dist/matchers.cjs +1 -2
- package/dist/matchers.d.cts +0 -2
- package/dist/matchers.d.mts +0 -2
- package/dist/matchers.mjs +1 -2
- package/dist/{memory-FYbP0_gg.mjs → memory-Couw0Esx.mjs} +31 -6
- package/dist/native/assets.d.mts +2 -0
- package/dist/native/assets.mjs +34 -0
- package/dist/native/babel-toolchain.mjs +190 -0
- package/dist/native/babel-worker.mjs +47 -0
- package/dist/native/boundary.mjs +23 -8
- package/dist/native/compile-cache.mjs +21 -9
- package/dist/native/coverage-v8.mjs +287 -0
- package/dist/native/esm-interop.mjs +216 -0
- package/dist/native/expo-native-modules.mjs +7 -1
- package/dist/native/globals.mjs +104 -6
- package/dist/native/hooks.mjs +271 -60
- package/dist/native/loader.mjs +378 -20
- package/dist/native/match.d.mts +24 -2
- package/dist/native/match.mjs +117 -12
- package/dist/native/metro-profile-compiler.mjs +2 -31
- package/dist/native/module-reset.mjs +37 -5
- package/dist/native/native-modules.d.mts +2 -3
- package/dist/native/native-modules.mjs +22 -21
- package/dist/native/ownership.d.mts +10 -0
- package/dist/native/ownership.mjs +96 -9
- package/dist/native/registry-compiler.mjs +6 -0
- package/dist/native/registry.mjs +138 -119
- package/dist/native/resident-health.mjs +133 -0
- package/dist/native/resolve.d.mts +6 -0
- package/dist/native/resolve.mjs +100 -9
- package/dist/native/rntl-hooks.mjs +157 -6
- package/dist/native/rntl-text-host.mjs +64 -0
- package/dist/native/runner.mjs +73 -0
- package/dist/native/setup.mjs +96 -70
- package/dist/native/state-manifest.mjs +14 -8
- package/dist/native/transform.d.mts +2 -0
- package/dist/native/transform.mjs +476 -59
- package/dist/native/worker.mjs +65 -36
- package/dist/{pool-DjpOjOf3.mjs → pool-CFSpNfyw.mjs} +37 -11
- package/dist/{preset-map-BlBriTA0.mjs → preset-map-CogjYmSw.mjs} +4 -19
- package/dist/preset-modules.mjs +2 -11
- package/dist/{presets--zrEWQC2.mjs → presets-CXDyg51l.mjs} +65 -82
- package/dist/presets.d.mts +1 -1
- package/dist/presets.mjs +1 -1
- package/dist/report-error.d.mts +20 -0
- package/dist/report-error.mjs +145 -0
- package/dist/rntl-support.d.mts +12 -0
- package/dist/rntl-support.mjs +189 -0
- package/dist/{rolldown-runtime-BhDjJH2R.mjs → rolldown-runtime-D70C1uOS.mjs} +1 -2
- package/dist/serializer.cjs +1 -2
- package/dist/serializer.d.cts +1 -3
- package/dist/serializer.d.mts +1 -3
- package/dist/serializer.mjs +1 -2
- package/dist/setup.mjs +95 -156
- package/dist/{worker-vitest-BGPo0ek6.mjs → worker-vitest-CILPFeRX.mjs} +2 -3
- package/docs/migrating-from-jest.md +76 -12
- package/docs/release-readiness.md +1 -1
- package/package.json +119 -102
- package/CHANGELOG.md +0 -2491
- package/dist/cli.cjs +0 -1951
- package/dist/cli.d.cts +0 -3
- package/dist/ecosystem-D6e1OVOg.mjs +0 -1019
- package/dist/ecosystem-MFwkbnaC.cjs +0 -1099
- package/dist/errors-B3lJK46O.cjs +0 -75
- package/dist/errors-CxoBUfVJ.mjs +0 -64
- package/dist/index-xw43lBlv.d.mts +0 -481
- package/dist/memory-6EPHrJA1.cjs +0 -144
- package/dist/pool-B4yesGhI.cjs +0 -121
- package/dist/preset-map-jSFsNy1Q.cjs +0 -241
- package/dist/preset-modules-BoLkaeEN.cjs +0 -53
- package/dist/preset-modules-CG8-G82P.mjs +0 -36
- package/dist/presets-9f83H0WW.cjs +0 -3939
- package/dist/rolldown-runtime-C0BPl7ul.cjs +0 -43
- package/dist/worker-vitest-BfiQB8ND.cjs +0 -62
- 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 (
|
|
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
|
-
|
|
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.
|
|
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
|
-
>
|
|
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,8 +148,8 @@ 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:
|
|
149
|
-
mocks: {}, //
|
|
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
|
|
@@ -160,11 +163,11 @@ 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[]
|
|
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
|
|
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. |
|
|
168
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
|
|
@@ -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
|
|
|
@@ -285,7 +288,7 @@ resetting the registry's module instances and the app/test module graph for ever
|
|
|
285
288
|
state manifest also restores and verifies timers/Vitest stubs, direct `process.env` changes,
|
|
286
289
|
process and RN listeners, complete global and console property descriptors, known RN state,
|
|
287
290
|
ErrorUtils, Expo runtime state, and plugin boundary mocks. A mutation gate removes each of its
|
|
288
|
-
|
|
291
|
+
restore actions in turn and requires the cross-file isolation suite to fail by name.
|
|
289
292
|
|
|
290
293
|
When hot is enabled, the plugin derives a worker-total memory plan from the lower of host and
|
|
291
294
|
container/cgroup memory. It reserves main-process and replacement headroom, caps automatic
|
|
@@ -314,8 +317,12 @@ reactNative({
|
|
|
314
317
|
});
|
|
315
318
|
```
|
|
316
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
|
+
|
|
317
324
|
Recycling is applied between Vitest scheduler tasks. Current Vitest batches every file into one
|
|
318
|
-
uninterruptible task at `maxWorkers: 1`, so
|
|
325
|
+
uninterruptible task at `maxWorkers: 1`, so `'auto'` keeps per-file isolation there and
|
|
319
326
|
`hotRuntime: true` fails that configuration rather than claim an inert memory bound. Use at least
|
|
320
327
|
two workers for hot mode. If an external scheduler
|
|
321
328
|
already provides a hard boundary, you can deliberately accept the risk with
|
|
@@ -482,7 +489,7 @@ Register a custom native module mock. The module becomes available through both
|
|
|
482
489
|
```ts
|
|
483
490
|
import { mockNativeModule } from "vitest-native/helpers";
|
|
484
491
|
|
|
485
|
-
test("uses a custom native module", () => {
|
|
492
|
+
test("uses a custom native module", async () => {
|
|
486
493
|
mockNativeModule("MyBridge", {
|
|
487
494
|
getValue: vi.fn().mockResolvedValue(42),
|
|
488
495
|
});
|
|
@@ -583,8 +590,9 @@ JavaScript runs for real — `expo` itself, expo-router, React Navigation and Ex
|
|
|
583
590
|
jest-expo: from the package's own `mocks/<Name>.ts` where it ships one, else from Expo's table
|
|
584
591
|
of the native modules (`Device.modelName` is `'mock'`). An optional native module a package
|
|
585
592
|
probes for, and that no installed package defines, is absent, as on a device.
|
|
586
|
-
- **Expo SDK
|
|
587
|
-
|
|
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.
|
|
588
596
|
|
|
589
597
|
Packed Expo SDK 58 and SDK 57 apps are installed from the release tarball and tested in CI: Expo
|
|
590
598
|
module auto-detection and rendering, and expo-router's testing library against file-based `app/`
|
|
@@ -615,30 +623,30 @@ common case it's a config swap:
|
|
|
615
623
|
|
|
616
624
|
Named import, and drop `@vitejs/plugin-react` (vitest-native handles the JSX runtime itself). The
|
|
617
625
|
full walkthrough — install, gotchas, what's the same — is in
|
|
618
|
-
**[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)**.
|
|
619
627
|
|
|
620
628
|
---
|
|
621
629
|
|
|
622
630
|
## Migrating from Jest
|
|
623
631
|
|
|
624
632
|
vitest-native ships a small compat layer that clears the mechanical Jest-API coupling in an existing
|
|
625
|
-
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):
|
|
626
634
|
|
|
627
635
|
```ts
|
|
628
636
|
// vitest.config.mts
|
|
629
637
|
import { reactNative } from "vitest-native";
|
|
630
|
-
import { jestCompatAliases, jestCompatSetup } from "vitest-native/jest-compat";
|
|
638
|
+
import { jestCompatAliases, jestCompatSetup, jestMockTransform } from "vitest-native/jest-compat";
|
|
631
639
|
|
|
632
640
|
export default defineConfig({
|
|
633
|
-
plugins: [reactNative({ engine: "native" })],
|
|
641
|
+
plugins: [reactNative({ engine: "native" }), jestMockTransform()],
|
|
634
642
|
resolve: { alias: { ...jestCompatAliases() } },
|
|
635
643
|
test: { globals: true, setupFiles: [jestCompatSetup] },
|
|
636
644
|
});
|
|
637
645
|
```
|
|
638
646
|
|
|
639
|
-
This is **not** a turnkey drop-in — a real suite still needs a small per-suite cleanup (
|
|
640
|
-
|
|
641
|
-
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)**.
|
|
642
650
|
|
|
643
651
|
---
|
|
644
652
|
|
|
@@ -662,45 +670,42 @@ npm i -D @react-native/babel-preset @babel/core
|
|
|
662
670
|
To silence the notice and stay on mock deliberately, set `reactNative({ engine: 'mock' })`.
|
|
663
671
|
|
|
664
672
|
**`vi.mock('some-rn-library')` doesn't take effect (native engine)**
|
|
665
|
-
Under `engine: 'native'`, React Native and
|
|
666
|
-
|
|
667
|
-
|
|
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:
|
|
668
676
|
|
|
669
677
|
- Use a **[preset](#auto-detect-presets)** if one exists (it shadows the library the way Jest does).
|
|
670
|
-
- For a pure-JS library shipping untranspiled source, add it to the [`transform`](#plugin-options)
|
|
671
|
-
allowlist so the engine strips its Flow/TS as it loads.
|
|
672
678
|
- Or test that boundary on the **mock engine**, where `vi.mock` applies normally.
|
|
673
679
|
|
|
674
680
|
**`Unexpected token` / Flow syntax errors from a third-party library (native engine)**
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
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.
|
|
678
685
|
|
|
679
686
|
**My `babel.config.js` plugin isn't running**
|
|
680
|
-
|
|
681
|
-
apply. Vite 6–7 use esbuild and Vite 8 uses Oxc; the plugin configures the
|
|
682
|
-
|
|
683
|
-
|
|
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)).
|
|
684
695
|
|
|
685
696
|
**Snapshots differ after switching from Jest or the mock engine**
|
|
686
697
|
Real RN computes host props (e.g. `<Text>`'s `accessible`, `allowFontScaling`) that mocks omit, so
|
|
687
|
-
the tree is richer.
|
|
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).
|
|
688
702
|
|
|
689
703
|
**`Worker terminated due to reaching memory limit` / `JS heap out of memory` (large native suites)**
|
|
690
|
-
Every test file that renders real React Native loads a full renderer
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
// vitest.config.ts
|
|
696
|
-
export default defineConfig({
|
|
697
|
-
test: { poolOptions: { threads: { memoryLimit: "512MB" } } },
|
|
698
|
-
});
|
|
699
|
-
```
|
|
700
|
-
|
|
701
|
-
The hot runtime (the default where it can be bounded) also helps: it keeps React Native's precompiled
|
|
702
|
-
factory registry warm, resets its module instances from memory per file, and recycles workers on a
|
|
703
|
-
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)).
|
|
704
709
|
|
|
705
710
|
**`Vitest caught N unhandled errors` in error-boundary tests**
|
|
706
711
|
A test that intentionally throws inside a component (to exercise an error boundary) makes React log
|
|
@@ -961,6 +966,17 @@ reactNative({
|
|
|
961
966
|
|
|
962
967
|
This prints details about which presets were detected, which modules are being mocked, and how imports are resolved. Useful for debugging unexpected behavior.
|
|
963
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
|
+
|
|
964
980
|
---
|
|
965
981
|
|
|
966
982
|
## Support Policy
|
|
@@ -988,11 +1004,11 @@ Every release must pass:
|
|
|
988
1004
|
package export analysis.
|
|
989
1005
|
|
|
990
1006
|
Current React Native edge releases are also tested weekly. See
|
|
991
|
-
[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.
|
|
992
1008
|
|
|
993
1009
|
For what is *promised* rather than what is tested — which exports and options are protected by
|
|
994
1010
|
semver, which are experimental, how the version ranges above may move, and what 1.0 will mean —
|
|
995
|
-
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).
|
|
996
1012
|
|
|
997
1013
|
---
|
|
998
1014
|
|
package/dist/cli.d.mts
CHANGED