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.
Files changed (77) hide show
  1. package/CHANGELOG.md +339 -0
  2. package/README.md +138 -48
  3. package/dist/cli.cjs +70 -5
  4. package/dist/cli.d.cts +2 -3
  5. package/dist/cli.d.mts +2 -3
  6. package/dist/cli.mjs +70 -5
  7. package/dist/{ecosystem-Duw40-mO.mjs → ecosystem-DFbU_MPe.mjs} +389 -18
  8. package/dist/{ecosystem-CEIF_-jq.cjs → ecosystem-DI1AhK_k.cjs} +408 -25
  9. package/dist/errors.d.mts +12 -0
  10. package/dist/helpers.cjs +6 -3
  11. package/dist/helpers.d.cts +8 -9
  12. package/dist/helpers.d.mts +8 -9
  13. package/dist/helpers.mjs +6 -3
  14. package/dist/{index-CPGq6p95.d.cts → index-BxzW2D7K.d.cts} +33 -9
  15. package/dist/{index-CmETArCM.d.mts → index-CEbwa4QU.d.mts} +33 -9
  16. package/dist/index.d.mts +4 -4
  17. package/dist/index.mjs +537 -118
  18. package/dist/jest-compat/aliases.d.mts +5 -0
  19. package/dist/jest-compat/aliases.mjs +65 -0
  20. package/dist/jest-compat/caller.mjs +53 -0
  21. package/dist/jest-compat/setup.mjs +72 -36
  22. package/dist/jest-compat.cjs +1 -3
  23. package/dist/jest-compat.d.cts +4 -5
  24. package/dist/jest-compat.d.mts +4 -5
  25. package/dist/jest-compat.mjs +1 -1
  26. package/dist/matchers.d.cts +9 -9
  27. package/dist/matchers.d.mts +9 -9
  28. package/dist/memory-6EPHrJA1.cjs +144 -0
  29. package/dist/memory-FYbP0_gg.mjs +126 -0
  30. package/dist/native/boundary.mjs +13 -2
  31. package/dist/native/bounded-process.mjs +165 -0
  32. package/dist/native/export-condition-recovery-preload.mjs +5 -0
  33. package/dist/native/export-condition-recovery.mjs +195 -0
  34. package/dist/native/globals.mjs +133 -5
  35. package/dist/native/hooks.mjs +131 -71
  36. package/dist/native/loader.mjs +41 -28
  37. package/dist/native/match.d.mts +3 -0
  38. package/dist/native/match.mjs +38 -2
  39. package/dist/native/metro-profile-compiler.mjs +234 -0
  40. package/dist/native/metro-profile.mjs +115 -0
  41. package/dist/native/module-reset.mjs +111 -6
  42. package/dist/native/ownership.d.mts +105 -0
  43. package/dist/native/ownership.mjs +474 -0
  44. package/dist/native/registry-compiler.mjs +43 -0
  45. package/dist/native/registry-process.mjs +124 -0
  46. package/dist/native/registry.mjs +139 -32
  47. package/dist/native/reset.mjs +305 -135
  48. package/dist/native/resolve.d.mts +20 -3
  49. package/dist/native/resolve.mjs +32 -12
  50. package/dist/native/rntl-hooks.mjs +76 -0
  51. package/dist/native/setup.mjs +81 -32
  52. package/dist/native/state-manifest.d.mts +22 -0
  53. package/dist/native/state-manifest.mjs +136 -0
  54. package/dist/native/transform.mjs +29 -8
  55. package/dist/native/worker.mjs +52 -4
  56. package/dist/pool-B4yesGhI.cjs +121 -0
  57. package/dist/pool-DjpOjOf3.mjs +119 -0
  58. package/dist/{presets-CoNf4ByH.cjs → presets-BYHmi7-W.cjs} +117 -18
  59. package/dist/{presets-DGProTaA.mjs → presets-DC-eM5IA.mjs} +117 -18
  60. package/dist/presets.d.mts +1 -1
  61. package/dist/presets.mjs +1 -1
  62. package/dist/rntl-matchers.d.ts +58 -12
  63. package/dist/serializer.cjs +4 -2
  64. package/dist/serializer.d.cts +3 -4
  65. package/dist/serializer.d.mts +3 -4
  66. package/dist/serializer.mjs +4 -2
  67. package/dist/setup.mjs +61 -50
  68. package/dist/worker-vitest-BGPo0ek6.mjs +49 -0
  69. package/dist/worker-vitest-BfiQB8ND.cjs +62 -0
  70. package/docs/hot-default-design.md +175 -88
  71. package/docs/migrating-from-jest.md +12 -5
  72. package/docs/migrating-from-vitest-react-native.md +4 -4
  73. package/docs/release-readiness.md +39 -13
  74. package/docs/versioning.md +19 -18
  75. package/package.json +42 -31
  76. package/dist/pool-BU-1ecIF.cjs +0 -122
  77. package/dist/pool-Bcxn9a3I.mjs +0 -118
package/dist/cli.cjs CHANGED
@@ -1,13 +1,29 @@
1
1
  #!/usr/bin/env node
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const require_rolldown_runtime = require("./rolldown-runtime-C0BPl7ul.cjs");
4
- const require_ecosystem = require("./ecosystem-CEIF_-jq.cjs");
4
+ const require_ecosystem = require("./ecosystem-DI1AhK_k.cjs");
5
5
  const require_preset_map = require("./preset-map-BoG19dLa.cjs");
6
+ const require_memory = require("./memory-6EPHrJA1.cjs");
6
7
  let node_fs = require("node:fs");
7
8
  node_fs = require_rolldown_runtime.__toESM(node_fs, 1);
8
9
  let node_path = require("node:path");
9
10
  node_path = require_rolldown_runtime.__toESM(node_path, 1);
10
11
  let node_module = require("node:module");
12
+ //#region src/native/state-manifest.mjs
13
+ const HOT_STATE_MANIFEST_ENTRIES = Object.freeze([
14
+ "vitest-runtime",
15
+ "native-boundary-mocks",
16
+ "react-native.dimensions",
17
+ "react-native.appearance",
18
+ "react-native.event-listeners",
19
+ "process.env",
20
+ "process.listeners",
21
+ "global.descriptors",
22
+ "console.descriptors",
23
+ "react-native.error-utils",
24
+ "expo.runtime"
25
+ ]);
26
+ //#endregion
11
27
  //#region src/cli/doctor.ts
12
28
  /**
13
29
  * `vitest-native doctor` — diagnose the project's environment: peer versions,
@@ -197,9 +213,30 @@ function runDoctor(root, nodeVersion = process.versions.node) {
197
213
  }
198
214
  lines.push("", "Engine");
199
215
  const rnVersion = packageVersion(rootFor("react-native"), "react-native");
200
- if (require_ecosystem.detectEngine("auto", rootFor("@react-native/babel-preset")).engine === "native") pass(`engine 'auto' resolves to NATIVE — real React Native${rnVersion ? ` ${rnVersion}` : ""} with @react-native/babel-preset + @babel/core present.`);
216
+ const decision = require_ecosystem.detectEngine("auto", rootFor("@react-native/babel-preset"));
217
+ if (decision.engine === "native") pass(`engine 'auto' resolves to NATIVE — real React Native${rnVersion ? ` ${rnVersion}` : ""} with @react-native/babel-preset + @babel/core present.`);
201
218
  else if (rnVersion) warn(`engine 'auto' resolves to MOCK: react-native ${rnVersion} is installed but @react-native/babel-preset and/or @babel/core do not resolve. Install both as devDependencies to run the real-RN native engine.`);
202
219
  else warn("engine 'auto' resolves to MOCK: react-native is not installed. That is fine for pure-logic suites; install react-native (+ its babel preset) for the native engine.");
220
+ if (decision.engine === "native") {
221
+ const inferredRoot = configRoot;
222
+ const inferredEcosystem = require_ecosystem.detectEcosystemPackages([.../* @__PURE__ */ new Set([root, configRoot])], [], root === configRoot ? [] : [root]);
223
+ const inferredOwnership = require_ecosystem.createNativeOwnershipPolicy({
224
+ projectRoot: inferredRoot,
225
+ ecosystemPackages: inferredEcosystem,
226
+ projectDirs: [.../* @__PURE__ */ new Set([root, configRoot])]
227
+ });
228
+ lines.push("", "Ownership model (inferred baseline)");
229
+ for (const line of require_ecosystem.formatNativeOwnershipManifest(inferredOwnership.manifest())) lines.push(` · ${line}`);
230
+ lines.push(" · This command does not execute Vitest config. Set diagnostics: true for the resolved static policy and worker-time registration lines.");
231
+ const memoryPlan = require_memory.createHotMemoryPlan();
232
+ lines.push("", "Hot runtime capacity (inferred baseline)");
233
+ for (const line of require_memory.formatHotMemoryPlan(memoryPlan)) lines.push(` · ${line}`);
234
+ if (memoryPlan.maxWorkers < 2) warn("this memory ceiling admits only one hot worker, but current Vitest batches one-worker hot suites into an unrecyclable task. Use the default runtime unless an external scheduler supplies the memory boundary.");
235
+ else lines.push(" · This is capacity, not proof that hotRuntime is enabled; the resolved run reports its actual plan with diagnostics:true.");
236
+ lines.push("", "Hot runtime state restoration");
237
+ lines.push(` · ${HOT_STATE_MANIFEST_ENTRIES.join(", ")}`);
238
+ lines.push(" · Each entry is captured once, restored at the next file boundary and verified after all restore actions complete.");
239
+ }
203
240
  lines.push("", "Testing library");
204
241
  const rntl = packageVersion(rootFor("@testing-library/react-native"), "@testing-library/react-native");
205
242
  if (!rntl) warn("@testing-library/react-native not found — optional, but required for render()/screen queries.");
@@ -224,7 +261,7 @@ function runDoctor(root, nodeVersion = process.versions.node) {
224
261
  const expo = packageVersion(rootFor("expo"), "expo");
225
262
  if (expo) {
226
263
  lines.push("", "Expo");
227
- warn(`expo ${expo} detected. Expo-module components work via the auto-detected preset; suites that import Expo CORE internals (expo-router setups, dev-client wiring) can hit known limits — see the Jest migration guide's Expo notes.`);
264
+ pass(`expo ${expo} detected. Expo modules are covered by the auto-detected expo preset, and expo-router's own testing library runs as written; coming from jest-expo, run \`vitest-native migrate\`. See https://danfry1.github.io/vitest-native/guide/expo`);
228
265
  }
229
266
  lines.push("", "Config");
230
267
  const configFile = findConfigFile(configRoot);
@@ -405,6 +442,19 @@ function loadJestConfig(root) {
405
442
  config: null
406
443
  };
407
444
  }
445
+ /**
446
+ * Whether the plugin will auto-detect `preset` in this project: one of its packages is
447
+ * installed where the root can see it. Looked up on disk rather than with
448
+ * `require.resolve`, which a process with module hooks installed (the mock engine's
449
+ * test runtime) answers for every preset package.
450
+ */
451
+ function presetDetected(root, preset) {
452
+ const packages = Object.entries(require_preset_map.AUTO_DETECT_PRESETS).filter(([, name]) => name === preset).map(([pkg]) => pkg);
453
+ for (let dir = node_path.default.resolve(root);; dir = node_path.default.dirname(dir)) {
454
+ if (packages.some((pkg) => node_fs.default.existsSync(node_path.default.join(dir, "node_modules", pkg, "package.json")))) return true;
455
+ if (node_path.default.dirname(dir) === dir) return false;
456
+ }
457
+ }
408
458
  function analyzeJestConfig(root) {
409
459
  const { source, config } = loadJestConfig(root);
410
460
  const automatic = [];
@@ -417,6 +467,8 @@ function analyzeJestConfig(root) {
417
467
  const transformPkgs = [];
418
468
  const autoInlined = new Set(require_ecosystem.detectEcosystemPackages(root));
419
469
  let needsUrlImport = false;
470
+ const pluginOptions = [];
471
+ let fromJestExpo = false;
420
472
  const presetPkgs = new Set(Object.keys(require_preset_map.AUTO_DETECT_PRESETS));
421
473
  if (config) {
422
474
  const handled = /* @__PURE__ */ new Set();
@@ -426,7 +478,15 @@ function analyzeJestConfig(root) {
426
478
  };
427
479
  const preset = take("preset");
428
480
  if (preset === "react-native" || preset === "@react-native/jest-preset") automatic.push(`preset: '${preset}' → replaced by the reactNative() plugin.`);
429
- else if (preset === "jest-expo") attention.push("preset: 'jest-expo' → the reactNative() plugin + auto-detected expo preset replace most of it, but suites importing Expo CORE internals can hit known limits (see the migration guide's Expo notes).");
481
+ else if (preset === "jest-expo" || preset === "jest-expo/ios" || preset === "jest-expo/android") {
482
+ fromJestExpo = true;
483
+ const android = preset === "jest-expo/android";
484
+ if (android) pluginOptions.push(`platform: 'android'`);
485
+ automatic.push(`preset: '${preset}' → replaced by the reactNative() plugin${android ? " with platform: 'android'" : ""}; the Expo modules it mocked are covered by the auto-detected expo preset.`);
486
+ } else if (preset === "jest-expo/universal") {
487
+ fromJestExpo = true;
488
+ attention.push("preset: 'jest-expo/universal' runs one Jest project per platform. Define a Vitest project for each native platform (reactNative({ platform: 'ios' }) and reactNative({ platform: 'android' })); its web and node projects are not React Native renders and stay outside vitest-native.");
489
+ } else if (preset === "jest-expo/web" || preset === "jest-expo/node") attention.push(`preset: '${preset}' targets ${preset.slice(10)}, not a React Native render; run these suites without vitest-native.`);
430
490
  else if (preset) attention.push(`preset: '${preset}' — unknown preset; review what it configured.`);
431
491
  for (const key of ["setupFiles", "setupFilesAfterEnv"]) {
432
492
  const files = take(key);
@@ -533,7 +593,12 @@ function analyzeJestConfig(root) {
533
593
  presetCovered.push(`__mocks__/${candidate} — the ${preset} preset covers this; delete the manual mock.`);
534
594
  }
535
595
  }
536
- const transformLine = transformPkgs.length ? `reactNative({ transform: [${transformPkgs.map((p) => JSON.stringify(p)).join(", ")}] })` : `reactNative()`;
596
+ if (fromJestExpo && presetDetected(root, "navigation") && !node_fs.default.existsSync(node_path.default.join(root, "__mocks__", "@react-navigation"))) {
597
+ pluginOptions.push(`presets: { navigation: false }`);
598
+ automatic.push("jest-expo renders the real React Navigation → presets: { navigation: false }, so screens keep running in real navigators.");
599
+ }
600
+ if (transformPkgs.length) pluginOptions.unshift(`transform: [${transformPkgs.map((p) => JSON.stringify(p)).join(", ")}]`);
601
+ const transformLine = pluginOptions.length ? `reactNative({ ${pluginOptions.join(", ")} })` : `reactNative()`;
537
602
  return {
538
603
  source,
539
604
  automatic,
package/dist/cli.d.cts CHANGED
@@ -1,4 +1,3 @@
1
1
  //#region src/cli/index.d.ts
2
- declare function main(argv: string[], log?: (line: string) => void): number;
3
- //#endregion
4
- export { main };
2
+ export declare function main(argv: string[], log?: (line: string) => void): number;
3
+ //#endregion
package/dist/cli.d.mts CHANGED
@@ -1,4 +1,3 @@
1
1
  //#region src/cli/index.d.ts
2
- declare function main(argv: string[], log?: (line: string) => void): number;
3
- //#endregion
4
- export { main };
2
+ export declare function main(argv: string[], log?: (line: string) => void): number;
3
+ //#endregion
package/dist/cli.mjs CHANGED
@@ -1,9 +1,25 @@
1
1
  #!/usr/bin/env node
2
- import { l as validatePeerDependency, n as detectEngine, s as PEER_REQUIREMENTS, t as detectEcosystemPackages } from "./ecosystem-Duw40-mO.mjs";
2
+ import { d as validatePeerDependency, l as PEER_REQUIREMENTS, n as detectEngine, o as formatNativeOwnershipManifest, r as createNativeOwnershipPolicy, t as detectEcosystemPackages } from "./ecosystem-DFbU_MPe.mjs";
3
3
  import { t as AUTO_DETECT_PRESETS } from "./preset-map-DuX0ocdn.mjs";
4
+ import { n as formatHotMemoryPlan, t as createHotMemoryPlan } from "./memory-FYbP0_gg.mjs";
4
5
  import { createRequire } from "node:module";
5
6
  import fs from "node:fs";
6
7
  import path from "node:path";
8
+ //#region src/native/state-manifest.mjs
9
+ const HOT_STATE_MANIFEST_ENTRIES = Object.freeze([
10
+ "vitest-runtime",
11
+ "native-boundary-mocks",
12
+ "react-native.dimensions",
13
+ "react-native.appearance",
14
+ "react-native.event-listeners",
15
+ "process.env",
16
+ "process.listeners",
17
+ "global.descriptors",
18
+ "console.descriptors",
19
+ "react-native.error-utils",
20
+ "expo.runtime"
21
+ ]);
22
+ //#endregion
7
23
  //#region src/cli/doctor.ts
8
24
  /**
9
25
  * `vitest-native doctor` — diagnose the project's environment: peer versions,
@@ -193,9 +209,30 @@ function runDoctor(root, nodeVersion = process.versions.node) {
193
209
  }
194
210
  lines.push("", "Engine");
195
211
  const rnVersion = packageVersion(rootFor("react-native"), "react-native");
196
- if (detectEngine("auto", rootFor("@react-native/babel-preset")).engine === "native") pass(`engine 'auto' resolves to NATIVE — real React Native${rnVersion ? ` ${rnVersion}` : ""} with @react-native/babel-preset + @babel/core present.`);
212
+ const decision = detectEngine("auto", rootFor("@react-native/babel-preset"));
213
+ if (decision.engine === "native") pass(`engine 'auto' resolves to NATIVE — real React Native${rnVersion ? ` ${rnVersion}` : ""} with @react-native/babel-preset + @babel/core present.`);
197
214
  else if (rnVersion) warn(`engine 'auto' resolves to MOCK: react-native ${rnVersion} is installed but @react-native/babel-preset and/or @babel/core do not resolve. Install both as devDependencies to run the real-RN native engine.`);
198
215
  else warn("engine 'auto' resolves to MOCK: react-native is not installed. That is fine for pure-logic suites; install react-native (+ its babel preset) for the native engine.");
216
+ if (decision.engine === "native") {
217
+ const inferredRoot = configRoot;
218
+ const inferredEcosystem = detectEcosystemPackages([.../* @__PURE__ */ new Set([root, configRoot])], [], root === configRoot ? [] : [root]);
219
+ const inferredOwnership = createNativeOwnershipPolicy({
220
+ projectRoot: inferredRoot,
221
+ ecosystemPackages: inferredEcosystem,
222
+ projectDirs: [.../* @__PURE__ */ new Set([root, configRoot])]
223
+ });
224
+ lines.push("", "Ownership model (inferred baseline)");
225
+ for (const line of formatNativeOwnershipManifest(inferredOwnership.manifest())) lines.push(` · ${line}`);
226
+ lines.push(" · This command does not execute Vitest config. Set diagnostics: true for the resolved static policy and worker-time registration lines.");
227
+ const memoryPlan = createHotMemoryPlan();
228
+ lines.push("", "Hot runtime capacity (inferred baseline)");
229
+ for (const line of formatHotMemoryPlan(memoryPlan)) lines.push(` · ${line}`);
230
+ if (memoryPlan.maxWorkers < 2) warn("this memory ceiling admits only one hot worker, but current Vitest batches one-worker hot suites into an unrecyclable task. Use the default runtime unless an external scheduler supplies the memory boundary.");
231
+ else lines.push(" · This is capacity, not proof that hotRuntime is enabled; the resolved run reports its actual plan with diagnostics:true.");
232
+ lines.push("", "Hot runtime state restoration");
233
+ lines.push(` · ${HOT_STATE_MANIFEST_ENTRIES.join(", ")}`);
234
+ lines.push(" · Each entry is captured once, restored at the next file boundary and verified after all restore actions complete.");
235
+ }
199
236
  lines.push("", "Testing library");
200
237
  const rntl = packageVersion(rootFor("@testing-library/react-native"), "@testing-library/react-native");
201
238
  if (!rntl) warn("@testing-library/react-native not found — optional, but required for render()/screen queries.");
@@ -220,7 +257,7 @@ function runDoctor(root, nodeVersion = process.versions.node) {
220
257
  const expo = packageVersion(rootFor("expo"), "expo");
221
258
  if (expo) {
222
259
  lines.push("", "Expo");
223
- warn(`expo ${expo} detected. Expo-module components work via the auto-detected preset; suites that import Expo CORE internals (expo-router setups, dev-client wiring) can hit known limits — see the Jest migration guide's Expo notes.`);
260
+ pass(`expo ${expo} detected. Expo modules are covered by the auto-detected expo preset, and expo-router's own testing library runs as written; coming from jest-expo, run \`vitest-native migrate\`. See https://danfry1.github.io/vitest-native/guide/expo`);
224
261
  }
225
262
  lines.push("", "Config");
226
263
  const configFile = findConfigFile(configRoot);
@@ -401,6 +438,19 @@ function loadJestConfig(root) {
401
438
  config: null
402
439
  };
403
440
  }
441
+ /**
442
+ * Whether the plugin will auto-detect `preset` in this project: one of its packages is
443
+ * installed where the root can see it. Looked up on disk rather than with
444
+ * `require.resolve`, which a process with module hooks installed (the mock engine's
445
+ * test runtime) answers for every preset package.
446
+ */
447
+ function presetDetected(root, preset) {
448
+ const packages = Object.entries(AUTO_DETECT_PRESETS).filter(([, name]) => name === preset).map(([pkg]) => pkg);
449
+ for (let dir = path.resolve(root);; dir = path.dirname(dir)) {
450
+ if (packages.some((pkg) => fs.existsSync(path.join(dir, "node_modules", pkg, "package.json")))) return true;
451
+ if (path.dirname(dir) === dir) return false;
452
+ }
453
+ }
404
454
  function analyzeJestConfig(root) {
405
455
  const { source, config } = loadJestConfig(root);
406
456
  const automatic = [];
@@ -413,6 +463,8 @@ function analyzeJestConfig(root) {
413
463
  const transformPkgs = [];
414
464
  const autoInlined = new Set(detectEcosystemPackages(root));
415
465
  let needsUrlImport = false;
466
+ const pluginOptions = [];
467
+ let fromJestExpo = false;
416
468
  const presetPkgs = new Set(Object.keys(AUTO_DETECT_PRESETS));
417
469
  if (config) {
418
470
  const handled = /* @__PURE__ */ new Set();
@@ -422,7 +474,15 @@ function analyzeJestConfig(root) {
422
474
  };
423
475
  const preset = take("preset");
424
476
  if (preset === "react-native" || preset === "@react-native/jest-preset") automatic.push(`preset: '${preset}' → replaced by the reactNative() plugin.`);
425
- else if (preset === "jest-expo") attention.push("preset: 'jest-expo' → the reactNative() plugin + auto-detected expo preset replace most of it, but suites importing Expo CORE internals can hit known limits (see the migration guide's Expo notes).");
477
+ else if (preset === "jest-expo" || preset === "jest-expo/ios" || preset === "jest-expo/android") {
478
+ fromJestExpo = true;
479
+ const android = preset === "jest-expo/android";
480
+ if (android) pluginOptions.push(`platform: 'android'`);
481
+ automatic.push(`preset: '${preset}' → replaced by the reactNative() plugin${android ? " with platform: 'android'" : ""}; the Expo modules it mocked are covered by the auto-detected expo preset.`);
482
+ } else if (preset === "jest-expo/universal") {
483
+ fromJestExpo = true;
484
+ attention.push("preset: 'jest-expo/universal' runs one Jest project per platform. Define a Vitest project for each native platform (reactNative({ platform: 'ios' }) and reactNative({ platform: 'android' })); its web and node projects are not React Native renders and stay outside vitest-native.");
485
+ } else if (preset === "jest-expo/web" || preset === "jest-expo/node") attention.push(`preset: '${preset}' targets ${preset.slice(10)}, not a React Native render; run these suites without vitest-native.`);
426
486
  else if (preset) attention.push(`preset: '${preset}' — unknown preset; review what it configured.`);
427
487
  for (const key of ["setupFiles", "setupFilesAfterEnv"]) {
428
488
  const files = take(key);
@@ -529,7 +589,12 @@ function analyzeJestConfig(root) {
529
589
  presetCovered.push(`__mocks__/${candidate} — the ${preset} preset covers this; delete the manual mock.`);
530
590
  }
531
591
  }
532
- const transformLine = transformPkgs.length ? `reactNative({ transform: [${transformPkgs.map((p) => JSON.stringify(p)).join(", ")}] })` : `reactNative()`;
592
+ if (fromJestExpo && presetDetected(root, "navigation") && !fs.existsSync(path.join(root, "__mocks__", "@react-navigation"))) {
593
+ pluginOptions.push(`presets: { navigation: false }`);
594
+ automatic.push("jest-expo renders the real React Navigation → presets: { navigation: false }, so screens keep running in real navigators.");
595
+ }
596
+ if (transformPkgs.length) pluginOptions.unshift(`transform: [${transformPkgs.map((p) => JSON.stringify(p)).join(", ")}]`);
597
+ const transformLine = pluginOptions.length ? `reactNative({ ${pluginOptions.join(", ")} })` : `reactNative()`;
533
598
  return {
534
599
  source,
535
600
  automatic,