vitest-native 0.9.0 → 0.10.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/CHANGELOG.md +731 -0
- package/README.md +32 -1
- package/dist/cli.cjs +163 -27
- package/dist/cli.mjs +162 -26
- package/dist/{ecosystem-EFtHnKS9.mjs → ecosystem-CO5vqExO.mjs} +77 -15
- package/dist/{ecosystem-BIWaVwYL.cjs → ecosystem-IuZ-Gv0R.cjs} +78 -16
- package/dist/errors-Dm5yLNTF.mjs +64 -0
- package/dist/errors-flXDIeWk.cjs +75 -0
- package/dist/errors.d.mts +46 -0
- package/dist/errors.mjs +78 -0
- package/dist/helpers.cjs +6 -23
- package/dist/helpers.d.cts +0 -6
- package/dist/helpers.d.mts +0 -6
- package/dist/helpers.mjs +6 -23
- package/dist/{index-CEgRDdhd.d.cts → index-BJL4cQ-l.d.cts} +9 -4
- package/dist/{index-j-0tueBr.d.mts → index-CvCU0cLl.d.mts} +9 -4
- package/dist/index.d.mts +8 -6
- package/dist/index.mjs +245 -59
- package/dist/jest-compat/interop.mjs +15 -0
- package/dist/jest-compat/setup.mjs +102 -7
- package/dist/matchers.cjs +16 -7
- package/dist/matchers.mjs +16 -7
- package/dist/native/hooks.mjs +75 -1
- package/dist/native/loader.mjs +26 -6
- package/dist/native/module-reset.mjs +63 -0
- package/dist/native/registry.mjs +80 -11
- package/dist/native/resolve.d.mts +22 -0
- package/dist/native/resolve.mjs +21 -13
- package/dist/native/runner.mjs +21 -0
- package/dist/native/setup.mjs +4 -2
- package/dist/native/transform.mjs +108 -3
- package/dist/native/worker.mjs +59 -16
- package/dist/{pool-CJmjRgsB.mjs → pool-Bcxp4Qrg.mjs} +2 -1
- package/dist/{pool-DzsEo9vv.cjs → pool-CFND7plG.cjs} +2 -1
- package/dist/{preset-map-CNsZKfvu.mjs → preset-map-BpDG_D5m.mjs} +0 -1
- package/dist/{preset-map-CG4FMtsl.cjs → preset-map-DxilQ4pI.cjs} +0 -1
- package/dist/{presets-C4faM3ds.cjs → presets-BGTqVH6C.cjs} +94 -50
- package/dist/{presets-CuDrNA_W.mjs → presets-CK85x8ey.mjs} +94 -50
- package/dist/presets.d.mts +1 -1
- package/dist/presets.mjs +1 -1
- package/dist/rntl-matchers.d.ts +35 -0
- package/dist/serializer.cjs +33 -3
- package/dist/serializer.mjs +33 -3
- package/dist/setup.mjs +234 -71
- package/docs/release-readiness.md +22 -5
- package/docs/versioning.md +133 -0
- package/package.json +25 -35
- package/dist/index.cjs +0 -788
- package/dist/index.d.cts +0 -14
- package/dist/presets.cjs +0 -18
- package/dist/presets.d.cts +0 -2
- package/dist/setup.cjs +0 -2702
- package/dist/setup.d.cts +0 -1
package/dist/native/resolve.mjs
CHANGED
|
@@ -4,21 +4,29 @@
|
|
|
4
4
|
import fs from "node:fs";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Metro's default `sourceExts`, in its order. Kept as data rather than spelled out
|
|
9
|
+
* per platform so the Vite graph and the Node graph cannot drift apart — both build
|
|
10
|
+
* their list from this one array (see `getPlatformExtensions` in ../resolve.ts).
|
|
11
|
+
*
|
|
12
|
+
* The order is load-bearing where a module has more than one variant on disk:
|
|
13
|
+
* Metro picks `Foo.js` over `Foo.tsx`, so this list must too, or a project with a
|
|
14
|
+
* compiled file beside its source tests a different file than it ships. `json` is
|
|
15
|
+
* a source extension to Metro, which is why `import config from './config'`
|
|
16
|
+
* resolves `config.json` in an app.
|
|
17
|
+
*/
|
|
18
|
+
export const METRO_SOURCE_EXTS = ["js", "jsx", "json", "ts", "tsx"];
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Metro tries every platform-suffixed variant first, then every `.native` one,
|
|
22
|
+
* then the bare extensions — not extension-major.
|
|
23
|
+
*/
|
|
24
|
+
export function extensionsFor(platform) {
|
|
8
25
|
const suffix = platform === "android" ? "android" : "ios";
|
|
9
26
|
return [
|
|
10
|
-
`.${suffix}
|
|
11
|
-
|
|
12
|
-
`.${
|
|
13
|
-
`.${suffix}.js`,
|
|
14
|
-
".native.tsx",
|
|
15
|
-
".native.ts",
|
|
16
|
-
".native.jsx",
|
|
17
|
-
".native.js",
|
|
18
|
-
".tsx",
|
|
19
|
-
".ts",
|
|
20
|
-
".jsx",
|
|
21
|
-
".js",
|
|
27
|
+
...METRO_SOURCE_EXTS.map((e) => `.${suffix}.${e}`),
|
|
28
|
+
...METRO_SOURCE_EXTS.map((e) => `.native.${e}`),
|
|
29
|
+
...METRO_SOURCE_EXTS.map((e) => `.${e}`),
|
|
22
30
|
];
|
|
23
31
|
}
|
|
24
32
|
|
package/dist/native/runner.mjs
CHANGED
|
@@ -28,6 +28,27 @@ if (!TestRunner) {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
export default class NativeHotRunner extends TestRunner {
|
|
31
|
+
// Fires once per test file, before its setup files and its own modules are
|
|
32
|
+
// imported — the point where Vitest resets the module graph when isolation is on.
|
|
33
|
+
// The hot pool runs with isolation off so the worker survives, so the reset happens
|
|
34
|
+
// here instead, through public API rather than by mutating Vitest's worker state.
|
|
35
|
+
//
|
|
36
|
+
// onBeforeCollect, not onCollectStart. Vitest AWAITS this one; it calls
|
|
37
|
+
// onCollectStart without awaiting, and the worker wraps that hook in an async
|
|
38
|
+
// function that first awaits an RPC to the main thread. The reset therefore landed
|
|
39
|
+
// some indeterminate time after collection had already started — measured at ~0.2ms
|
|
40
|
+
// against a 1-45ms head start on the setup-file import, so it always won in
|
|
41
|
+
// practice, but nothing ordered it. Losing that race would have reset the graph
|
|
42
|
+
// mid-import and dropped any mock a setup file had just registered.
|
|
43
|
+
//
|
|
44
|
+
// Vitest passes an array because the hook is shaped for a batch, but its per-file
|
|
45
|
+
// loop invokes the run through startTests([file]) one file at a time, which is the
|
|
46
|
+
// cadence the reset needs.
|
|
47
|
+
async onBeforeCollect(paths) {
|
|
48
|
+
globalThis.__vitest_native_reset_module_runner?.();
|
|
49
|
+
return super.onBeforeCollect?.(paths);
|
|
50
|
+
}
|
|
51
|
+
|
|
31
52
|
async onBeforeRunFiles(files) {
|
|
32
53
|
globalThis.__vitest_native_hot_bless?.();
|
|
33
54
|
return super.onBeforeRunFiles?.(files);
|
package/dist/native/setup.mjs
CHANGED
|
@@ -11,6 +11,7 @@ import { enableV8CompileCache } from "./compile-cache.mjs";
|
|
|
11
11
|
import * as presetFactories from "../presets.mjs";
|
|
12
12
|
import { animatedMatchers } from "../matchers.mjs";
|
|
13
13
|
import { serializer as rnSerializer } from "../serializer.mjs";
|
|
14
|
+
import { VitestNativeError } from "../errors.mjs";
|
|
14
15
|
|
|
15
16
|
// Hot runtime: surgical reset of state left by the PREVIOUS file. Setup files
|
|
16
17
|
// are force-inlined by Vitest, so this body re-runs per test file even when the
|
|
@@ -170,8 +171,9 @@ function emitColorScheme(colorScheme) {
|
|
|
170
171
|
g.__vitest_native_control = {
|
|
171
172
|
engine: "native",
|
|
172
173
|
setPlatform() {
|
|
173
|
-
throw new
|
|
174
|
-
|
|
174
|
+
throw new VitestNativeError(
|
|
175
|
+
"WRONG_ENGINE_FOR_HELPER",
|
|
176
|
+
`setPlatform() is only available with engine:'mock'. ` +
|
|
175
177
|
`The native engine selects platform files when the module graph loads. ` +
|
|
176
178
|
`Use reactNative({ platform: 'ios' | 'android' }) or separate Vitest projects.`,
|
|
177
179
|
);
|
|
@@ -19,14 +19,20 @@ import fs from "node:fs";
|
|
|
19
19
|
import os from "node:os";
|
|
20
20
|
import crypto from "node:crypto";
|
|
21
21
|
import { decorateTransformError } from "./explain.mjs";
|
|
22
|
+
import { VitestNativeError } from "../errors.mjs";
|
|
22
23
|
|
|
23
24
|
let _req;
|
|
24
25
|
let _babel;
|
|
25
26
|
let _preset;
|
|
27
|
+
let _flowEnums;
|
|
26
28
|
let _cacheDir;
|
|
27
29
|
let _writeSeq = 0;
|
|
28
30
|
const mem = new Map();
|
|
29
|
-
|
|
31
|
+
// 4: Flow enums are now transformed ahead of the preset's strip-types pass, so cached
|
|
32
|
+
// output from 3 is missing every `export enum` declaration. Neither the preset nor
|
|
33
|
+
// Babel version changed, and those are the only other inputs to the directory name, so
|
|
34
|
+
// without this bump a warm cache would keep serving the broken modules.
|
|
35
|
+
export const TRANSFORM_CACHE_VERSION = 4;
|
|
30
36
|
|
|
31
37
|
/**
|
|
32
38
|
* Root directory for vitest-native's on-disk caches. Prefers the project's
|
|
@@ -61,11 +67,32 @@ function init(projectRoot) {
|
|
|
61
67
|
// lazily on the first cache miss.
|
|
62
68
|
_preset = _req.resolve("@react-native/babel-preset");
|
|
63
69
|
_req.resolve("@babel/core");
|
|
70
|
+
// Flow enums must be transformed BEFORE @babel/plugin-transform-flow-strip-types
|
|
71
|
+
// sees them, or the declaration is removed as if it were a type annotation. The
|
|
72
|
+
// React Native preset carries both, but in separate `overrides` entries that Babel
|
|
73
|
+
// merges into ONE pass with strip-types first — so `export enum Foo {}` is deleted
|
|
74
|
+
// while the code referencing Foo survives, leaving a module that throws
|
|
75
|
+
// ReferenceError on a path nothing warned about. Measured identical on preset
|
|
76
|
+
// 0.85.3 and 0.86.1, so this is the preset's ordering rather than version skew.
|
|
77
|
+
//
|
|
78
|
+
// Babel applies `plugins` before `presets`, so naming the plugin here runs it first
|
|
79
|
+
// and the enum survives. Resolved from the preset, which depends on it, so no new
|
|
80
|
+
// dependency is required.
|
|
81
|
+
try {
|
|
82
|
+
_flowEnums = createRequire(_req.resolve("@react-native/babel-preset/package.json")).resolve(
|
|
83
|
+
"babel-plugin-transform-flow-enums",
|
|
84
|
+
);
|
|
85
|
+
} catch {
|
|
86
|
+
// A preset layout without it: fall back to the preset's own handling rather than
|
|
87
|
+
// failing the run. Flow enums are rare and only two React Native files use them.
|
|
88
|
+
_flowEnums = null;
|
|
89
|
+
}
|
|
64
90
|
presetVersion = _req("@react-native/babel-preset/package.json").version;
|
|
65
91
|
babelVersion = _req("@babel/core/package.json").version;
|
|
66
92
|
} catch {
|
|
67
|
-
throw new
|
|
68
|
-
"
|
|
93
|
+
throw new VitestNativeError(
|
|
94
|
+
"ENGINE_REQUIRES_BABEL",
|
|
95
|
+
"engine 'native' requires '@react-native/babel-preset' and " +
|
|
69
96
|
"'@babel/core' in your project. Install them as devDependencies " +
|
|
70
97
|
"(they ship with React Native projects by default).",
|
|
71
98
|
);
|
|
@@ -89,6 +116,83 @@ export function transformCacheDir() {
|
|
|
89
116
|
}
|
|
90
117
|
|
|
91
118
|
/** Returns true if the source contains RN Flow syntax that must be transformed. */
|
|
119
|
+
/** A valid identifier, so a name can appear in the shorthand export hint. */
|
|
120
|
+
const IDENTIFIER = /^[A-Za-z_$][\w$]*$/;
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Named exports of already-transformed CommonJS code, read from its AST.
|
|
124
|
+
*
|
|
125
|
+
* Node decides a CommonJS module's named exports with cjs-module-lexer, which reads
|
|
126
|
+
* the source statically and stops at shapes it cannot follow. `module.exports = {
|
|
127
|
+
* A() {}, b: () => 1 }` — ordinary hand-written CommonJS, and common across the React
|
|
128
|
+
* Native ecosystem — yields `["A", "default", "module.exports"]`: `b` is missing, and
|
|
129
|
+
* a name that is not an export appears. That is plain Node behaviour, reproducible
|
|
130
|
+
* with no plugin involved.
|
|
131
|
+
*
|
|
132
|
+
* Reading it properly is possible here because Babel is already loaded to do the
|
|
133
|
+
* transform, and because the input is the transform's own output rather than
|
|
134
|
+
* arbitrary source. Names are used only to emit a dead `0 && (module.exports = {…})`
|
|
135
|
+
* hint, which is the form the lexer does understand.
|
|
136
|
+
*
|
|
137
|
+
* Returns an empty array when the shape is not statically knowable (`module.exports =
|
|
138
|
+
* someValue`), which leaves Node's own detection in charge — no worse than before.
|
|
139
|
+
*/
|
|
140
|
+
export function cjsExportNames(code) {
|
|
141
|
+
if (!_babel) {
|
|
142
|
+
if (!_req) return [];
|
|
143
|
+
_babel = _req("@babel/core");
|
|
144
|
+
}
|
|
145
|
+
let ast;
|
|
146
|
+
try {
|
|
147
|
+
ast = _babel.parseSync(code, { babelrc: false, configFile: false, sourceType: "script" });
|
|
148
|
+
} catch {
|
|
149
|
+
return [];
|
|
150
|
+
}
|
|
151
|
+
const names = new Set();
|
|
152
|
+
const isExportsTarget = (node, wantMember) => {
|
|
153
|
+
if (!node) return false;
|
|
154
|
+
if (node.type === "Identifier") return !wantMember && node.name === "exports";
|
|
155
|
+
if (node.type !== "MemberExpression" || node.computed) return false;
|
|
156
|
+
return (
|
|
157
|
+
node.object.type === "Identifier" &&
|
|
158
|
+
node.object.name === "module" &&
|
|
159
|
+
node.property.type === "Identifier" &&
|
|
160
|
+
node.property.name === "exports"
|
|
161
|
+
);
|
|
162
|
+
};
|
|
163
|
+
for (const statement of ast.program.body) {
|
|
164
|
+
if (statement.type !== "ExpressionStatement") continue;
|
|
165
|
+
const expression = statement.expression;
|
|
166
|
+
if (expression.type !== "AssignmentExpression" || expression.operator !== "=") continue;
|
|
167
|
+
const target = expression.left;
|
|
168
|
+
// `module.exports = { … }` / `exports = { … }` — take the literal's own keys.
|
|
169
|
+
if (isExportsTarget(target, true) || isExportsTarget(target, false)) {
|
|
170
|
+
if (expression.right.type !== "ObjectExpression") continue;
|
|
171
|
+
for (const property of expression.right.properties) {
|
|
172
|
+
if (property.type === "SpreadElement" || property.computed) continue;
|
|
173
|
+
const key = property.key;
|
|
174
|
+
if (key.type === "Identifier") names.add(key.name);
|
|
175
|
+
else if (key.type === "StringLiteral" && IDENTIFIER.test(key.value)) names.add(key.value);
|
|
176
|
+
}
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
// `exports.foo = …` / `module.exports.foo = …` — the lexer handles these, but
|
|
180
|
+
// a module can mix both forms and the object-literal branch would miss them.
|
|
181
|
+
if (target.type === "MemberExpression" && !target.computed) {
|
|
182
|
+
const owner = target.object;
|
|
183
|
+
if (
|
|
184
|
+
(owner.type === "Identifier" && owner.name === "exports") ||
|
|
185
|
+
isExportsTarget(owner, true)
|
|
186
|
+
) {
|
|
187
|
+
if (target.property.type === "Identifier") names.add(target.property.name);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
names.delete("default");
|
|
192
|
+
names.delete("__esModule");
|
|
193
|
+
return [...names].filter((name) => IDENTIFIER.test(name));
|
|
194
|
+
}
|
|
195
|
+
|
|
92
196
|
export function isFlow(src) {
|
|
93
197
|
return /@flow|import typeof|\bcomponent\s+\w/.test(src);
|
|
94
198
|
}
|
|
@@ -128,6 +232,7 @@ export function transformRN(file, src, projectRoot, platform = "ios") {
|
|
|
128
232
|
try {
|
|
129
233
|
out = _babel.transformSync(src, {
|
|
130
234
|
filename: file,
|
|
235
|
+
plugins: _flowEnums ? [_flowEnums] : [],
|
|
131
236
|
presets: [[_preset, { disableStaticViewConfigsCodegen: true }]],
|
|
132
237
|
babelrc: false,
|
|
133
238
|
configFile: false,
|
package/dist/native/worker.mjs
CHANGED
|
@@ -17,10 +17,12 @@ import { installGlobals } from "./globals.mjs";
|
|
|
17
17
|
import { installRequireHooks } from "./hooks.mjs";
|
|
18
18
|
import { installHotReset } from "./reset.mjs";
|
|
19
19
|
import { installRegistry } from "./registry.mjs";
|
|
20
|
+
import { captureModuleBaseline } from "./module-reset.mjs";
|
|
20
21
|
import { enableV8CompileCache } from "./compile-cache.mjs";
|
|
22
|
+
import { VitestNativeError } from "../errors.mjs";
|
|
21
23
|
|
|
22
24
|
if (isMainThread || !parentPort) {
|
|
23
|
-
throw new
|
|
25
|
+
throw new VitestNativeError("HOT_WORKER_ENV", "hot worker entry must run in node:worker_threads");
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
const projectRoot = process.env.VITEST_NATIVE_PROJECT_ROOT || process.cwd();
|
|
@@ -95,24 +97,62 @@ try {
|
|
|
95
97
|
RN.Appearance.getColorScheme?.();
|
|
96
98
|
} catch {}
|
|
97
99
|
} catch (error) {
|
|
98
|
-
throw new
|
|
99
|
-
|
|
100
|
+
throw new VitestNativeError(
|
|
101
|
+
"HOT_WORKER_PRELOAD",
|
|
102
|
+
`hot worker failed to preload react-native from ${projectRoot}: ${error?.message}`,
|
|
100
103
|
{ cause: error },
|
|
101
104
|
);
|
|
102
105
|
}
|
|
106
|
+
const resetModules = captureModuleBaseline();
|
|
103
107
|
const { hotReset, bless } = installHotReset({ projectRoot, diagnostics, preserveGlobals });
|
|
104
|
-
globalThis.__vitest_native_hot_reset =
|
|
105
|
-
globalThis.
|
|
108
|
+
globalThis.__vitest_native_hot_reset = () => {
|
|
109
|
+
globalThis.__vitest_native_registry_reset?.();
|
|
110
|
+
const dropped = resetModules();
|
|
111
|
+
hotReset();
|
|
112
|
+
if (diagnostics) console.log(`[vitest-native] hot reset: dropped ${dropped} modules`);
|
|
113
|
+
};
|
|
114
|
+
globalThis.__vitest_native_hot_bless = bless;
|
|
106
115
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
+
// Vitest's own per-file isolation — mocker reset plus a clear of the evaluated
|
|
117
|
+
// module graph — is gated on `config.isolate`, which the pool sets to false so the
|
|
118
|
+
// scheduler keeps this worker alive. Doing the two steps ourselves gives the same
|
|
119
|
+
// result without touching Vitest's worker state.
|
|
120
|
+
//
|
|
121
|
+
// This used to be done by mutating `state.ctx.config.isolate = true` inside the
|
|
122
|
+
// worker. That read a shape nothing contracts, and it broke on a PATCH release:
|
|
123
|
+
// vitest 4.1.9 on Node 24 produced "Cannot read properties of undefined (reading
|
|
124
|
+
// 'config')" for every test file and a run that reported no tests at all. The two
|
|
125
|
+
// operations below are public API — `mocker.reset()` and Vite's
|
|
126
|
+
// `ModuleRunner.clearCache()` — so a Vitest internal moving cannot silently take the
|
|
127
|
+
// hot runtime with it.
|
|
128
|
+
let moduleRunner = null;
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Reset the module-runner graph for the next test file.
|
|
132
|
+
*
|
|
133
|
+
* Called from the runner's per-file hook rather than here, because a single task can
|
|
134
|
+
* carry several files (Vitest batches them in single-worker mode) and each one needs
|
|
135
|
+
* its own reset — the same cadence Vitest uses when isolation is on. See runner.mjs
|
|
136
|
+
* for why that hook is onBeforeCollect and not onCollectStart.
|
|
137
|
+
*/
|
|
138
|
+
// Vitest's own reset deliberately leaves its runtime modules evaluated and only
|
|
139
|
+
// clears evaluation state on the rest; it does not throw the module graph away.
|
|
140
|
+
// `ModuleRunner.clearCache()` does throw it away, Vitest's own dist included, which
|
|
141
|
+
// measured 29% more peak memory and ~6% slower at 200 files — every file re-creating
|
|
142
|
+
// module nodes, and re-evaluating Vitest itself, for nothing.
|
|
143
|
+
const VITEST_RUNTIME = [/\/vitest\/dist\//, /vitest-virtual-\w+\/dist/, /@vitest\/dist/];
|
|
144
|
+
|
|
145
|
+
globalThis.__vitest_native_reset_module_runner = () => {
|
|
146
|
+
if (!moduleRunner) return;
|
|
147
|
+
moduleRunner.mocker?.reset();
|
|
148
|
+
for (const [id, node] of moduleRunner.evaluatedModules.idToModuleMap) {
|
|
149
|
+
if (VITEST_RUNTIME.some((re) => re.test(id))) continue;
|
|
150
|
+
node.promise = undefined;
|
|
151
|
+
node.exports = undefined;
|
|
152
|
+
node.evaluated = false;
|
|
153
|
+
node.importers.clear();
|
|
154
|
+
}
|
|
155
|
+
};
|
|
116
156
|
|
|
117
157
|
init({
|
|
118
158
|
// oxlint-disable-next-line unicorn/require-post-message-target-origin -- worker_threads MessagePort, not window
|
|
@@ -120,7 +160,10 @@ init({
|
|
|
120
160
|
on: (callback) => parentPort.on("message", callback),
|
|
121
161
|
off: (callback) => parentPort.off("message", callback),
|
|
122
162
|
teardown: () => parentPort.removeAllListeners("message"),
|
|
123
|
-
runTests:
|
|
124
|
-
collectTests:
|
|
163
|
+
runTests: (state, traces) => runBaseTests("run", state, traces),
|
|
164
|
+
collectTests: (state, traces) => runBaseTests("collect", state, traces),
|
|
165
|
+
onModuleRunner: (runner) => {
|
|
166
|
+
moduleRunner = runner;
|
|
167
|
+
},
|
|
125
168
|
setup: setupEnvironment,
|
|
126
169
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { t as VitestNativeError } from "./errors-Dm5yLNTF.mjs";
|
|
1
2
|
import { createRequire } from "node:module";
|
|
2
3
|
import path from "node:path";
|
|
3
4
|
import os from "node:os";
|
|
@@ -103,7 +104,7 @@ function assertWorkerVitestMatchesProject(workerEntry, projectRoot) {
|
|
|
103
104
|
const worker = resolveVitest(workerEntry);
|
|
104
105
|
const project = resolveVitest(path.join(projectRoot, "package.json"));
|
|
105
106
|
if (worker === null || project === null || worker.version === project.version) return;
|
|
106
|
-
throw new
|
|
107
|
+
throw new VitestNativeError("HOT_RUNTIME_UNAVAILABLE", `'hotRuntime' cannot run: its worker would load vitest@${worker.version}, but this run is driven by vitest@${project.version}. They talk over Vitest's worker protocol, and a version mismatch reports no results at all rather than failing.\n worker would load: ${worker.path}\n project resolves: ${project.path}\nThis happens when vitest-native and vitest resolve to different node_modules trees (linked packages, hoisted monorepo installs, mixed Vitest versions). Install one Vitest version reachable from vitest-native, or set 'hotRuntime: false'.`);
|
|
107
108
|
}
|
|
108
109
|
/** Pool initializer for `test.pool` — keeps RN-hot workers alive across files. */
|
|
109
110
|
function nativePool(options) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-CZWwpsFl.cjs");
|
|
2
|
+
const require_errors = require("./errors-flXDIeWk.cjs");
|
|
2
3
|
let node_path = require("node:path");
|
|
3
4
|
node_path = require_chunk.__toESM(node_path, 1);
|
|
4
5
|
let node_module = require("node:module");
|
|
@@ -106,7 +107,7 @@ function assertWorkerVitestMatchesProject(workerEntry, projectRoot) {
|
|
|
106
107
|
const worker = resolveVitest(workerEntry);
|
|
107
108
|
const project = resolveVitest(node_path.default.join(projectRoot, "package.json"));
|
|
108
109
|
if (worker === null || project === null || worker.version === project.version) return;
|
|
109
|
-
throw new
|
|
110
|
+
throw new require_errors.VitestNativeError("HOT_RUNTIME_UNAVAILABLE", `'hotRuntime' cannot run: its worker would load vitest@${worker.version}, but this run is driven by vitest@${project.version}. They talk over Vitest's worker protocol, and a version mismatch reports no results at all rather than failing.\n worker would load: ${worker.path}\n project resolves: ${project.path}\nThis happens when vitest-native and vitest resolve to different node_modules trees (linked packages, hoisted monorepo installs, mixed Vitest versions). Install one Vitest version reachable from vitest-native, or set 'hotRuntime: false'.`);
|
|
110
111
|
}
|
|
111
112
|
/** Pool initializer for `test.pool` — keeps RN-hot workers alive across files. */
|
|
112
113
|
function nativePool(options) {
|
|
@@ -21,7 +21,6 @@ const AUTO_DETECT_PRESETS = {
|
|
|
21
21
|
"react-native-svg": "svg",
|
|
22
22
|
"react-native-webview": "webview",
|
|
23
23
|
"@react-native-vector-icons/common": "vectorIcons",
|
|
24
|
-
"react-native-vector-icons": "vectorIcons",
|
|
25
24
|
"@shopify/flash-list": "flashList",
|
|
26
25
|
"@gorhom/bottom-sheet": "bottomSheet",
|
|
27
26
|
"react-native-keyboard-controller": "keyboardController"
|
|
@@ -21,7 +21,6 @@ const AUTO_DETECT_PRESETS = {
|
|
|
21
21
|
"react-native-svg": "svg",
|
|
22
22
|
"react-native-webview": "webview",
|
|
23
23
|
"@react-native-vector-icons/common": "vectorIcons",
|
|
24
|
-
"react-native-vector-icons": "vectorIcons",
|
|
25
24
|
"@shopify/flash-list": "flashList",
|
|
26
25
|
"@gorhom/bottom-sheet": "bottomSheet",
|
|
27
26
|
"react-native-keyboard-controller": "keyboardController"
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-CZWwpsFl.cjs");
|
|
2
|
+
const require_errors = require("./errors-flXDIeWk.cjs");
|
|
2
3
|
let node_path = require("node:path");
|
|
3
4
|
node_path = require_chunk.__toESM(node_path, 1);
|
|
4
5
|
let node_module = require("node:module");
|
|
@@ -49,11 +50,6 @@ function reanimated() {
|
|
|
49
50
|
"addWhitelistedUIProps",
|
|
50
51
|
"addWhitelistedNativeProps",
|
|
51
52
|
"configureProps",
|
|
52
|
-
"View",
|
|
53
|
-
"Text",
|
|
54
|
-
"Image",
|
|
55
|
-
"ScrollView",
|
|
56
|
-
"FlatList",
|
|
57
53
|
"Easing",
|
|
58
54
|
"FadeIn",
|
|
59
55
|
"FadeOut",
|
|
@@ -233,7 +229,7 @@ function reanimated() {
|
|
|
233
229
|
function makeAnimatedHost(name) {
|
|
234
230
|
const Comp = react.default.forwardRef((props, ref) => {
|
|
235
231
|
const Base = getRN()[name];
|
|
236
|
-
if (!Base) throw new
|
|
232
|
+
if (!Base) throw new require_errors.VitestNativeError("PRESET_UNAVAILABLE", `The reanimated preset needs React Native's '${name}' component to build Animated.${name}, and react-native did not provide it.\nThis usually means react-native resolved to something unexpected — a partially installed copy, or a mock replacing the whole module. Check that 'react-native' resolves in your project and that no vi.mock replaces it wholesale.`);
|
|
237
233
|
return react.default.createElement(Base, {
|
|
238
234
|
...props,
|
|
239
235
|
ref
|
|
@@ -280,11 +276,6 @@ function reanimated() {
|
|
|
280
276
|
addWhitelistedUIProps,
|
|
281
277
|
addWhitelistedNativeProps,
|
|
282
278
|
configureProps,
|
|
283
|
-
View,
|
|
284
|
-
Text,
|
|
285
|
-
Image,
|
|
286
|
-
ScrollView,
|
|
287
|
-
FlatList,
|
|
288
279
|
useSharedValue,
|
|
289
280
|
useAnimatedStyle,
|
|
290
281
|
useAnimatedProps,
|
|
@@ -644,10 +635,7 @@ function safeAreaContext() {
|
|
|
644
635
|
"useSafeAreaFrame",
|
|
645
636
|
"withSafeAreaInsets",
|
|
646
637
|
"initialWindowMetrics",
|
|
647
|
-
"initialWindowSafeAreaInsets"
|
|
648
|
-
"EdgeInsets",
|
|
649
|
-
"Rect",
|
|
650
|
-
"Metrics"
|
|
638
|
+
"initialWindowSafeAreaInsets"
|
|
651
639
|
],
|
|
652
640
|
factory: () => {
|
|
653
641
|
const defaultInsets = {
|
|
@@ -1265,12 +1253,29 @@ function screens() {
|
|
|
1265
1253
|
"screensEnabled",
|
|
1266
1254
|
"enableFreeze",
|
|
1267
1255
|
"freezeEnabled",
|
|
1256
|
+
"featureFlags",
|
|
1257
|
+
"compatibilityFlags",
|
|
1258
|
+
"executeNativeBackPress",
|
|
1259
|
+
"isSearchBarAvailableForCurrentPlatform",
|
|
1260
|
+
"useTransitionProgress",
|
|
1268
1261
|
"Screen",
|
|
1262
|
+
"InnerScreen",
|
|
1269
1263
|
"ScreenContainer",
|
|
1264
|
+
"ScreenContentWrapper",
|
|
1265
|
+
"ScreenContext",
|
|
1266
|
+
"ScreenFooter",
|
|
1270
1267
|
"ScreenStack",
|
|
1268
|
+
"ScreenStackItem",
|
|
1271
1269
|
"ScreenStackHeaderConfig",
|
|
1270
|
+
"ScreenStackHeaderBackButtonImage",
|
|
1271
|
+
"ScreenStackHeaderCenterView",
|
|
1272
|
+
"ScreenStackHeaderLeftView",
|
|
1273
|
+
"ScreenStackHeaderRightView",
|
|
1274
|
+
"ScreenStackHeaderSearchBarView",
|
|
1275
|
+
"ScreenStackHeaderSubview",
|
|
1272
1276
|
"SearchBar",
|
|
1273
1277
|
"FullWindowOverlay",
|
|
1278
|
+
"Tabs",
|
|
1274
1279
|
"NativeScreen",
|
|
1275
1280
|
"NativeScreenContainer"
|
|
1276
1281
|
],
|
|
@@ -1301,6 +1306,24 @@ function screens() {
|
|
|
1301
1306
|
const FullWindowOverlay = createScreenComponent("FullWindowOverlay");
|
|
1302
1307
|
const NativeScreen = createScreenComponent("NativeScreen");
|
|
1303
1308
|
const NativeScreenContainer = createScreenComponent("NativeScreenContainer");
|
|
1309
|
+
const InnerScreen = createScreenComponent("InnerScreen");
|
|
1310
|
+
const ScreenContentWrapper = createScreenComponent("ScreenContentWrapper");
|
|
1311
|
+
const ScreenFooter = createScreenComponent("ScreenFooter");
|
|
1312
|
+
const ScreenStackItem = createScreenComponent("ScreenStackItem");
|
|
1313
|
+
const ScreenStackHeaderBackButtonImage = createScreenComponent("ScreenStackHeaderBackButtonImage");
|
|
1314
|
+
const ScreenStackHeaderCenterView = createScreenComponent("ScreenStackHeaderCenterView");
|
|
1315
|
+
const ScreenStackHeaderLeftView = createScreenComponent("ScreenStackHeaderLeftView");
|
|
1316
|
+
const ScreenStackHeaderRightView = createScreenComponent("ScreenStackHeaderRightView");
|
|
1317
|
+
const ScreenStackHeaderSearchBarView = createScreenComponent("ScreenStackHeaderSearchBarView");
|
|
1318
|
+
const ScreenStackHeaderSubview = createScreenComponent("ScreenStackHeaderSubview");
|
|
1319
|
+
const Tabs = createScreenComponent("Tabs");
|
|
1320
|
+
const ScreenContext = react.default.createContext(Screen);
|
|
1321
|
+
const useTransitionProgress = vitest.vi.fn(() => ({
|
|
1322
|
+
progress: 1,
|
|
1323
|
+
closing: 0,
|
|
1324
|
+
goingForward: 0
|
|
1325
|
+
}));
|
|
1326
|
+
const executeNativeBackPress = vitest.vi.fn(() => true);
|
|
1304
1327
|
return {
|
|
1305
1328
|
default: {
|
|
1306
1329
|
Screen,
|
|
@@ -1319,7 +1342,27 @@ function screens() {
|
|
|
1319
1342
|
SearchBar,
|
|
1320
1343
|
FullWindowOverlay,
|
|
1321
1344
|
NativeScreen,
|
|
1322
|
-
NativeScreenContainer
|
|
1345
|
+
NativeScreenContainer,
|
|
1346
|
+
InnerScreen,
|
|
1347
|
+
ScreenContentWrapper,
|
|
1348
|
+
ScreenContext,
|
|
1349
|
+
ScreenFooter,
|
|
1350
|
+
ScreenStackItem,
|
|
1351
|
+
ScreenStackHeaderBackButtonImage,
|
|
1352
|
+
ScreenStackHeaderCenterView,
|
|
1353
|
+
ScreenStackHeaderLeftView,
|
|
1354
|
+
ScreenStackHeaderRightView,
|
|
1355
|
+
ScreenStackHeaderSearchBarView,
|
|
1356
|
+
ScreenStackHeaderSubview,
|
|
1357
|
+
Tabs,
|
|
1358
|
+
useTransitionProgress,
|
|
1359
|
+
executeNativeBackPress,
|
|
1360
|
+
isSearchBarAvailableForCurrentPlatform: true,
|
|
1361
|
+
featureFlags: {
|
|
1362
|
+
experiment: {},
|
|
1363
|
+
flags: {}
|
|
1364
|
+
},
|
|
1365
|
+
compatibilityFlags: {}
|
|
1323
1366
|
};
|
|
1324
1367
|
}
|
|
1325
1368
|
} }
|
|
@@ -1333,42 +1376,44 @@ function expo() {
|
|
|
1333
1376
|
modules: {
|
|
1334
1377
|
"expo-constants": {
|
|
1335
1378
|
exports: [
|
|
1336
|
-
"
|
|
1337
|
-
"
|
|
1338
|
-
"
|
|
1339
|
-
"isDevice",
|
|
1340
|
-
"platform",
|
|
1341
|
-
"manifest",
|
|
1342
|
-
"manifest2",
|
|
1343
|
-
"expoGoConfig",
|
|
1344
|
-
"easConfig",
|
|
1345
|
-
"experienceUrl",
|
|
1346
|
-
"linkingUri",
|
|
1347
|
-
"getWebViewUserAgentAsync"
|
|
1379
|
+
"AppOwnership",
|
|
1380
|
+
"ExecutionEnvironment",
|
|
1381
|
+
"UserInterfaceIdiom"
|
|
1348
1382
|
],
|
|
1349
1383
|
factory: () => {
|
|
1350
|
-
const Constants = {
|
|
1351
|
-
expoConfig: {
|
|
1352
|
-
name: "test-app",
|
|
1353
|
-
slug: "test-app",
|
|
1354
|
-
version: "1.0.0",
|
|
1355
|
-
extra: {}
|
|
1356
|
-
},
|
|
1357
|
-
executionEnvironment: "storeClient",
|
|
1358
|
-
appOwnership: "standalone",
|
|
1359
|
-
isDevice: true,
|
|
1360
|
-
platform: {},
|
|
1361
|
-
manifest: null,
|
|
1362
|
-
manifest2: null,
|
|
1363
|
-
expoGoConfig: null,
|
|
1364
|
-
easConfig: null,
|
|
1365
|
-
experienceUrl: "",
|
|
1366
|
-
linkingUri: "",
|
|
1367
|
-
getWebViewUserAgentAsync: vitest.vi.fn(async () => "test-user-agent")
|
|
1368
|
-
};
|
|
1369
1384
|
return {
|
|
1370
|
-
default:
|
|
1371
|
-
|
|
1385
|
+
default: {
|
|
1386
|
+
expoConfig: {
|
|
1387
|
+
name: "test-app",
|
|
1388
|
+
slug: "test-app",
|
|
1389
|
+
version: "1.0.0",
|
|
1390
|
+
extra: {}
|
|
1391
|
+
},
|
|
1392
|
+
executionEnvironment: "storeClient",
|
|
1393
|
+
appOwnership: "standalone",
|
|
1394
|
+
isDevice: true,
|
|
1395
|
+
platform: {},
|
|
1396
|
+
manifest: null,
|
|
1397
|
+
manifest2: null,
|
|
1398
|
+
expoGoConfig: null,
|
|
1399
|
+
easConfig: null,
|
|
1400
|
+
experienceUrl: "",
|
|
1401
|
+
linkingUri: "",
|
|
1402
|
+
getWebViewUserAgentAsync: vitest.vi.fn(async () => "test-user-agent")
|
|
1403
|
+
},
|
|
1404
|
+
AppOwnership: { Expo: "expo" },
|
|
1405
|
+
ExecutionEnvironment: {
|
|
1406
|
+
Bare: "bare",
|
|
1407
|
+
Standalone: "standalone",
|
|
1408
|
+
StoreClient: "storeClient"
|
|
1409
|
+
},
|
|
1410
|
+
UserInterfaceIdiom: {
|
|
1411
|
+
Handset: "handset",
|
|
1412
|
+
Tablet: "tablet",
|
|
1413
|
+
Desktop: "desktop",
|
|
1414
|
+
TV: "tv",
|
|
1415
|
+
Unsupported: "unsupported"
|
|
1416
|
+
}
|
|
1372
1417
|
};
|
|
1373
1418
|
}
|
|
1374
1419
|
},
|
|
@@ -1830,7 +1875,6 @@ function flashList() {
|
|
|
1830
1875
|
"FlashList",
|
|
1831
1876
|
"AnimatedFlashList",
|
|
1832
1877
|
"LayoutCommitObserver",
|
|
1833
|
-
"ViewToken",
|
|
1834
1878
|
"RenderTargetOptions",
|
|
1835
1879
|
"useRecyclingState",
|
|
1836
1880
|
"useLayoutState",
|