vitest-native 0.13.0 → 0.14.0-rc.2
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 +339 -0
- package/README.md +138 -48
- package/dist/cli.cjs +70 -5
- package/dist/cli.d.cts +2 -3
- package/dist/cli.d.mts +2 -3
- package/dist/cli.mjs +70 -5
- package/dist/{ecosystem-Duw40-mO.mjs → ecosystem-DFbU_MPe.mjs} +389 -18
- package/dist/{ecosystem-CEIF_-jq.cjs → ecosystem-DI1AhK_k.cjs} +408 -25
- package/dist/errors.d.mts +12 -0
- package/dist/helpers.cjs +6 -3
- package/dist/helpers.d.cts +8 -9
- package/dist/helpers.d.mts +8 -9
- package/dist/helpers.mjs +6 -3
- package/dist/{index-CPGq6p95.d.cts → index-BxzW2D7K.d.cts} +33 -9
- package/dist/{index-CmETArCM.d.mts → index-CEbwa4QU.d.mts} +33 -9
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +537 -118
- package/dist/jest-compat/aliases.d.mts +5 -0
- package/dist/jest-compat/aliases.mjs +65 -0
- package/dist/jest-compat/caller.mjs +53 -0
- package/dist/jest-compat/setup.mjs +72 -36
- package/dist/jest-compat.cjs +1 -3
- package/dist/jest-compat.d.cts +4 -5
- package/dist/jest-compat.d.mts +4 -5
- package/dist/jest-compat.mjs +1 -1
- package/dist/matchers.d.cts +9 -9
- package/dist/matchers.d.mts +9 -9
- package/dist/memory-6EPHrJA1.cjs +144 -0
- package/dist/memory-FYbP0_gg.mjs +126 -0
- package/dist/native/boundary.mjs +13 -2
- package/dist/native/bounded-process.mjs +165 -0
- package/dist/native/export-condition-recovery-preload.mjs +5 -0
- package/dist/native/export-condition-recovery.mjs +195 -0
- package/dist/native/globals.mjs +133 -5
- package/dist/native/hooks.mjs +131 -71
- package/dist/native/loader.mjs +41 -28
- package/dist/native/match.d.mts +3 -0
- package/dist/native/match.mjs +38 -2
- package/dist/native/metro-profile-compiler.mjs +234 -0
- package/dist/native/metro-profile.mjs +115 -0
- package/dist/native/module-reset.mjs +111 -6
- package/dist/native/ownership.d.mts +105 -0
- package/dist/native/ownership.mjs +474 -0
- package/dist/native/registry-compiler.mjs +43 -0
- package/dist/native/registry-process.mjs +124 -0
- package/dist/native/registry.mjs +139 -32
- package/dist/native/reset.mjs +305 -135
- package/dist/native/resolve.d.mts +20 -3
- package/dist/native/resolve.mjs +32 -12
- package/dist/native/rntl-hooks.mjs +76 -0
- package/dist/native/setup.mjs +81 -32
- package/dist/native/state-manifest.d.mts +22 -0
- package/dist/native/state-manifest.mjs +136 -0
- package/dist/native/transform.mjs +29 -8
- package/dist/native/worker.mjs +52 -4
- package/dist/pool-B4yesGhI.cjs +121 -0
- package/dist/pool-DjpOjOf3.mjs +119 -0
- package/dist/{presets-CoNf4ByH.cjs → presets-BYHmi7-W.cjs} +117 -18
- package/dist/{presets-DGProTaA.mjs → presets-DC-eM5IA.mjs} +117 -18
- package/dist/presets.d.mts +1 -1
- package/dist/presets.mjs +1 -1
- package/dist/rntl-matchers.d.ts +58 -12
- package/dist/serializer.cjs +4 -2
- package/dist/serializer.d.cts +3 -4
- package/dist/serializer.d.mts +3 -4
- package/dist/serializer.mjs +4 -2
- package/dist/setup.mjs +61 -50
- package/dist/worker-vitest-BGPo0ek6.mjs +49 -0
- package/dist/worker-vitest-BfiQB8ND.cjs +62 -0
- package/docs/hot-default-design.md +175 -88
- package/docs/migrating-from-jest.md +12 -5
- package/docs/migrating-from-vitest-react-native.md +4 -4
- package/docs/release-readiness.md +39 -13
- package/docs/versioning.md +19 -18
- package/package.json +42 -31
- package/dist/pool-BU-1ecIF.cjs +0 -122
- package/dist/pool-Bcxn9a3I.mjs +0 -118
|
@@ -13,6 +13,7 @@ const KNOWN_OPTIONS = [
|
|
|
13
13
|
"mocks",
|
|
14
14
|
"diagnostics",
|
|
15
15
|
"assetExts",
|
|
16
|
+
"metroConfig",
|
|
16
17
|
"engine",
|
|
17
18
|
"transform",
|
|
18
19
|
"hotRuntime"
|
|
@@ -20,9 +21,11 @@ const KNOWN_OPTIONS = [
|
|
|
20
21
|
const KNOWN_HOT_RUNTIME_OPTIONS = [
|
|
21
22
|
"recycleAfterFiles",
|
|
22
23
|
"memoryLimit",
|
|
24
|
+
"allowUnboundedMemory",
|
|
23
25
|
"preserveGlobals",
|
|
24
26
|
"esmGeneration"
|
|
25
27
|
];
|
|
28
|
+
const KNOWN_METRO_CONFIG_OPTIONS = ["configFile"];
|
|
26
29
|
function assertStringArray(value, option) {
|
|
27
30
|
if (!Array.isArray(value) || value.some((entry) => typeof entry !== "string" || entry.length === 0)) throw new require_errors.VitestNativeTypeError("INVALID_OPTION", `"${option}" must be an array of non-empty strings.`);
|
|
28
31
|
}
|
|
@@ -34,21 +37,30 @@ function validateOptions(options) {
|
|
|
34
37
|
if (options.platform !== void 0 && options.platform !== "ios" && options.platform !== "android") throw new require_errors.VitestNativeTypeError("INVALID_OPTION", `"platform" must be "ios" or "android".`);
|
|
35
38
|
if (options.diagnostics !== void 0 && typeof options.diagnostics !== "boolean") throw new require_errors.VitestNativeTypeError("INVALID_OPTION", `"diagnostics" must be a boolean.`);
|
|
36
39
|
if (options.assetExts !== void 0) assertStringArray(options.assetExts, "assetExts");
|
|
37
|
-
if (options.
|
|
38
|
-
|
|
39
|
-
const
|
|
40
|
-
const
|
|
41
|
-
if (
|
|
42
|
-
if (
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
if (options.metroConfig !== void 0 && typeof options.metroConfig !== "boolean") {
|
|
41
|
+
if (options.metroConfig === null || Array.isArray(options.metroConfig) || typeof options.metroConfig !== "object") throw new require_errors.VitestNativeTypeError("INVALID_OPTION", `"metroConfig" must be a boolean or an options object.`);
|
|
42
|
+
const metro = options.metroConfig;
|
|
43
|
+
const unknown = Object.keys(metro).filter((key) => !KNOWN_METRO_CONFIG_OPTIONS.includes(key));
|
|
44
|
+
if (unknown.length > 0) throw new require_errors.VitestNativeTypeError("UNKNOWN_OPTION", `Unknown metroConfig option "${unknown[0]}". Valid options: ${KNOWN_METRO_CONFIG_OPTIONS.join(", ")}.`);
|
|
45
|
+
if (metro.configFile !== void 0 && (typeof metro.configFile !== "string" || !metro.configFile.trim())) throw new require_errors.VitestNativeTypeError("INVALID_OPTION", `"metroConfig.configFile" must be a non-empty string.`);
|
|
46
|
+
}
|
|
47
|
+
if (options.transform !== void 0) {
|
|
48
|
+
if (Array.isArray(options.transform)) assertStringArray(options.transform, "transform");
|
|
49
|
+
else if (options.transform !== null && typeof options.transform === "object") {
|
|
50
|
+
const shape = options.transform;
|
|
51
|
+
const unknownKeys = Object.keys(shape).filter((k) => k !== "include" && k !== "exclude");
|
|
52
|
+
if (unknownKeys.length > 0) throw new require_errors.VitestNativeTypeError("INVALID_OPTION", `"transform" accepts only "include" and "exclude"; received ${unknownKeys.map((k) => `"${k}"`).join(", ")}.`);
|
|
53
|
+
if (shape.include !== void 0) assertStringArray(shape.include, "transform.include");
|
|
54
|
+
if (shape.exclude !== void 0) assertStringArray(shape.exclude, "transform.exclude");
|
|
55
|
+
} else throw new require_errors.VitestNativeTypeError("INVALID_OPTION", `"transform" must be an array of package names, or an object with "include" and/or "exclude".`);
|
|
56
|
+
}
|
|
45
57
|
if (options.presets !== void 0 && !Array.isArray(options.presets)) {
|
|
46
58
|
if (!(options.presets !== null && typeof options.presets === "object" && Object.values(options.presets).every((v) => typeof v === "boolean"))) throw new require_errors.VitestNativeTypeError("INVALID_OPTION", "\"presets\" must be an array of presets, or an object of booleans to switch auto-detected presets off (for example { navigation: false }).");
|
|
47
59
|
}
|
|
48
60
|
if (options.mocks !== void 0 && (options.mocks === null || Array.isArray(options.mocks) || typeof options.mocks !== "object")) throw new require_errors.VitestNativeTypeError("INVALID_OPTION", `"mocks" must be a plain object.`);
|
|
49
61
|
const hotRuntime = options.hotRuntime;
|
|
50
|
-
if (hotRuntime === void 0 || typeof hotRuntime === "boolean") return;
|
|
51
|
-
if (hotRuntime === null || Array.isArray(hotRuntime) || typeof hotRuntime !== "object") throw new require_errors.VitestNativeTypeError("INVALID_OPTION", `"hotRuntime" must be a boolean or an options object.`);
|
|
62
|
+
if (hotRuntime === void 0 || typeof hotRuntime === "boolean" || hotRuntime === "auto") return;
|
|
63
|
+
if (hotRuntime === null || Array.isArray(hotRuntime) || typeof hotRuntime !== "object") throw new require_errors.VitestNativeTypeError("INVALID_OPTION", `"hotRuntime" must be a boolean, "auto", or an options object.`);
|
|
52
64
|
const hotOptions = hotRuntime;
|
|
53
65
|
for (const key of Object.keys(hotOptions)) if (!KNOWN_HOT_RUNTIME_OPTIONS.includes(key)) {
|
|
54
66
|
const suggestion = findClosest(key, KNOWN_HOT_RUNTIME_OPTIONS);
|
|
@@ -56,6 +68,7 @@ function validateOptions(options) {
|
|
|
56
68
|
}
|
|
57
69
|
if (hotOptions.recycleAfterFiles !== void 0) assertNonNegativeInteger(hotOptions.recycleAfterFiles, "hotRuntime.recycleAfterFiles");
|
|
58
70
|
if (hotOptions.memoryLimit !== void 0) assertNonNegativeInteger(hotOptions.memoryLimit, "hotRuntime.memoryLimit");
|
|
71
|
+
if (hotOptions.allowUnboundedMemory !== void 0 && typeof hotOptions.allowUnboundedMemory !== "boolean") throw new require_errors.VitestNativeTypeError("INVALID_OPTION", `"hotRuntime.allowUnboundedMemory" must be a boolean.`);
|
|
59
72
|
if (hotOptions.preserveGlobals !== void 0) assertStringArray(hotOptions.preserveGlobals, "hotRuntime.preserveGlobals");
|
|
60
73
|
if (hotOptions.esmGeneration !== void 0 && typeof hotOptions.esmGeneration !== "boolean") throw new require_errors.VitestNativeTypeError("INVALID_OPTION", `"hotRuntime.esmGeneration" must be a boolean.`);
|
|
61
74
|
}
|
|
@@ -161,14 +174,47 @@ const PEER_REQUIREMENTS = [
|
|
|
161
174
|
* worker loads this file directly, so it must stay that way — module-level state
|
|
162
175
|
* would exist twice.
|
|
163
176
|
*/
|
|
177
|
+
/** Any file under a node_modules directory. */
|
|
178
|
+
const NODE_MODULES_PATH = /[\\/]node_modules[\\/]/;
|
|
164
179
|
/**
|
|
165
180
|
* React Native's own source, including the `@react-native/*` packages. Node owns
|
|
166
181
|
* these unconditionally: the Flow strip, the boundary mocks and the precompiled
|
|
167
182
|
* registry are all Node loader hooks.
|
|
168
183
|
*/
|
|
169
184
|
const REACT_NATIVE_PATH = /[\\/]node_modules[\\/](react-native|@react-native)[\\/]/;
|
|
185
|
+
/**
|
|
186
|
+
* A directory in the form Node's module loader reports paths: fs.realpathSync, not
|
|
187
|
+
* realpathSync.native. The native call expands Windows 8.3 short names (RUNNER~1) and
|
|
188
|
+
* rewrites letter case on case-insensitive disks, so a directory it returns can fail
|
|
189
|
+
* to contain the module ids Node hands the matchers.
|
|
190
|
+
*/
|
|
191
|
+
function canonicalDir(dir) {
|
|
192
|
+
try {
|
|
193
|
+
return node_fs.default.realpathSync(dir);
|
|
194
|
+
} catch {
|
|
195
|
+
return dir;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Resolve only from a physical node_modules directory at/above the project.
|
|
200
|
+
*
|
|
201
|
+
* Unlike createRequire.resolve(), this deliberately ignores NODE_PATH and loader
|
|
202
|
+
* hooks. It is for dependencies whose presence must be consumer-visible rather than
|
|
203
|
+
* borrowed from the test runner's own install.
|
|
204
|
+
*/
|
|
205
|
+
function installedPackageDirOf(name, projectRoot) {
|
|
206
|
+
const packagePath = name.split("/");
|
|
207
|
+
let dir = node_path.default.resolve(projectRoot);
|
|
208
|
+
for (;;) {
|
|
209
|
+
const candidate = node_path.default.join(dir, "node_modules", ...packagePath);
|
|
210
|
+
if (node_fs.default.existsSync(node_path.default.join(candidate, "package.json"))) return canonicalDir(candidate);
|
|
211
|
+
const parent = node_path.default.dirname(dir);
|
|
212
|
+
if (parent === dir) return null;
|
|
213
|
+
dir = parent;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
170
216
|
/** Escape a string for literal use inside a RegExp. */
|
|
171
|
-
function escapeRe(value) {
|
|
217
|
+
function escapeRe$1(value) {
|
|
172
218
|
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
173
219
|
}
|
|
174
220
|
/** Forward slashes, the form Vitest presents module ids in. */
|
|
@@ -207,7 +253,7 @@ function containsPath(dir, target) {
|
|
|
207
253
|
function packageDirOf(name, projectRoot) {
|
|
208
254
|
const req = (0, node_module.createRequire)(node_path.default.join(projectRoot, "package.json"));
|
|
209
255
|
try {
|
|
210
|
-
return node_path.default.dirname(req.resolve(`${name}/package.json`));
|
|
256
|
+
return canonicalDir(node_path.default.dirname(req.resolve(`${name}/package.json`)));
|
|
211
257
|
} catch {}
|
|
212
258
|
let dir;
|
|
213
259
|
try {
|
|
@@ -217,7 +263,7 @@ function packageDirOf(name, projectRoot) {
|
|
|
217
263
|
}
|
|
218
264
|
for (;;) {
|
|
219
265
|
try {
|
|
220
|
-
if ((0, node_module.createRequire)(node_path.default.join(dir, "index.js"))("./package.json").name === name) return dir;
|
|
266
|
+
if ((0, node_module.createRequire)(node_path.default.join(dir, "index.js"))("./package.json").name === name) return canonicalDir(dir);
|
|
221
267
|
} catch {}
|
|
222
268
|
const parent = node_path.default.dirname(dir);
|
|
223
269
|
if (parent === dir) return null;
|
|
@@ -251,13 +297,337 @@ function packageDirOf(name, projectRoot) {
|
|
|
251
297
|
* there is nothing to resolve against.
|
|
252
298
|
*/
|
|
253
299
|
function packagePatterns(name, projectRoot) {
|
|
254
|
-
const patterns = [new RegExp(`[\\\\/]node_modules[\\\\/]${escapeRe(name)}[\\\\/]`)];
|
|
300
|
+
const patterns = [new RegExp(`[\\\\/]node_modules[\\\\/]${escapeRe$1(name)}[\\\\/]`)];
|
|
255
301
|
if (!projectRoot) return patterns;
|
|
256
302
|
const dir = packageDirOf(name, projectRoot);
|
|
257
|
-
if (dir && !containsPath(dir, projectRoot)) patterns.push(new RegExp(`^${escapeRe(toPosix(dir).replace(/\/$/, ""))}[\\\\/]`));
|
|
303
|
+
if (dir && !containsPath(dir, projectRoot)) patterns.push(new RegExp(`^${escapeRe$1(toPosix(dir).replace(/\/$/, ""))}[\\\\/]`));
|
|
258
304
|
return patterns;
|
|
259
305
|
}
|
|
260
306
|
/**
|
|
307
|
+
* A predicate over the same patterns Vitest is given, so what the loader transforms
|
|
308
|
+
* and what Vitest externalizes cannot drift apart.
|
|
309
|
+
*
|
|
310
|
+
* Paths are normalised before testing: the directory anchor is written with forward
|
|
311
|
+
* slashes (the form Vitest presents module ids in) while callers here pass whatever
|
|
312
|
+
* Node handed them, which on Windows is backslashes.
|
|
313
|
+
*/
|
|
314
|
+
function buildPkgMatcher(pkgs, projectRoot) {
|
|
315
|
+
const patterns = (pkgs || []).flatMap((name) => packagePatterns(name, projectRoot));
|
|
316
|
+
return (file) => {
|
|
317
|
+
const norm = toPosix(file);
|
|
318
|
+
return patterns.some((re) => re.test(norm));
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
//#endregion
|
|
322
|
+
//#region src/native/ownership.mjs
|
|
323
|
+
/**
|
|
324
|
+
* Project-scoped module ownership policy for the native engine.
|
|
325
|
+
*
|
|
326
|
+
* This module does not resolve or load anything. It turns already-established
|
|
327
|
+
* project facts into the patterns and predicates consumed by Vitest config, the
|
|
328
|
+
* CommonJS hook, the ESM loader, hot reset, and diagnostics. Keeping it pure lets
|
|
329
|
+
* the Vite main process and every worker reconstruct the same decision.
|
|
330
|
+
*/
|
|
331
|
+
const OUTSIDE_NODE_MODULES = String.raw`^(?!.*[\\/]node_modules[\\/])`;
|
|
332
|
+
/** Files Vitest may execute as entries. They always belong to Vite. */
|
|
333
|
+
const TEST_ENTRY_PATTERNS = Object.freeze([new RegExp(String.raw`${OUTSIDE_NODE_MODULES}.*\.(?:test|spec)\.[cm]?[jt]sx?$`), new RegExp(String.raw`${OUTSIDE_NODE_MODULES}.*[\\/]__tests__[\\/].*\.[cm]?[jt]sx?$`)]);
|
|
334
|
+
/**
|
|
335
|
+
* Identity-sensitive runtime packages whose CJS entries cannot be dropped while
|
|
336
|
+
* their ESM entries remain resident. Shared by ESM generation and hot CJS reset.
|
|
337
|
+
*/
|
|
338
|
+
const RUNTIME_RESIDENT_PACKAGES = Object.freeze([
|
|
339
|
+
"react",
|
|
340
|
+
"react-is",
|
|
341
|
+
"react-dom",
|
|
342
|
+
"scheduler",
|
|
343
|
+
"react-reconciler",
|
|
344
|
+
"react-test-renderer",
|
|
345
|
+
"test-renderer",
|
|
346
|
+
"@testing-library/react-native"
|
|
347
|
+
]);
|
|
348
|
+
const RUNTIME_RESIDENT_PATH = /[\\/]node_modules[\\/](react|react-is|react-dom|scheduler|react-reconciler|react-test-renderer|test-renderer|@testing-library[\\/]react-native)[\\/]/;
|
|
349
|
+
/** The test runner/runtime must never receive per-file ESM generation stamps. */
|
|
350
|
+
const TEST_RUNTIME_RESIDENT_PACKAGES = Object.freeze([
|
|
351
|
+
"vitest",
|
|
352
|
+
"@vitest/*",
|
|
353
|
+
"chai",
|
|
354
|
+
"vitest-native"
|
|
355
|
+
]);
|
|
356
|
+
const TEST_RUNTIME_RESIDENT_PATH = /[\\/]node_modules[\\/](vitest|@vitest[\\/][^\\/]+|chai|vitest-native)[\\/]/;
|
|
357
|
+
const normalizeFile = (file) => file.replace(/\\/g, "/");
|
|
358
|
+
const cleanRawFileId = (file) => file.replace(/[?#].*$/, "");
|
|
359
|
+
const cleanFileId = (file) => normalizeFile(cleanRawFileId(file));
|
|
360
|
+
const unique = (values) => [...new Set((values || []).filter(Boolean))];
|
|
361
|
+
const escapeRe = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
362
|
+
function isRuntimeResidentFile(file) {
|
|
363
|
+
return RUNTIME_RESIDENT_PATH.test(normalizeFile(file));
|
|
364
|
+
}
|
|
365
|
+
function isTestRuntimeResidentFile(file) {
|
|
366
|
+
return TEST_RUNTIME_RESIDENT_PATH.test(normalizeFile(file));
|
|
367
|
+
}
|
|
368
|
+
function decision(owner, format, transform, reset, reasons, evidence) {
|
|
369
|
+
return Object.freeze({
|
|
370
|
+
owner,
|
|
371
|
+
format,
|
|
372
|
+
transform,
|
|
373
|
+
reset,
|
|
374
|
+
reason: reasons[0],
|
|
375
|
+
reasons: Object.freeze(reasons),
|
|
376
|
+
evidence: Object.freeze(evidence)
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* Build one immutable policy for a Vitest project.
|
|
381
|
+
*
|
|
382
|
+
* `explicitTransforms` is the public `transform` include list.
|
|
383
|
+
* `ecosystemPackages` is the detected RN dependency closure.
|
|
384
|
+
* `runtimeTransforms` is for workers reconstructing the already-combined list from
|
|
385
|
+
* serialized setup data; config-time callers normally leave it empty.
|
|
386
|
+
*/
|
|
387
|
+
function createNativeOwnershipPolicy({ projectRoot = process.cwd(), explicitTransforms = [], ecosystemPackages = [], runtimeTransforms = [], runtimeTransformAugmentations = [], projectDirs = [], reactNativeRoots = [], serverDepsInlineAll = false } = {}) {
|
|
388
|
+
const enforcement = serverDepsInlineAll ? "overridden-by-inline-all" : "enforced";
|
|
389
|
+
const root = node_path.default.resolve(projectRoot);
|
|
390
|
+
const explicit = unique(explicitTransforms);
|
|
391
|
+
const explicitSet = new Set(explicit);
|
|
392
|
+
const ecosystem = unique(ecosystemPackages).filter((name) => !explicitSet.has(name));
|
|
393
|
+
const runtime = unique(runtimeTransforms).filter((name) => !explicitSet.has(name) && !ecosystem.includes(name));
|
|
394
|
+
const runtimeAugmentations = Object.freeze(unique(runtimeTransformAugmentations));
|
|
395
|
+
const nodeTransformPackages = Object.freeze([
|
|
396
|
+
...explicit,
|
|
397
|
+
...ecosystem,
|
|
398
|
+
...runtime
|
|
399
|
+
]);
|
|
400
|
+
const inferredReactNativeRoot = installedPackageDirOf("react-native", root);
|
|
401
|
+
const normalizedReactNativeRoots = Object.freeze(unique([inferredReactNativeRoot, ...reactNativeRoots]).map((dir) => node_path.default.resolve(dir)));
|
|
402
|
+
const reactNativeRootPatterns = normalizedReactNativeRoots.map((dir) => new RegExp(`^${normalizeFile(dir).replace(/\/$/, "").split("/").map(escapeRe).join("[\\\\/]")}[\\\\/]`));
|
|
403
|
+
const isReactNativeCore = (file, rawFile) => REACT_NATIVE_PATH.test(file) || normalizedReactNativeRoots.some((dir) => containsPath(dir, cleanRawFileId(rawFile)));
|
|
404
|
+
const reactNativePathFor = (rawFile) => {
|
|
405
|
+
const clean = cleanRawFileId(rawFile);
|
|
406
|
+
const file = normalizeFile(clean);
|
|
407
|
+
if (REACT_NATIVE_PATH.test(file)) return file;
|
|
408
|
+
const packageRoot = normalizedReactNativeRoots.find((dir) => containsPath(dir, clean));
|
|
409
|
+
if (!packageRoot) return null;
|
|
410
|
+
return `/react-native/${normalizeFile(node_path.default.relative(packageRoot, clean))}`;
|
|
411
|
+
};
|
|
412
|
+
const externalPatterns = [
|
|
413
|
+
REACT_NATIVE_PATH,
|
|
414
|
+
...reactNativeRootPatterns,
|
|
415
|
+
...nodeTransformPackages.flatMap((name) => packagePatterns(name, root))
|
|
416
|
+
];
|
|
417
|
+
const matchesNodeTransformedFile = buildPkgMatcher(nodeTransformPackages, root);
|
|
418
|
+
const explicitMatcher = buildPkgMatcher(explicit, root);
|
|
419
|
+
const ecosystemMatcher = buildPkgMatcher(ecosystem, root);
|
|
420
|
+
const runtimeMatcher = buildPkgMatcher(runtime, root);
|
|
421
|
+
const normalizedProjectDirs = Object.freeze(unique(projectDirs).map((dir) => node_path.default.resolve(dir)));
|
|
422
|
+
const decideFile = (rawFile) => {
|
|
423
|
+
const file = cleanFileId(rawFile);
|
|
424
|
+
if (TEST_ENTRY_PATTERNS.some((pattern) => pattern.test(file))) return decision("vite", "source", "vite", "per-file", ["test-entry"], [file]);
|
|
425
|
+
const runtimeResident = isRuntimeResidentFile(file);
|
|
426
|
+
const testRuntimeResident = isTestRuntimeResidentFile(file);
|
|
427
|
+
if (isReactNativeCore(file, rawFile)) return decision("node", "cjs", "registry", "worker-resident", ["react-native-core"], [normalizedReactNativeRoots.find((dir) => containsPath(dir, cleanRawFileId(rawFile))) ?? "react-native/@react-native path", "preloaded before the hot reset baseline"]);
|
|
428
|
+
if (!NODE_MODULES_PATH.test(file)) {
|
|
429
|
+
const projectDir = normalizedProjectDirs.find((dir) => containsPath(dir, cleanRawFileId(rawFile)));
|
|
430
|
+
if (projectDir) return decision("vite", "source", "vite", "per-file", ["project-source"], [projectDir]);
|
|
431
|
+
}
|
|
432
|
+
if (explicitMatcher(file)) return decision("node", "package", "native-babel", runtimeResident ? "worker-resident" : "per-file", runtimeResident ? ["explicit-transform", "identity-sensitive-runtime"] : ["explicit-transform"], runtimeResident ? ["reactNative.transform.include", "CJS/ESM identity must remain stable"] : ["reactNative.transform.include"]);
|
|
433
|
+
if (ecosystemMatcher(file)) return decision("node", "package", "native-babel", runtimeResident ? "worker-resident" : "per-file", runtimeResident ? ["ecosystem-detected", "identity-sensitive-runtime"] : ["ecosystem-detected"], runtimeResident ? ["React Native dependency closure", "CJS/ESM identity must remain stable"] : ["React Native dependency closure"]);
|
|
434
|
+
if (runtimeMatcher(file)) return decision("node", "package", "native-babel", runtimeResident ? "worker-resident" : "per-file", runtimeResident ? ["runtime-transform", "identity-sensitive-runtime"] : ["runtime-transform"], runtimeResident ? ["serialized worker transform set", "CJS/ESM identity must remain stable"] : ["serialized worker transform set"]);
|
|
435
|
+
if (runtimeResident) return decision("vitest-default", "package", "default", "worker-resident-if-external", ["identity-sensitive-runtime"], ["Vitest decides whether this package is inlined or external", "if external, CJS/ESM identity must remain stable"]);
|
|
436
|
+
if (testRuntimeResident) return decision("vitest-default", "package", "default", "worker-resident-if-external", ["test-runtime"], ["Vitest decides whether this package is inlined or external", "if external, runner identity must remain stable"]);
|
|
437
|
+
return decision("vitest-default", "unknown", "default", "vitest-default", ["delegated"], ["not governed by native ownership policy"]);
|
|
438
|
+
};
|
|
439
|
+
const manifest = () => Object.freeze({
|
|
440
|
+
version: 1,
|
|
441
|
+
enforcement,
|
|
442
|
+
projectRoot: root,
|
|
443
|
+
projectDirs: normalizedProjectDirs,
|
|
444
|
+
reactNativeRoots: normalizedReactNativeRoots,
|
|
445
|
+
nodeTransformPackages,
|
|
446
|
+
runtimeTransformAugmentations: runtimeAugmentations,
|
|
447
|
+
identityResidentPackages: RUNTIME_RESIDENT_PACKAGES,
|
|
448
|
+
testRuntimeResidentPackages: TEST_RUNTIME_RESIDENT_PACKAGES,
|
|
449
|
+
rules: Object.freeze([
|
|
450
|
+
Object.freeze({
|
|
451
|
+
effect: "owner-transform-reset",
|
|
452
|
+
owner: "node",
|
|
453
|
+
transform: "registry",
|
|
454
|
+
reset: "worker-resident",
|
|
455
|
+
reason: "react-native-core",
|
|
456
|
+
packages: Object.freeze(["react-native", "@react-native/*"]),
|
|
457
|
+
roots: normalizedReactNativeRoots
|
|
458
|
+
}),
|
|
459
|
+
Object.freeze({
|
|
460
|
+
effect: "owner-transform",
|
|
461
|
+
owner: "node",
|
|
462
|
+
transform: "native-babel",
|
|
463
|
+
reason: "explicit-transform",
|
|
464
|
+
packages: Object.freeze(explicit)
|
|
465
|
+
}),
|
|
466
|
+
Object.freeze({
|
|
467
|
+
effect: "owner-transform",
|
|
468
|
+
owner: "node",
|
|
469
|
+
transform: "native-babel",
|
|
470
|
+
reason: "ecosystem-detected",
|
|
471
|
+
packages: Object.freeze(ecosystem)
|
|
472
|
+
}),
|
|
473
|
+
Object.freeze({
|
|
474
|
+
effect: "owner-transform",
|
|
475
|
+
owner: "node",
|
|
476
|
+
transform: "native-babel",
|
|
477
|
+
reason: "runtime-transform",
|
|
478
|
+
packages: Object.freeze(runtime)
|
|
479
|
+
}),
|
|
480
|
+
Object.freeze({
|
|
481
|
+
effect: "owner-transform-reset",
|
|
482
|
+
owner: "vite",
|
|
483
|
+
transform: "vite",
|
|
484
|
+
reset: "per-file",
|
|
485
|
+
reason: "project-source",
|
|
486
|
+
roots: normalizedProjectDirs
|
|
487
|
+
}),
|
|
488
|
+
Object.freeze({
|
|
489
|
+
effect: "owner-transform-reset",
|
|
490
|
+
owner: "vite",
|
|
491
|
+
transform: "vite",
|
|
492
|
+
reset: "per-file",
|
|
493
|
+
reason: "test-entry",
|
|
494
|
+
patterns: Object.freeze(TEST_ENTRY_PATTERNS.map(String))
|
|
495
|
+
}),
|
|
496
|
+
Object.freeze({
|
|
497
|
+
effect: "reset-if-external",
|
|
498
|
+
reset: "worker-resident",
|
|
499
|
+
reason: "identity-sensitive-runtime",
|
|
500
|
+
packages: RUNTIME_RESIDENT_PACKAGES
|
|
501
|
+
}),
|
|
502
|
+
Object.freeze({
|
|
503
|
+
effect: "reset-if-external",
|
|
504
|
+
reset: "worker-resident",
|
|
505
|
+
reason: "test-runtime",
|
|
506
|
+
packages: TEST_RUNTIME_RESIDENT_PACKAGES
|
|
507
|
+
})
|
|
508
|
+
])
|
|
509
|
+
});
|
|
510
|
+
return Object.freeze({
|
|
511
|
+
enforcement,
|
|
512
|
+
projectRoot: root,
|
|
513
|
+
nodeTransformPackages,
|
|
514
|
+
externalPatterns,
|
|
515
|
+
testEntryPatterns: [...TEST_ENTRY_PATTERNS],
|
|
516
|
+
matchesNodeTransformedFile,
|
|
517
|
+
isReactNativeFile: (file) => isReactNativeCore(cleanFileId(file), file),
|
|
518
|
+
reactNativePathFor,
|
|
519
|
+
decideFile,
|
|
520
|
+
manifest
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
/**
|
|
524
|
+
* Compare an actual graph observation with the owner assigned by the project.
|
|
525
|
+
* Delegated packages are intentionally inconclusive: Vitest is allowed to inline or
|
|
526
|
+
* externalize them. Likewise an inline-all override disables enforcement because it
|
|
527
|
+
* has explicitly taken precedence over the engine's externalization rules.
|
|
528
|
+
*/
|
|
529
|
+
function findNativeOwnershipConflict(policy, file, observedOwner) {
|
|
530
|
+
if (!policy || policy.enforcement !== "enforced") return null;
|
|
531
|
+
if (observedOwner !== "vite" && observedOwner !== "node") return null;
|
|
532
|
+
const expected = policy.decideFile(file);
|
|
533
|
+
if (expected.owner === "vitest-default" || expected.owner === observedOwner) return null;
|
|
534
|
+
return Object.freeze({
|
|
535
|
+
code: "NATIVE_MODULE_OWNER_CONFLICT",
|
|
536
|
+
file,
|
|
537
|
+
observedOwner,
|
|
538
|
+
expectedOwner: expected.owner,
|
|
539
|
+
decision: expected
|
|
540
|
+
});
|
|
541
|
+
}
|
|
542
|
+
/**
|
|
543
|
+
* Node-owned packages a Vitest inline rule would claim before externalization.
|
|
544
|
+
* Matching mirrors Vitest's `matchPattern`: strings are fragments below a module
|
|
545
|
+
* directory and regular expressions test the normalized resolved id.
|
|
546
|
+
*/
|
|
547
|
+
function findNativeInlineConflicts(policy, inline) {
|
|
548
|
+
if (!policy || inline == null) return [];
|
|
549
|
+
if (inline === true) return ["*"];
|
|
550
|
+
const patterns = Array.isArray(inline) ? inline : [inline];
|
|
551
|
+
const packages = [
|
|
552
|
+
"react-native",
|
|
553
|
+
"@react-native/*",
|
|
554
|
+
...policy.nodeTransformPackages
|
|
555
|
+
];
|
|
556
|
+
const conflicts = [];
|
|
557
|
+
for (const name of packages) {
|
|
558
|
+
const concrete = name === "@react-native/*" ? "@react-native/assets-registry" : name;
|
|
559
|
+
const probes = [`/project/node_modules/${concrete}/index.js`, `C:\\project\\node_modules\\${concrete.replaceAll("/", "\\")}\\index.js`];
|
|
560
|
+
const dir = name.includes("*") ? null : packageDirOf(name, policy.projectRoot);
|
|
561
|
+
if (dir) probes.push(`${normalizeFile(dir).replace(/\/$/, "")}/index.js`);
|
|
562
|
+
if (patterns.some((pattern) => {
|
|
563
|
+
if (typeof pattern === "string") {
|
|
564
|
+
const fragment = `/node_modules/${pattern.replace(/^[/\\]+/, "")}`;
|
|
565
|
+
return probes.some((probe) => normalizeFile(probe).includes(fragment));
|
|
566
|
+
}
|
|
567
|
+
if (!pattern || typeof pattern.test !== "function") return false;
|
|
568
|
+
return probes.some((probe) => {
|
|
569
|
+
pattern.lastIndex = 0;
|
|
570
|
+
const matched = pattern.test(normalizeFile(probe));
|
|
571
|
+
pattern.lastIndex = 0;
|
|
572
|
+
return matched;
|
|
573
|
+
});
|
|
574
|
+
})) conflicts.push(name);
|
|
575
|
+
}
|
|
576
|
+
return [...new Set(conflicts)];
|
|
577
|
+
}
|
|
578
|
+
/**
|
|
579
|
+
* Parse the project policy passed across the Vitest worker boundary.
|
|
580
|
+
*
|
|
581
|
+
* Treat environment data as untrusted even though the plugin produced it: users can
|
|
582
|
+
* set `test.env`, and a malformed diagnostic must never stop a test run. Unknown
|
|
583
|
+
* manifest versions deliberately return null rather than being guessed at.
|
|
584
|
+
*/
|
|
585
|
+
function parseNativeOwnershipManifest(raw) {
|
|
586
|
+
try {
|
|
587
|
+
const value = typeof raw === "string" ? JSON.parse(raw) : raw;
|
|
588
|
+
if (!value || typeof value !== "object" || value.version !== 1) return null;
|
|
589
|
+
if (value.enforcement !== "enforced" && value.enforcement !== "overridden-by-inline-all") return null;
|
|
590
|
+
if (typeof value.projectRoot !== "string") return null;
|
|
591
|
+
for (const key of [
|
|
592
|
+
"projectDirs",
|
|
593
|
+
"reactNativeRoots",
|
|
594
|
+
"nodeTransformPackages",
|
|
595
|
+
"runtimeTransformAugmentations",
|
|
596
|
+
"identityResidentPackages",
|
|
597
|
+
"testRuntimeResidentPackages",
|
|
598
|
+
"rules"
|
|
599
|
+
]) if (!Array.isArray(value[key])) return null;
|
|
600
|
+
if (![
|
|
601
|
+
...value.projectDirs,
|
|
602
|
+
...value.reactNativeRoots,
|
|
603
|
+
...value.nodeTransformPackages,
|
|
604
|
+
...value.runtimeTransformAugmentations,
|
|
605
|
+
...value.identityResidentPackages,
|
|
606
|
+
...value.testRuntimeResidentPackages
|
|
607
|
+
].every((entry) => typeof entry === "string")) return null;
|
|
608
|
+
return value;
|
|
609
|
+
} catch {
|
|
610
|
+
return null;
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
/** Human-readable lines for diagnostics and `doctor`; generated from the manifest. */
|
|
614
|
+
function formatNativeOwnershipManifest(input) {
|
|
615
|
+
const manifest = parseNativeOwnershipManifest(input);
|
|
616
|
+
if (!manifest) return ["ownership manifest unavailable or invalid"];
|
|
617
|
+
const list = (values) => values.length > 0 ? values.join(", ") : "(none)";
|
|
618
|
+
const lines = [
|
|
619
|
+
`project: ${manifest.projectRoot}`,
|
|
620
|
+
`Vite / reset per file: ${list(manifest.projectDirs)} plus test entries`,
|
|
621
|
+
`Node / worker resident: react-native, @react-native/* (${list(manifest.reactNativeRoots)})`,
|
|
622
|
+
`Node / native transform / reset per file: ${list(manifest.nodeTransformPackages)}`,
|
|
623
|
+
`worker-time transform augmentations: ${list(manifest.runtimeTransformAugmentations)}`,
|
|
624
|
+
`resident if Vitest externalizes them: ${list(manifest.identityResidentPackages)}`,
|
|
625
|
+
`test runtime resident if external: ${list(manifest.testRuntimeResidentPackages)}`
|
|
626
|
+
];
|
|
627
|
+
if (manifest.enforcement === "overridden-by-inline-all") lines.push("WARNING: server.deps.inline=true takes precedence over Node ownership; graph uniqueness is not guaranteed");
|
|
628
|
+
return lines;
|
|
629
|
+
}
|
|
630
|
+
/**
|
|
261
631
|
* The native engine's dependencies that do NOT resolve from the project root.
|
|
262
632
|
*
|
|
263
633
|
* react-native itself is part of the check: the Babel toolchain alone chose
|
|
@@ -485,11 +855,12 @@ function manifestsFrom(projectRoot) {
|
|
|
485
855
|
* test infrastructure in NEVER_INLINE, and anything the consumer listed explicitly
|
|
486
856
|
* in `transform` — that option keeps its existing meaning and takes precedence.
|
|
487
857
|
*/
|
|
488
|
-
function detectEcosystemPackages(projectRoot, explicit = [], testRoots = [], neverTransform = []) {
|
|
858
|
+
function detectEcosystemPackages(projectRoot, explicit = [], testRoots = [], neverTransform = [], activePresets) {
|
|
489
859
|
const roots = (Array.isArray(projectRoot) ? projectRoot : [projectRoot]).filter(Boolean);
|
|
860
|
+
const shadowed = Object.entries(require_preset_map.AUTO_DETECT_PRESETS).filter(([, presetName]) => activePresets === void 0 || activePresets.includes(presetName)).map(([pkg]) => pkg);
|
|
490
861
|
const skip = /* @__PURE__ */ new Set([
|
|
491
862
|
...NEVER_INLINE,
|
|
492
|
-
...
|
|
863
|
+
...shadowed,
|
|
493
864
|
...explicit,
|
|
494
865
|
...neverTransform
|
|
495
866
|
]);
|
|
@@ -603,16 +974,16 @@ Object.defineProperty(exports, "PEER_REQUIREMENTS", {
|
|
|
603
974
|
return PEER_REQUIREMENTS;
|
|
604
975
|
}
|
|
605
976
|
});
|
|
606
|
-
Object.defineProperty(exports, "
|
|
977
|
+
Object.defineProperty(exports, "containsPath", {
|
|
607
978
|
enumerable: true,
|
|
608
979
|
get: function() {
|
|
609
|
-
return
|
|
980
|
+
return containsPath;
|
|
610
981
|
}
|
|
611
982
|
});
|
|
612
|
-
Object.defineProperty(exports, "
|
|
983
|
+
Object.defineProperty(exports, "createNativeOwnershipPolicy", {
|
|
613
984
|
enumerable: true,
|
|
614
985
|
get: function() {
|
|
615
|
-
return
|
|
986
|
+
return createNativeOwnershipPolicy;
|
|
616
987
|
}
|
|
617
988
|
});
|
|
618
989
|
Object.defineProperty(exports, "detectEcosystemPackages", {
|
|
@@ -627,16 +998,28 @@ Object.defineProperty(exports, "detectEngine", {
|
|
|
627
998
|
return detectEngine;
|
|
628
999
|
}
|
|
629
1000
|
});
|
|
630
|
-
Object.defineProperty(exports, "
|
|
1001
|
+
Object.defineProperty(exports, "findNativeInlineConflicts", {
|
|
631
1002
|
enumerable: true,
|
|
632
1003
|
get: function() {
|
|
633
|
-
return
|
|
1004
|
+
return findNativeInlineConflicts;
|
|
634
1005
|
}
|
|
635
1006
|
});
|
|
636
|
-
Object.defineProperty(exports, "
|
|
1007
|
+
Object.defineProperty(exports, "findNativeOwnershipConflict", {
|
|
637
1008
|
enumerable: true,
|
|
638
1009
|
get: function() {
|
|
639
|
-
return
|
|
1010
|
+
return findNativeOwnershipConflict;
|
|
1011
|
+
}
|
|
1012
|
+
});
|
|
1013
|
+
Object.defineProperty(exports, "formatNativeOwnershipManifest", {
|
|
1014
|
+
enumerable: true,
|
|
1015
|
+
get: function() {
|
|
1016
|
+
return formatNativeOwnershipManifest;
|
|
1017
|
+
}
|
|
1018
|
+
});
|
|
1019
|
+
Object.defineProperty(exports, "packageDirOf", {
|
|
1020
|
+
enumerable: true,
|
|
1021
|
+
get: function() {
|
|
1022
|
+
return packageDirOf;
|
|
640
1023
|
}
|
|
641
1024
|
});
|
|
642
1025
|
Object.defineProperty(exports, "validateOptions", {
|
package/dist/errors.d.mts
CHANGED
|
@@ -12,17 +12,29 @@ export type VitestNativeErrorCode =
|
|
|
12
12
|
| "UNKNOWN_OPTION"
|
|
13
13
|
| "UNSUPPORTED_PEER"
|
|
14
14
|
| "UNSUPPORTED_POOL"
|
|
15
|
+
| "INLINE_BREAKS_OWNERSHIP"
|
|
16
|
+
| "MODULE_OWNER_CONFLICT"
|
|
15
17
|
| "ENGINE_REQUIRES_BABEL"
|
|
16
18
|
| "MOCKS_REQUIRE_MOCK_ENGINE"
|
|
19
|
+
| "METRO_CONFIG_LOAD_FAILED"
|
|
20
|
+
| "METRO_PROFILE_INVALID"
|
|
17
21
|
| "TRANSFORM_FAILED"
|
|
18
22
|
| "UNTRANSPILED_PACKAGE"
|
|
19
23
|
| "HOT_WORKER_ENV"
|
|
20
24
|
| "HOT_WORKER_PRELOAD"
|
|
21
25
|
| "HOT_RUNTIME_UNAVAILABLE"
|
|
26
|
+
| "HOT_MEMORY_UNBOUNDED"
|
|
27
|
+
| "HOT_RUNTIME_OVERRIDDEN"
|
|
28
|
+
| "SHARED_VITE_SERVER"
|
|
29
|
+
| "HOT_MEMORY_BUDGET_EXCEEDED"
|
|
30
|
+
| "HOT_STATE_CAPTURE_FAILED"
|
|
31
|
+
| "HOT_STATE_RESTORE_FAILED"
|
|
32
|
+
| "HOT_CJS_CACHE_RESET"
|
|
22
33
|
| "PRESET_UNAVAILABLE"
|
|
23
34
|
| "WRONG_ENGINE_FOR_HELPER"
|
|
24
35
|
| "HELPERS_BEFORE_SETUP"
|
|
25
36
|
| "JEST_API_UNSUPPORTED"
|
|
37
|
+
| "REQUIRE_ACTUAL_ALIAS_UNSUPPORTED"
|
|
26
38
|
| "MATCHER_BAD_RECEIVER";
|
|
27
39
|
|
|
28
40
|
export interface VitestNativeErrorOptions {
|
package/dist/helpers.cjs
CHANGED
|
@@ -149,9 +149,12 @@ function resetAllMocks() {
|
|
|
149
149
|
originalNativeModules = null;
|
|
150
150
|
}
|
|
151
151
|
const presetMocks = globalThis.__vitest_native_preset_mocks;
|
|
152
|
-
if (presetMocks)
|
|
153
|
-
|
|
154
|
-
|
|
152
|
+
if (presetMocks) {
|
|
153
|
+
const built = presetMocks[Symbol.for("vitest-native.presets-built")];
|
|
154
|
+
for (const mod of built ? [...built.values()] : Object.values(presetMocks)) {
|
|
155
|
+
if (mod?._reset) mod._reset();
|
|
156
|
+
if (mod?._resetStore) mod._resetStore();
|
|
157
|
+
}
|
|
155
158
|
}
|
|
156
159
|
}
|
|
157
160
|
//#endregion
|
package/dist/helpers.d.cts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
//#region src/helpers.d.ts
|
|
2
|
-
declare function setPlatform(os: "ios" | "android"): void;
|
|
3
|
-
declare function setDimensions(dims: {
|
|
2
|
+
export declare function setPlatform(os: "ios" | "android"): void;
|
|
3
|
+
export declare function setDimensions(dims: {
|
|
4
4
|
width: number;
|
|
5
5
|
height: number;
|
|
6
6
|
scale?: number;
|
|
7
7
|
fontScale?: number;
|
|
8
8
|
}): void;
|
|
9
|
-
declare function setColorScheme(scheme: "light" | "dark" | null): void;
|
|
10
|
-
declare function setInsets(insets: {
|
|
9
|
+
export declare function setColorScheme(scheme: "light" | "dark" | null): void;
|
|
10
|
+
export declare function setInsets(insets: {
|
|
11
11
|
top?: number;
|
|
12
12
|
right?: number;
|
|
13
13
|
bottom?: number;
|
|
@@ -19,8 +19,7 @@ declare function setInsets(insets: {
|
|
|
19
19
|
* a library calls that the preset does not model. Returns `false` when no
|
|
20
20
|
* preset mock exists for the package. Undone by `resetAllMocks()`.
|
|
21
21
|
*/
|
|
22
|
-
declare function extendPresetMock(pkg: string, overrides: Record<string, any>): boolean;
|
|
23
|
-
declare function mockNativeModule(name: string, impl: Record<string, any>): void;
|
|
24
|
-
declare function resetAllMocks(): void;
|
|
25
|
-
//#endregion
|
|
26
|
-
export { extendPresetMock, mockNativeModule, resetAllMocks, setColorScheme, setDimensions, setInsets, setPlatform };
|
|
22
|
+
export declare function extendPresetMock(pkg: string, overrides: Record<string, any>): boolean;
|
|
23
|
+
export declare function mockNativeModule(name: string, impl: Record<string, any>): void;
|
|
24
|
+
export declare function resetAllMocks(): void;
|
|
25
|
+
//#endregion
|
package/dist/helpers.d.mts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
//#region src/helpers.d.ts
|
|
2
|
-
declare function setPlatform(os: "ios" | "android"): void;
|
|
3
|
-
declare function setDimensions(dims: {
|
|
2
|
+
export declare function setPlatform(os: "ios" | "android"): void;
|
|
3
|
+
export declare function setDimensions(dims: {
|
|
4
4
|
width: number;
|
|
5
5
|
height: number;
|
|
6
6
|
scale?: number;
|
|
7
7
|
fontScale?: number;
|
|
8
8
|
}): void;
|
|
9
|
-
declare function setColorScheme(scheme: "light" | "dark" | null): void;
|
|
10
|
-
declare function setInsets(insets: {
|
|
9
|
+
export declare function setColorScheme(scheme: "light" | "dark" | null): void;
|
|
10
|
+
export declare function setInsets(insets: {
|
|
11
11
|
top?: number;
|
|
12
12
|
right?: number;
|
|
13
13
|
bottom?: number;
|
|
@@ -19,8 +19,7 @@ declare function setInsets(insets: {
|
|
|
19
19
|
* a library calls that the preset does not model. Returns `false` when no
|
|
20
20
|
* preset mock exists for the package. Undone by `resetAllMocks()`.
|
|
21
21
|
*/
|
|
22
|
-
declare function extendPresetMock(pkg: string, overrides: Record<string, any>): boolean;
|
|
23
|
-
declare function mockNativeModule(name: string, impl: Record<string, any>): void;
|
|
24
|
-
declare function resetAllMocks(): void;
|
|
25
|
-
//#endregion
|
|
26
|
-
export { extendPresetMock, mockNativeModule, resetAllMocks, setColorScheme, setDimensions, setInsets, setPlatform };
|
|
22
|
+
export declare function extendPresetMock(pkg: string, overrides: Record<string, any>): boolean;
|
|
23
|
+
export declare function mockNativeModule(name: string, impl: Record<string, any>): void;
|
|
24
|
+
export declare function resetAllMocks(): void;
|
|
25
|
+
//#endregion
|