vitest-native 0.14.0-rc.8 → 0.14.0-rc.9
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/CHANGELOG.md +24 -8
- package/README.md +15 -12
- package/dist/cli.cjs +41 -14
- package/dist/cli.mjs +41 -14
- package/dist/{index-bZ7AHqLc.d.cts → index-CzQazgp9.d.cts} +5 -5
- package/dist/{index-BSyUeoga.d.mts → index-xw43lBlv.d.mts} +5 -5
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/jest-compat/setup.mjs +6 -0
- package/dist/native/loader.mjs +31 -0
- package/dist/native/runner.mjs +33 -1
- package/dist/native/setup.mjs +9 -7
- package/dist/native/worker.mjs +87 -11
- package/dist/presets.d.mts +1 -1
- package/docs/migrating-from-vitest-react-native.md +1 -1
- package/docs/release-readiness.md +5 -4
- package/docs/versioning.md +1 -1
- package/package.json +8 -7
package/CHANGELOG.md
CHANGED
|
@@ -4,14 +4,20 @@
|
|
|
4
4
|
|
|
5
5
|
### Upgrading from 0.13
|
|
6
6
|
|
|
7
|
-
- **
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
- **
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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'`. Four 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.
|
|
15
21
|
- **Expo path aliases resolve.** In an Expo project on Vite 8, imports through tsconfig `paths` (the
|
|
16
22
|
template's `@/…`) now resolve as Metro resolves them; a `vite-tsconfig-paths` plugin or a hand-written
|
|
17
23
|
alias for them can go.
|
|
@@ -69,6 +75,8 @@
|
|
|
69
75
|
|
|
70
76
|
### Minor Changes
|
|
71
77
|
|
|
78
|
+
- 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.
|
|
79
|
+
|
|
72
80
|
- 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.
|
|
73
81
|
|
|
74
82
|
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.
|
|
@@ -222,6 +230,14 @@
|
|
|
222
230
|
|
|
223
231
|
### Patch Changes
|
|
224
232
|
|
|
233
|
+
- 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.
|
|
234
|
+
|
|
235
|
+
- 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.
|
|
236
|
+
|
|
237
|
+
- 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.
|
|
238
|
+
|
|
239
|
+
- 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.
|
|
240
|
+
|
|
225
241
|
- 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.
|
|
226
242
|
|
|
227
243
|
- 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.
|
package/README.md
CHANGED
|
@@ -150,7 +150,7 @@ export default defineConfig({
|
|
|
150
150
|
diagnostics: false, // Enable verbose logging
|
|
151
151
|
assetExts: [".lottie"], // Additional asset extensions to stub
|
|
152
152
|
transform: [], // Extra native-engine packages to Flow/TS transform
|
|
153
|
-
hotRuntime:
|
|
153
|
+
hotRuntime: false, // false (default) | 'auto' | true | HotRuntimeOptions
|
|
154
154
|
}),
|
|
155
155
|
],
|
|
156
156
|
});
|
|
@@ -165,7 +165,7 @@ export default defineConfig({
|
|
|
165
165
|
| `diagnostics` | `boolean` | `false` | Log plugin activity to the console for debugging. |
|
|
166
166
|
| `assetExts` | `string[]` | `[]` | Additional file extensions to stub as asset imports (beyond the built-in set). |
|
|
167
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` | `
|
|
168
|
+
| `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
169
|
|
|
170
170
|
### Experimental Metro configuration
|
|
171
171
|
|
|
@@ -242,9 +242,11 @@ the cross-check/fidelity harnesses in the repository's `bench/` directory.
|
|
|
242
242
|
|
|
243
243
|
#### Hot runtime
|
|
244
244
|
|
|
245
|
-
Vitest's default isolation gives each test file a fresh worker, so React Native
|
|
246
|
-
|
|
247
|
-
modules per file whenever that can be done safely
|
|
245
|
+
Vitest's default isolation gives each test file a fresh worker, so React Native reloads for every
|
|
246
|
+
file; that is the default (`hotRuntime: false`), as in 0.13.0. With `hotRuntime: 'auto'` the native
|
|
247
|
+
engine instead reuses workers and resets modules per file whenever that can be done safely. It has
|
|
248
|
+
known differences from per-file isolation, listed under "A test passes on its own but fails when
|
|
249
|
+
run with other files" in the troubleshooting guide.
|
|
248
250
|
|
|
249
251
|
`'auto'` selects persistent workers when the current scheduler provides recyclable task boundaries,
|
|
250
252
|
the host/container memory plan admits at least two workers, no other pool was explicitly
|
|
@@ -259,8 +261,8 @@ jest-compat surface — `jest.mock` in its forms, runtime mocks, spies, timers,
|
|
|
259
261
|
Library cleanup — has its own cross-file isolation gate under the hot runtime. The decision runs
|
|
260
262
|
after other Vite config hooks, so a pool contributed by a later plugin is included rather than
|
|
261
263
|
producing a mixed runtime. When it falls
|
|
262
|
-
back to per-file isolation it
|
|
263
|
-
explicitly
|
|
264
|
+
back to per-file isolation it prints the reason. Per-file isolation, the default, can also be set
|
|
265
|
+
explicitly:
|
|
264
266
|
|
|
265
267
|
```ts
|
|
266
268
|
reactNative({
|
|
@@ -971,7 +973,7 @@ that API.
|
|
|
971
973
|
|
|
972
974
|
Every release must pass:
|
|
973
975
|
|
|
974
|
-
- Linux on Node
|
|
976
|
+
- Linux on Node 22.13 (with RNTL 12, 13 and 14) and 24, plus macOS and Windows on Node 22.13.
|
|
975
977
|
- The mock, native iOS, native Android, hot-runtime, isolation, and 100-file soak suites.
|
|
976
978
|
- React Native 0.81–0.88 against both locked and newest-supported Vitest, plus the Vitest 4 floor
|
|
977
979
|
on 0.81 and 0.88.
|
|
@@ -1001,14 +1003,15 @@ see [versioning and stability](docs/versioning.md).
|
|
|
1001
1003
|
| `react` | >= 18; use RN's matching React version |
|
|
1002
1004
|
| `vite` | ^6.4.2, ^7.3.2, or ^8.0.5 |
|
|
1003
1005
|
| `vitest` | 4.x or 5.x |
|
|
1004
|
-
| `node` |
|
|
1006
|
+
| `node` | 22.13+ on Node 22, or 24.3+ |
|
|
1005
1007
|
| `react-native` (native engine) | 0.81–0.88 validated |
|
|
1006
1008
|
| `@react-native/babel-preset` (native engine) | Match the installed React Native minor |
|
|
1007
1009
|
| `@testing-library/react-native` (optional) | 12.x, 13.x, or 14.x |
|
|
1008
1010
|
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1011
|
+
Node 20 reached end of life in April 2026. Node 22.13 is the first Node 22 that both RNTL 14 and the
|
|
1012
|
+
engine's CommonJS entry points (`require(esm)`) support. On Node 24.0–24.2, `jest.mock`,
|
|
1013
|
+
`jest.isolateModules` and `jest.resetModules` do not reach modules Node loads, with either loader.
|
|
1014
|
+
Node 23 is past its end of life. RNTL 14 uses async rendering APIs.
|
|
1012
1015
|
|
|
1013
1016
|
---
|
|
1014
1017
|
|
package/dist/cli.cjs
CHANGED
|
@@ -350,20 +350,49 @@ function packageVersion(root, name) {
|
|
|
350
350
|
}
|
|
351
351
|
}
|
|
352
352
|
/**
|
|
353
|
-
* The supported Node
|
|
354
|
-
*
|
|
355
|
-
*
|
|
353
|
+
* The supported Node versions, as this package's own `engines.node` states them.
|
|
354
|
+
* Single source: the manifest is what a package manager enforces at install time, so a
|
|
355
|
+
* diagnostic must not carry its own copy of the range.
|
|
356
356
|
*/
|
|
357
|
-
function
|
|
358
|
-
const fallback =
|
|
357
|
+
function nodeRange() {
|
|
358
|
+
const fallback = ">=22.13.0 <23 || >=24.3.0";
|
|
359
359
|
try {
|
|
360
|
-
|
|
361
|
-
const match = /(\d+)\.(\d+)/.exec(manifest.engines?.node ?? "");
|
|
362
|
-
return match ? [Number(match[1]), Number(match[2])] : fallback;
|
|
360
|
+
return JSON.parse(node_fs.default.readFileSync(new URL("../../package.json", require("url").pathToFileURL(__filename).href), "utf8")).engines?.node?.trim() || fallback;
|
|
363
361
|
} catch {
|
|
364
362
|
return fallback;
|
|
365
363
|
}
|
|
366
364
|
}
|
|
365
|
+
const versionParts = (version) => {
|
|
366
|
+
const [major = 0, minor = 0, patch = 0] = version.replace(/^v/, "").split(/[.-]/).map((part) => Number.parseInt(part, 10) || 0);
|
|
367
|
+
return [
|
|
368
|
+
major,
|
|
369
|
+
minor,
|
|
370
|
+
patch
|
|
371
|
+
];
|
|
372
|
+
};
|
|
373
|
+
const compareVersions = (a, b) => {
|
|
374
|
+
const [x, y] = [versionParts(a), versionParts(b)];
|
|
375
|
+
return x[0] - y[0] || x[1] - y[1] || x[2] - y[2];
|
|
376
|
+
};
|
|
377
|
+
/**
|
|
378
|
+
* Whether `version` is in `range`: `||`-separated sets of space-separated comparators
|
|
379
|
+
* (`>=`, `>`, `<=`, `<`, `=`), the forms `engines.node` uses. A version missing parts
|
|
380
|
+
* reads them as 0 (`<23` is `<23.0.0`).
|
|
381
|
+
*/
|
|
382
|
+
function satisfiesNodeRange(version, range) {
|
|
383
|
+
return range.split("||").some((set) => set.trim().split(/\s+/).filter(Boolean).every((comparator) => {
|
|
384
|
+
const match = /^(>=|<=|>|<|=)?\s*v?(\d[\w.-]*)$/.exec(comparator);
|
|
385
|
+
if (!match) return false;
|
|
386
|
+
const order = compareVersions(version, match[2]);
|
|
387
|
+
switch (match[1] ?? "=") {
|
|
388
|
+
case ">=": return order >= 0;
|
|
389
|
+
case ">": return order > 0;
|
|
390
|
+
case "<=": return order <= 0;
|
|
391
|
+
case "<": return order < 0;
|
|
392
|
+
default: return order === 0;
|
|
393
|
+
}
|
|
394
|
+
}));
|
|
395
|
+
}
|
|
367
396
|
/**
|
|
368
397
|
* In Vitest's own precedence order: a `vitest.config.*` wins, and `vite.config.*`
|
|
369
398
|
* is used when there is none.
|
|
@@ -507,11 +536,9 @@ function runDoctor(root, nodeVersion = process.versions.node) {
|
|
|
507
536
|
const rootFor = (name) => resolvesHere(name) || configRoot === root ? root : configRoot;
|
|
508
537
|
lines.push(`vitest-native doctor — ${root}`);
|
|
509
538
|
lines.push("", "Runtime");
|
|
510
|
-
const
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
if (nodeMajorMinor[0] > floorMajor || nodeMajorMinor[0] === floorMajor && nodeMajorMinor[1] >= floorMinor) pass(`Node ${nodeVersion} (floor: ${floorText})`);
|
|
514
|
-
else fail(`Node ${nodeVersion} — vitest-native requires Node >= ${floorText}.`);
|
|
539
|
+
const range = nodeRange();
|
|
540
|
+
if (satisfiesNodeRange(nodeVersion, range)) pass(`Node ${nodeVersion} (supported: ${range})`);
|
|
541
|
+
else fail(`Node ${nodeVersion} — vitest-native supports Node ${range}.`);
|
|
515
542
|
lines.push("", "Peer dependencies");
|
|
516
543
|
for (const { name, minimum, maximumMajor, minimumByMajor, optional } of require_ecosystem.PEER_REQUIREMENTS) {
|
|
517
544
|
if (optional) continue;
|
|
@@ -559,7 +586,7 @@ function runDoctor(root, nodeVersion = process.versions.node) {
|
|
|
559
586
|
const rntlReq = require_ecosystem.PEER_REQUIREMENTS.find((r) => r.name === "@testing-library/react-native");
|
|
560
587
|
const rntlError = rntlReq && require_ecosystem.validatePeerDependency(rntlReq.name, rntlReq.minimum, root, rntlReq.maximumMajor, rntlReq.minimumByMajor);
|
|
561
588
|
if (rntlError) warn(rntlError);
|
|
562
|
-
else if (rntlMajor >= 14 && (
|
|
589
|
+
else if (rntlMajor >= 14 && !satisfiesNodeRange(nodeVersion, ">=22.13.0")) fail(`@testing-library/react-native ${rntl} requires Node >= 22.13, but this is Node ${nodeVersion}. Upgrade Node or pin @testing-library/react-native@13.`);
|
|
563
590
|
else if (rntlMajor >= 14 && !packageVersion(rootFor("test-renderer"), "test-renderer")) fail(`@testing-library/react-native ${rntl} requires the 'test-renderer' package, which is not installed. Every render() will fail with "Cannot find module 'test-renderer'". Install it:\n\n npm install -D test-renderer\n`);
|
|
564
591
|
else pass(`@testing-library/react-native ${rntl}${rntlMajor >= 14 ? " (14 is async: await render/fireEvent)" : ""}`);
|
|
565
592
|
}
|
package/dist/cli.mjs
CHANGED
|
@@ -346,20 +346,49 @@ function packageVersion(root, name) {
|
|
|
346
346
|
}
|
|
347
347
|
}
|
|
348
348
|
/**
|
|
349
|
-
* The supported Node
|
|
350
|
-
*
|
|
351
|
-
*
|
|
349
|
+
* The supported Node versions, as this package's own `engines.node` states them.
|
|
350
|
+
* Single source: the manifest is what a package manager enforces at install time, so a
|
|
351
|
+
* diagnostic must not carry its own copy of the range.
|
|
352
352
|
*/
|
|
353
|
-
function
|
|
354
|
-
const fallback =
|
|
353
|
+
function nodeRange() {
|
|
354
|
+
const fallback = ">=22.13.0 <23 || >=24.3.0";
|
|
355
355
|
try {
|
|
356
|
-
|
|
357
|
-
const match = /(\d+)\.(\d+)/.exec(manifest.engines?.node ?? "");
|
|
358
|
-
return match ? [Number(match[1]), Number(match[2])] : fallback;
|
|
356
|
+
return JSON.parse(fs.readFileSync(new URL("../../package.json", import.meta.url), "utf8")).engines?.node?.trim() || fallback;
|
|
359
357
|
} catch {
|
|
360
358
|
return fallback;
|
|
361
359
|
}
|
|
362
360
|
}
|
|
361
|
+
const versionParts = (version) => {
|
|
362
|
+
const [major = 0, minor = 0, patch = 0] = version.replace(/^v/, "").split(/[.-]/).map((part) => Number.parseInt(part, 10) || 0);
|
|
363
|
+
return [
|
|
364
|
+
major,
|
|
365
|
+
minor,
|
|
366
|
+
patch
|
|
367
|
+
];
|
|
368
|
+
};
|
|
369
|
+
const compareVersions = (a, b) => {
|
|
370
|
+
const [x, y] = [versionParts(a), versionParts(b)];
|
|
371
|
+
return x[0] - y[0] || x[1] - y[1] || x[2] - y[2];
|
|
372
|
+
};
|
|
373
|
+
/**
|
|
374
|
+
* Whether `version` is in `range`: `||`-separated sets of space-separated comparators
|
|
375
|
+
* (`>=`, `>`, `<=`, `<`, `=`), the forms `engines.node` uses. A version missing parts
|
|
376
|
+
* reads them as 0 (`<23` is `<23.0.0`).
|
|
377
|
+
*/
|
|
378
|
+
function satisfiesNodeRange(version, range) {
|
|
379
|
+
return range.split("||").some((set) => set.trim().split(/\s+/).filter(Boolean).every((comparator) => {
|
|
380
|
+
const match = /^(>=|<=|>|<|=)?\s*v?(\d[\w.-]*)$/.exec(comparator);
|
|
381
|
+
if (!match) return false;
|
|
382
|
+
const order = compareVersions(version, match[2]);
|
|
383
|
+
switch (match[1] ?? "=") {
|
|
384
|
+
case ">=": return order >= 0;
|
|
385
|
+
case ">": return order > 0;
|
|
386
|
+
case "<=": return order <= 0;
|
|
387
|
+
case "<": return order < 0;
|
|
388
|
+
default: return order === 0;
|
|
389
|
+
}
|
|
390
|
+
}));
|
|
391
|
+
}
|
|
363
392
|
/**
|
|
364
393
|
* In Vitest's own precedence order: a `vitest.config.*` wins, and `vite.config.*`
|
|
365
394
|
* is used when there is none.
|
|
@@ -503,11 +532,9 @@ function runDoctor(root, nodeVersion = process.versions.node) {
|
|
|
503
532
|
const rootFor = (name) => resolvesHere(name) || configRoot === root ? root : configRoot;
|
|
504
533
|
lines.push(`vitest-native doctor — ${root}`);
|
|
505
534
|
lines.push("", "Runtime");
|
|
506
|
-
const
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
if (nodeMajorMinor[0] > floorMajor || nodeMajorMinor[0] === floorMajor && nodeMajorMinor[1] >= floorMinor) pass(`Node ${nodeVersion} (floor: ${floorText})`);
|
|
510
|
-
else fail(`Node ${nodeVersion} — vitest-native requires Node >= ${floorText}.`);
|
|
535
|
+
const range = nodeRange();
|
|
536
|
+
if (satisfiesNodeRange(nodeVersion, range)) pass(`Node ${nodeVersion} (supported: ${range})`);
|
|
537
|
+
else fail(`Node ${nodeVersion} — vitest-native supports Node ${range}.`);
|
|
511
538
|
lines.push("", "Peer dependencies");
|
|
512
539
|
for (const { name, minimum, maximumMajor, minimumByMajor, optional } of PEER_REQUIREMENTS) {
|
|
513
540
|
if (optional) continue;
|
|
@@ -555,7 +582,7 @@ function runDoctor(root, nodeVersion = process.versions.node) {
|
|
|
555
582
|
const rntlReq = PEER_REQUIREMENTS.find((r) => r.name === "@testing-library/react-native");
|
|
556
583
|
const rntlError = rntlReq && validatePeerDependency(rntlReq.name, rntlReq.minimum, root, rntlReq.maximumMajor, rntlReq.minimumByMajor);
|
|
557
584
|
if (rntlError) warn(rntlError);
|
|
558
|
-
else if (rntlMajor >= 14 && (
|
|
585
|
+
else if (rntlMajor >= 14 && !satisfiesNodeRange(nodeVersion, ">=22.13.0")) fail(`@testing-library/react-native ${rntl} requires Node >= 22.13, but this is Node ${nodeVersion}. Upgrade Node or pin @testing-library/react-native@13.`);
|
|
559
586
|
else if (rntlMajor >= 14 && !packageVersion(rootFor("test-renderer"), "test-renderer")) fail(`@testing-library/react-native ${rntl} requires the 'test-renderer' package, which is not installed. Every render() will fail with "Cannot find module 'test-renderer'". Install it:\n\n npm install -D test-renderer\n`);
|
|
560
587
|
else pass(`@testing-library/react-native ${rntl}${rntlMajor >= 14 ? " (14 is async: await render/fireEvent)" : ""}`);
|
|
561
588
|
}
|
|
@@ -389,12 +389,12 @@ interface VitestNativeOptions {
|
|
|
389
389
|
*
|
|
390
390
|
* `'auto'` selects the bounded hot runtime when the configuration has recyclable
|
|
391
391
|
* task boundaries (enough memory headroom for at least two workers) and no
|
|
392
|
-
* explicit custom pool; otherwise the run keeps per-file isolation
|
|
393
|
-
*
|
|
394
|
-
* back quietly (`diagnostics: true` shows the reason).
|
|
392
|
+
* explicit custom pool; otherwise the run keeps per-file isolation and prints the
|
|
393
|
+
* reason for falling back.
|
|
395
394
|
*
|
|
396
|
-
* Default: `
|
|
397
|
-
* Native reloaded per file.
|
|
395
|
+
* Default: `false`, as in 0.13.0: each file runs in a fresh worker, with React
|
|
396
|
+
* Native reloaded per file. The hot runtime has known differences from per-file
|
|
397
|
+
* isolation, listed in the troubleshooting guide.
|
|
398
398
|
*/
|
|
399
399
|
hotRuntime?: boolean | "auto" | {
|
|
400
400
|
recycleAfterFiles?: number;
|
|
@@ -388,12 +388,12 @@ interface VitestNativeOptions {
|
|
|
388
388
|
*
|
|
389
389
|
* `'auto'` selects the bounded hot runtime when the configuration has recyclable
|
|
390
390
|
* task boundaries (enough memory headroom for at least two workers) and no
|
|
391
|
-
* explicit custom pool; otherwise the run keeps per-file isolation
|
|
392
|
-
*
|
|
393
|
-
* back quietly (`diagnostics: true` shows the reason).
|
|
391
|
+
* explicit custom pool; otherwise the run keeps per-file isolation and prints the
|
|
392
|
+
* reason for falling back.
|
|
394
393
|
*
|
|
395
|
-
* Default: `
|
|
396
|
-
* Native reloaded per file.
|
|
394
|
+
* Default: `false`, as in 0.13.0: each file runs in a fresh worker, with React
|
|
395
|
+
* Native reloaded per file. The hot runtime has known differences from per-file
|
|
396
|
+
* isolation, listed in the troubleshooting guide.
|
|
397
397
|
*/
|
|
398
398
|
hotRuntime?: boolean | "auto" | {
|
|
399
399
|
recycleAfterFiles?: number;
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as VitestNativeOptions, S as ReactNativeMock, t as index_d_exports, x as Preset } from "./index-
|
|
1
|
+
import { C as VitestNativeOptions, S as ReactNativeMock, t as index_d_exports, x as Preset } from "./index-xw43lBlv.mjs";
|
|
2
2
|
import { Plugin } from "vite";
|
|
3
3
|
//#region src/plugin.d.ts
|
|
4
4
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -1482,7 +1482,7 @@ function reactNative(options) {
|
|
|
1482
1482
|
const requestedEngine = options?.engine ?? "auto";
|
|
1483
1483
|
const { include: transformPkgs, exclude: neverTransform } = normalizeTransformOption(options?.transform);
|
|
1484
1484
|
const hotRuntimeExplicit = options?.hotRuntime !== void 0;
|
|
1485
|
-
const hotRuntimeOpt = options?.hotRuntime ??
|
|
1485
|
+
const hotRuntimeOpt = options?.hotRuntime ?? false;
|
|
1486
1486
|
const hotRuntimeRequested = hotRuntimeOpt !== false;
|
|
1487
1487
|
const hotRuntimeAuto = hotRuntimeOpt === "auto";
|
|
1488
1488
|
const hotRecycle = typeof hotRuntimeOpt === "object" ? hotRuntimeOpt : {};
|
|
@@ -247,6 +247,12 @@ if (typeof globalThis.__vnInteropMock !== "function") globalThis.__vnInteropMock
|
|
|
247
247
|
// Hot runtime: cleared at the file boundary and verified empty (state-manifest.mjs).
|
|
248
248
|
globalThis.__vitest_native_register_state?.({
|
|
249
249
|
id: NODE_MOCKS_STATE_ID,
|
|
250
|
+
// Before the value-based React Native restores. They reach their module through
|
|
251
|
+
// Node's loader (react-native's index getters `require` it), and while the
|
|
252
|
+
// previous file's `jest.mock` is still registered that load returns the mock:
|
|
253
|
+
// `jest.mock('react-native/Libraries/Utilities/Appearance', () => null)` made the
|
|
254
|
+
// Appearance restore read `null.setColorScheme` and fail the NEXT file's reset.
|
|
255
|
+
restoreOrder: -100,
|
|
250
256
|
capture: () => null,
|
|
251
257
|
restore: () => registry.clear(),
|
|
252
258
|
verify: () => {
|
package/dist/native/loader.mjs
CHANGED
|
@@ -332,6 +332,37 @@ export async function resolve(specifier, context, nextResolve) {
|
|
|
332
332
|
return resolveAfter(resolved, context);
|
|
333
333
|
}
|
|
334
334
|
|
|
335
|
+
/**
|
|
336
|
+
* Whether Node's in-thread hooks (module.registerHooks) carry the engine on `version`:
|
|
337
|
+
* Node 22 from 22.22.3, Node 24 from 24.12.0, and Node 26 on. Measured across Node minors
|
|
338
|
+
* and patches, the releases before those that have the hooks fail with them in-thread
|
|
339
|
+
* while the threaded hooks (module.register) pass: expo-router's elements fail to load
|
|
340
|
+
* ("request for 'node:module' is from a module not been linked", through 22.22.2 and
|
|
341
|
+
* 24.11), and the hot runtime's CommonJS lookup reset stops mattering, so its mutation
|
|
342
|
+
* control passes when it must fail. Node 25 was not measured, and Node 23 is past its
|
|
343
|
+
* end of life, so both keep the threaded hooks.
|
|
344
|
+
*/
|
|
345
|
+
export function inThreadHooksReliable(version) {
|
|
346
|
+
const [major, minor, patch] = version.replace(/^v/, "").split(".").map(Number);
|
|
347
|
+
if (major === 22) return minor > 22 || (minor === 22 && patch >= 3);
|
|
348
|
+
if (major === 24) return minor >= 12;
|
|
349
|
+
return major >= 26;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* Whether an in-thread hook call (module.registerHooks) comes from `require()` rather
|
|
354
|
+
* than `import`. An import's context always lists its conditions, "import" among them.
|
|
355
|
+
* A require's lists "require" from Node 22.19 and 24.6, but is an empty object `{}` on
|
|
356
|
+
* 22.15–22.18 and 24.0–24.4 (measured on each), so anything but a list with "import" in
|
|
357
|
+
* it is a require. Read as an import there, every require reached this loader, which
|
|
358
|
+
* compiled Babel's own files as Babel loaded them ("Reentrant preset detected").
|
|
359
|
+
*/
|
|
360
|
+
export function isRequireContext(context) {
|
|
361
|
+
const conditions = context?.conditions;
|
|
362
|
+
if (!Array.isArray(conditions)) return true;
|
|
363
|
+
return !conditions.includes("import");
|
|
364
|
+
}
|
|
365
|
+
|
|
335
366
|
export function resolveSync(specifier, context, nextResolve) {
|
|
336
367
|
const before = resolveBefore(specifier, context);
|
|
337
368
|
if (before.done) return before.done;
|
package/dist/native/runner.mjs
CHANGED
|
@@ -44,11 +44,43 @@ export default class NativeHotRunner extends TestRunner {
|
|
|
44
44
|
// Vitest passes an array because the hook is shaped for a batch, but its per-file
|
|
45
45
|
// loop invokes the run through startTests([file]) one file at a time, which is the
|
|
46
46
|
// cadence the reset needs.
|
|
47
|
+
//
|
|
48
|
+
// A reset that throws must fail THIS file, not vanish it. Vitest calls the hook
|
|
49
|
+
// outside the per-file try/catch that turns a collection error into a failed file,
|
|
50
|
+
// so an error thrown from here rejects startTests, the file is never collected, and
|
|
51
|
+
// it is missing from every report: Vitest records only a run-level "Test Run Error",
|
|
52
|
+
// which the JSON reporter does not carry at all. The error is held and thrown from
|
|
53
|
+
// the file's first import instead, which IS inside that try/catch, so the file is
|
|
54
|
+
// reported failed with the restoration error naming the cause.
|
|
47
55
|
async onBeforeCollect(paths) {
|
|
48
|
-
|
|
56
|
+
this.vitestNativeFile = paths[0];
|
|
57
|
+
try {
|
|
58
|
+
globalThis.__vitest_native_reset_module_runner?.();
|
|
59
|
+
} catch (error) {
|
|
60
|
+
this.vitestNativeResetError = error;
|
|
61
|
+
}
|
|
49
62
|
return super.onBeforeCollect?.(paths);
|
|
50
63
|
}
|
|
51
64
|
|
|
65
|
+
importFile(filepath, source) {
|
|
66
|
+
const resetError = this.vitestNativeResetError;
|
|
67
|
+
if (resetError) {
|
|
68
|
+
this.vitestNativeResetError = undefined;
|
|
69
|
+
throw resetError;
|
|
70
|
+
}
|
|
71
|
+
// Set by worker.mjs only while it reports files a rejected task never reached.
|
|
72
|
+
const lostFileError = globalThis.__vitest_native_lost_file_error;
|
|
73
|
+
if (lostFileError) throw lostFileError(this.vitestNativeFile ?? filepath);
|
|
74
|
+
return super.importFile(filepath, source);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Every file that reaches this hook is reported to the main thread. The worker
|
|
78
|
+
// entry compares this against the files it was asked to run (worker.mjs).
|
|
79
|
+
async onCollected(files) {
|
|
80
|
+
for (const file of files) globalThis.__vitest_native_file_collected?.(file.filepath);
|
|
81
|
+
return super.onCollected?.(files);
|
|
82
|
+
}
|
|
83
|
+
|
|
52
84
|
async onBeforeRunFiles(files) {
|
|
53
85
|
globalThis.__vitest_native_hot_bless?.();
|
|
54
86
|
return super.onBeforeRunFiles?.(files);
|
package/dist/native/setup.mjs
CHANGED
|
@@ -208,25 +208,27 @@ if (typeof globalThis.expect === "undefined") {
|
|
|
208
208
|
* of an externalized module blocks this thread on a synchronous cross-thread request
|
|
209
209
|
* (Node's makeSyncRequest). Profiled on a 105-file production suite, that wait was 18%
|
|
210
210
|
* of all worker CPU time. `module.registerHooks()` (Node 22.15+, 23.5+) runs the same
|
|
211
|
-
* hooks synchronously on this thread instead, so it is used
|
|
212
|
-
*
|
|
211
|
+
* hooks synchronously on this thread instead, so it is used where Node's in-thread hooks
|
|
212
|
+
* are reliable (inThreadHooksReliable in loader.mjs); every other Node keeps
|
|
213
|
+
* `register()`. VITEST_NATIVE_LOADER_THREAD=1 forces the threaded hooks.
|
|
213
214
|
*
|
|
214
215
|
* In-thread hooks also run for `require()`. CommonJS is already handled by the require
|
|
215
216
|
* hooks (hooks.mjs), so those calls go straight to Node's default resolution, as they
|
|
216
217
|
* did when only `import` reached the threaded loader.
|
|
217
218
|
*/
|
|
218
219
|
function installLoaderHooks(data) {
|
|
219
|
-
if (
|
|
220
|
+
if (
|
|
221
|
+
typeof registerHooks !== "function" ||
|
|
222
|
+
process.env.VITEST_NATIVE_LOADER_THREAD === "1" ||
|
|
223
|
+
!nativeLoader.inThreadHooksReliable(process.versions.node)
|
|
224
|
+
) {
|
|
220
225
|
register("./loader.mjs", import.meta.url, { data });
|
|
221
226
|
globalThis.__vitest_native_loader_mode = "thread";
|
|
222
227
|
return;
|
|
223
228
|
}
|
|
224
229
|
nativeLoader.initialize(data);
|
|
225
230
|
globalThis.__vitest_native_loader_mode = "in-thread";
|
|
226
|
-
const fromRequire =
|
|
227
|
-
Array.isArray(context?.conditions) &&
|
|
228
|
-
context.conditions.includes("require") &&
|
|
229
|
-
!context.conditions.includes("import");
|
|
231
|
+
const fromRequire = nativeLoader.isRequireContext;
|
|
230
232
|
registerHooks({
|
|
231
233
|
resolve: (specifier, context, nextResolve) =>
|
|
232
234
|
fromRequire(context)
|
package/dist/native/worker.mjs
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
// file, hot RN graph.
|
|
12
12
|
import { createRequire } from "node:module";
|
|
13
13
|
import path from "node:path";
|
|
14
|
+
import { fileURLToPath } from "node:url";
|
|
14
15
|
import { isMainThread, parentPort, threadId } from "node:worker_threads";
|
|
15
16
|
import { init, runBaseTests, setupEnvironment } from "vitest/worker";
|
|
16
17
|
import { installGlobals, installErrorUtils } from "./globals.mjs";
|
|
@@ -191,25 +192,100 @@ function clearPendingMocks(mocker) {
|
|
|
191
192
|
}
|
|
192
193
|
|
|
193
194
|
globalThis.__vitest_native_reset_module_runner = () => {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
195
|
+
try {
|
|
196
|
+
// The previous file's realm state (fake timers, stubbed globals, listeners) must be
|
|
197
|
+
// gone before ANY setup file of the next one runs. It used to be reset from this
|
|
198
|
+
// package's setup file, which Vitest runs after the user's own: a user setup that
|
|
199
|
+
// installs fake timers then found the previous file's still installed.
|
|
200
|
+
globalThis.__vitest_native_hot_reset?.();
|
|
201
|
+
} finally {
|
|
202
|
+
// A failed realm restore is reported by the runner as this file's failure; the
|
|
203
|
+
// previous file's modules and mocks are still dropped, so what follows does not
|
|
204
|
+
// inherit them on top of it.
|
|
205
|
+
if (moduleRunner) {
|
|
206
|
+
moduleRunner.mocker?.reset();
|
|
207
|
+
clearPendingMocks(moduleRunner.mocker);
|
|
208
|
+
resetEvaluatedModules(moduleRunner.evaluatedModules.idToModuleMap);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
203
211
|
};
|
|
204
212
|
|
|
213
|
+
// --- Every scheduled file gets a result ---
|
|
214
|
+
//
|
|
215
|
+
// Vitest runs a task's files in one loop, and anything that throws out of that loop
|
|
216
|
+
// (rather than inside a file's own collection or tests) rejects the whole task. The
|
|
217
|
+
// main thread then records one run-level "Test Run Error" and every file of the task
|
|
218
|
+
// that had not been collected yet is simply absent: no file entry, no failed test, and
|
|
219
|
+
// nothing at all in the JSON reporter, which does not carry run-level errors. In
|
|
220
|
+
// single-worker mode a task is the whole suite. The hot runtime adds steps to that loop
|
|
221
|
+
// (the per-file reset and bless in runner.mjs), so it owns making that loss loud.
|
|
222
|
+
//
|
|
223
|
+
// The runner reports each file it hands to the main thread. When a task rejects, the
|
|
224
|
+
// files it never reached are run again through Vitest's own path with their import
|
|
225
|
+
// replaced by an error that names the cause, so each one is reported as a failed file
|
|
226
|
+
// by every reporter. The original error is rethrown too, so the run still fails with
|
|
227
|
+
// it. Only our runner reports collection, so a project that replaced it is left alone.
|
|
228
|
+
const ownRunner = path.join(path.dirname(fileURLToPath(import.meta.url)), "runner.mjs");
|
|
229
|
+
const collected = new Set();
|
|
230
|
+
globalThis.__vitest_native_file_collected = (filepath) => collected.add(filepath);
|
|
231
|
+
|
|
232
|
+
function usesOwnRunner(state) {
|
|
233
|
+
const runner = state.ctx?.config?.runner;
|
|
234
|
+
return typeof runner === "string" && path.resolve(runner) === ownRunner;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
async function runAccounted(method, state, traces) {
|
|
238
|
+
collected.clear();
|
|
239
|
+
try {
|
|
240
|
+
await runBaseTests(method, state, traces);
|
|
241
|
+
} catch (error) {
|
|
242
|
+
const lost = usesOwnRunner(state)
|
|
243
|
+
? state.ctx.files.filter((file) => !collected.has(file.filepath))
|
|
244
|
+
: [];
|
|
245
|
+
if (lost.length > 0) await reportLostFiles(method, state, traces, lost, error);
|
|
246
|
+
throw error;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
async function reportLostFiles(method, state, traces, lost, cause) {
|
|
251
|
+
const reason = cause instanceof Error ? cause.message : String(cause);
|
|
252
|
+
globalThis.__vitest_native_lost_file_error = (filepath) =>
|
|
253
|
+
new VitestNativeError(
|
|
254
|
+
"HOT_FILE_NOT_RUN",
|
|
255
|
+
`hotRuntime: ${filepath} was scheduled on this worker but never ran, because an ` +
|
|
256
|
+
`earlier step of the same task threw outside any test file: ${reason}`,
|
|
257
|
+
{ cause },
|
|
258
|
+
);
|
|
259
|
+
try {
|
|
260
|
+
await runBaseTests(
|
|
261
|
+
method,
|
|
262
|
+
{ ...state, ctx: { ...state.ctx, files: lost, invalidates: [] } },
|
|
263
|
+
traces,
|
|
264
|
+
);
|
|
265
|
+
} catch {
|
|
266
|
+
// The rethrown original error still fails the run; the message names every file.
|
|
267
|
+
} finally {
|
|
268
|
+
globalThis.__vitest_native_lost_file_error = undefined;
|
|
269
|
+
}
|
|
270
|
+
const missing = lost.filter((file) => !collected.has(file.filepath));
|
|
271
|
+
if (missing.length > 0) {
|
|
272
|
+
throw new VitestNativeError(
|
|
273
|
+
"HOT_FILE_NOT_RUN",
|
|
274
|
+
`hotRuntime: ${missing.length} scheduled test file(s) produced no result: ` +
|
|
275
|
+
`${missing.map((file) => file.filepath).join(", ")}. Cause: ${reason}`,
|
|
276
|
+
{ cause },
|
|
277
|
+
);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
205
281
|
init({
|
|
206
282
|
// oxlint-disable-next-line unicorn/require-post-message-target-origin -- worker_threads MessagePort, not window
|
|
207
283
|
post: (msg) => parentPort.postMessage(msg),
|
|
208
284
|
on: (callback) => parentPort.on("message", callback),
|
|
209
285
|
off: (callback) => parentPort.off("message", callback),
|
|
210
286
|
teardown: () => parentPort.removeAllListeners("message"),
|
|
211
|
-
runTests: (state, traces) =>
|
|
212
|
-
collectTests: (state, traces) =>
|
|
287
|
+
runTests: (state, traces) => runAccounted("run", state, traces),
|
|
288
|
+
collectTests: (state, traces) => runAccounted("collect", state, traces),
|
|
213
289
|
onModuleRunner: (runner) => {
|
|
214
290
|
moduleRunner = runner;
|
|
215
291
|
registerRntlHooksOnImport(runner.evaluator);
|
package/dist/presets.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as navigation, a as keyboardController, b as reanimated, c as vectorIcons, d as netInfo, f as mmkv, g as asyncStorage, h as screens, i as worklets, l as webview, m as expo, n as skia, o as bottomSheet, p as deviceInfo, r as unistyles, s as flashList, u as svg, v as safeAreaContext, y as gestureHandler } from "./index-
|
|
1
|
+
import { _ as navigation, a as keyboardController, b as reanimated, c as vectorIcons, d as netInfo, f as mmkv, g as asyncStorage, h as screens, i as worklets, l as webview, m as expo, n as skia, o as bottomSheet, p as deviceInfo, r as unistyles, s as flashList, u as svg, v as safeAreaContext, y as gestureHandler } from "./index-xw43lBlv.mjs";
|
|
2
2
|
export { asyncStorage, bottomSheet, deviceInfo, expo, flashList, gestureHandler, keyboardController, mmkv, navigation, netInfo, reanimated, safeAreaContext, screens, skia, svg, unistyles, vectorIcons, webview, worklets };
|
|
@@ -89,7 +89,7 @@ Your existing tests render against real React Native exactly as before.
|
|
|
89
89
|
tests. A CI-gated cross-check keeps the mock behaviorally honest against real RN.
|
|
90
90
|
- **Presets** auto-shadow common native libraries (Reanimated, Gesture Handler,
|
|
91
91
|
Safe Area, Navigation, …) the way `jest` mocks them — no per-lib wiring.
|
|
92
|
-
- A **hot runtime**,
|
|
92
|
+
- A **hot runtime**, opt-in where the run can be bounded
|
|
93
93
|
(`hotRuntime: 'auto'`), keeps RN warm across files while resetting app/test
|
|
94
94
|
modules and common process-wide pollution between files. It uses Vitest's
|
|
95
95
|
custom worker APIs; `hotRuntime: false` opts out.
|
|
@@ -19,8 +19,8 @@ semver, which are experimental, and how the peer ranges below are allowed to mov
|
|
|
19
19
|
|
|
20
20
|
## Blocking compatibility matrix
|
|
21
21
|
|
|
22
|
-
- Node
|
|
23
|
-
|
|
22
|
+
- Node 22.13 (the floor) on Linux with RNTL 12, 13 and 14, and on macOS and Windows; Node 24 on
|
|
23
|
+
Linux.
|
|
24
24
|
- Patched Vite lines ^6.4.2, ^7.3.2, and ^8.0.5 through packed consumers.
|
|
25
25
|
- Vitest 5 (the lockfile release and the newest 5.x) against React Native 0.81–0.88, and the newest
|
|
26
26
|
Vitest 4.x against the oldest and newest of that range.
|
|
@@ -84,14 +84,15 @@ change.
|
|
|
84
84
|
them; the caches every pull request starts from are the ones `main` saves. `pages.yml` also
|
|
85
85
|
publishes the fidelity matrix from the latest successful `main` run of the RN matrix.
|
|
86
86
|
|
|
87
|
-
The ATTW gate ignores legacy Node 10 resolution because the package requires Node
|
|
87
|
+
The ATTW gate ignores legacy Node 10 resolution because the package requires Node 22.13+ or 24.3+.
|
|
88
88
|
|
|
89
89
|
Seven of the eleven `exports` subpaths are ESM-only by design — `.`, `./setup`, `./presets`, the
|
|
90
90
|
three `jest-compat` runtime shims, and the types-only `./rntl-matchers`. Each of the runtime ones
|
|
91
91
|
depends on Vitest, which throws when it is reached through `require()`, so shipping a transpiled
|
|
92
92
|
CommonJS build for them produced files that could not be loaded at all. They now declare a single
|
|
93
93
|
ESM target for both conditions: a CommonJS consumer still reaches them, through Node's `require(esm)`
|
|
94
|
-
support
|
|
94
|
+
support, which Node has had since 20.19 and 22.12; the range itself (22.13+ or 24.3+) also leaves out
|
|
95
|
+
Node 24.0–24.2, where `jest.mock` does not reach modules Node loads.
|
|
95
96
|
|
|
96
97
|
The remaining four subpaths ship a real CommonJS build and are checked with `cjs-resolves-to-esm`
|
|
97
98
|
enforced, so a dual entry cannot quietly lose its `.cjs`. Which subpaths are intentionally ESM-only
|
package/docs/versioning.md
CHANGED
|
@@ -96,7 +96,7 @@ are documented, tested, and gated in CI — they are simply not stable, and they
|
|
|
96
96
|
|
|
97
97
|
| Surface | Why |
|
|
98
98
|
| --- | --- |
|
|
99
|
-
| `hotRuntime` and its options | Built on Vitest's experimental custom-pool API, which can change between Vitest minors. The default
|
|
99
|
+
| `hotRuntime` and its options | Built on Vitest's experimental custom-pool API, which can change between Vitest minors. The default is `false` (per-file isolation); `'auto'` opts in, and falls back to per-file isolation whenever the run cannot be bounded. |
|
|
100
100
|
| `metroConfig` and its options | Opt-in declarative Metro profile ingestion. Framework loading, custom resolvers and the version matrix remain under investigation. Off by default. |
|
|
101
101
|
|
|
102
102
|
A surface leaves this list by being promoted in a minor, and can change or be removed in a minor
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitest-native",
|
|
3
|
-
"version": "0.14.0-rc.
|
|
3
|
+
"version": "0.14.0-rc.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Run real React Native tests under Vitest. One install, zero config.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
"CHANGELOG.md"
|
|
108
108
|
],
|
|
109
109
|
"engines": {
|
|
110
|
-
"node": ">=
|
|
110
|
+
"node": ">=22.13.0 <23 || >=24.3.0"
|
|
111
111
|
},
|
|
112
112
|
"sideEffects": [
|
|
113
113
|
"./dist/setup.mjs",
|
|
@@ -141,8 +141,8 @@
|
|
|
141
141
|
"@babel/core": "^7.29.7",
|
|
142
142
|
"@gorhom/bottom-sheet": "5.2.14",
|
|
143
143
|
"@react-native-community/netinfo": "12.0.1",
|
|
144
|
-
"@react-native-vector-icons/common": "
|
|
145
|
-
"@react-native-vector-icons/material-icons": "
|
|
144
|
+
"@react-native-vector-icons/common": "14.0.0",
|
|
145
|
+
"@react-native-vector-icons/material-icons": "14.0.0",
|
|
146
146
|
"@react-native/babel-preset": "0.88.0",
|
|
147
147
|
"@react-navigation/native": "7.5.1",
|
|
148
148
|
"@react-navigation/native-stack": "7.21.0",
|
|
@@ -162,11 +162,11 @@
|
|
|
162
162
|
"react": "^19.3.0",
|
|
163
163
|
"react-native": "0.88.0",
|
|
164
164
|
"react-native-gesture-handler": "3.4.0",
|
|
165
|
-
"react-native-keyboard-controller": "1.22.
|
|
165
|
+
"react-native-keyboard-controller": "1.22.8",
|
|
166
166
|
"react-native-reanimated": "4.7.1",
|
|
167
167
|
"react-native-safe-area-context": "5.10.1",
|
|
168
168
|
"react-native-unistyles": "3.5.3",
|
|
169
|
-
"react-native-skia": "3.7.
|
|
169
|
+
"react-native-skia": "3.7.2",
|
|
170
170
|
"react-native-worklets": "0.13.0",
|
|
171
171
|
"react-test-renderer": "^19.3.0",
|
|
172
172
|
"resident-singleton": "file:./tests-native/fixtures/resident-singleton",
|
|
@@ -194,7 +194,8 @@
|
|
|
194
194
|
"test:native:android": "vitest run --config tests-native/vitest.android.config.mts",
|
|
195
195
|
"test:native:advice": "vitest run --config tests-native/vitest.advice.config.mts",
|
|
196
196
|
"test:native:hot": "vitest run --config tests-native/vitest.hot.config.mts",
|
|
197
|
-
"test:native:hot:isolation": "vitest run --config tests-native/vitest.hot-isolation.config.mts && vitest run --config tests-native/vitest.hot-user-setup.config.mts && vitest run --config tests-native/vitest.hot-jest-compat.config.mts --mode stock && vitest run --config tests-native/vitest.hot-jest-compat.config.mts --mode hot && vitest run --config tests-native/vitest.jest-registry-no-isolate.config.mts",
|
|
197
|
+
"test:native:hot:isolation": "vitest run --config tests-native/vitest.hot-isolation.config.mts && vitest run --config tests-native/vitest.hot-user-setup.config.mts && vitest run --config tests-native/vitest.hot-jest-compat.config.mts --mode stock && vitest run --config tests-native/vitest.hot-jest-compat.config.mts --mode hot && vitest run --config tests-native/vitest.jest-registry-no-isolate.config.mts && bun run test:native:hot:file-accounting",
|
|
198
|
+
"test:native:hot:file-accounting": "node scripts/test-hot-file-accounting.mjs",
|
|
198
199
|
"test:native:hot:state-manifest": "node scripts/test-hot-state-manifest.mjs",
|
|
199
200
|
"test:native:hot:soak": "node scripts/test-hot-soak.mjs",
|
|
200
201
|
"test:consumers": "node scripts/test-consumers.mjs",
|