vitest-native 0.14.0-rc.5 → 0.14.0-rc.8

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 (46) hide show
  1. package/CHANGELOG.md +91 -0
  2. package/README.md +30 -22
  3. package/dist/cli.cjs +35 -22
  4. package/dist/cli.mjs +35 -22
  5. package/dist/{ecosystem-lBGWAeOw.mjs → ecosystem-D6e1OVOg.mjs} +54 -5
  6. package/dist/{ecosystem-Bg7DgFeG.cjs → ecosystem-MFwkbnaC.cjs} +59 -4
  7. package/dist/errors.d.mts +1 -0
  8. package/dist/helpers.cjs +0 -6
  9. package/dist/helpers.mjs +0 -6
  10. package/dist/{index-B40lg28R.d.cts → index-BSyUeoga.d.mts} +34 -8
  11. package/dist/{index-D7-7BtcM.d.mts → index-bZ7AHqLc.d.cts} +35 -7
  12. package/dist/index.d.mts +1 -1
  13. package/dist/index.mjs +163 -25
  14. package/dist/matchers.d.cts +2 -1
  15. package/dist/matchers.d.mts +2 -1
  16. package/dist/native/assets.mjs +16 -9
  17. package/dist/native/babel-preset.d.mts +14 -0
  18. package/dist/native/babel-preset.mjs +56 -0
  19. package/dist/native/boundary.mjs +14 -2
  20. package/dist/native/expo-module-mocks.mjs +432 -0
  21. package/dist/native/expo-module-table-57.mjs +1925 -0
  22. package/dist/native/expo-module-table-58.mjs +2045 -0
  23. package/dist/native/expo-module-tables.mjs +6 -0
  24. package/dist/native/expo-native-modules.mjs +66 -0
  25. package/dist/native/globals.mjs +118 -3
  26. package/dist/native/hooks.mjs +24 -0
  27. package/dist/native/loader.mjs +79 -17
  28. package/dist/native/registry.mjs +4 -1
  29. package/dist/native/setup.mjs +86 -9
  30. package/dist/native/transform.mjs +51 -28
  31. package/dist/{preset-map-mriqY254.mjs → preset-map-BlBriTA0.mjs} +36 -3
  32. package/dist/{preset-map-mzfu_YUy.cjs → preset-map-jSFsNy1Q.cjs} +41 -2
  33. package/dist/preset-modules-BoLkaeEN.cjs +53 -0
  34. package/dist/preset-modules-CG8-G82P.mjs +36 -0
  35. package/dist/preset-modules.d.mts +16 -0
  36. package/dist/preset-modules.mjs +101 -0
  37. package/dist/preset-ready.mjs +9 -0
  38. package/dist/{presets-DC-eM5IA.mjs → presets--zrEWQC2.mjs} +983 -83
  39. package/dist/{presets-BYHmi7-W.cjs → presets-9f83H0WW.cjs} +1001 -82
  40. package/dist/presets.d.mts +2 -2
  41. package/dist/presets.mjs +1 -2
  42. package/dist/setup.mjs +37 -12
  43. package/docs/migrating-from-vitest-react-native.md +1 -1
  44. package/docs/release-readiness.md +5 -3
  45. package/docs/versioning.md +13 -5
  46. package/package.json +30 -25
package/CHANGELOG.md CHANGED
@@ -37,9 +37,86 @@
37
37
  `require()`, `jest.requireActual`'s dependencies and React Native's own requires of a mocked internal;
38
38
  `jest.isolateModules` and `jest.isolateModulesAsync` work. TypeScript app files that Node loads are
39
39
  compiled with the project's Babel config, as babel-jest compiles them.
40
+ - **Unistyles and Skia are mocked automatically.** The new `unistyles` and `skia` presets are
41
+ auto-detected. Remove Unistyles' `react-native-unistyles/mocks` setup file, whose `jest.mock()` calls
42
+ would replace the preset (`vitest-native migrate` removes it), and a hand-written Skia mock, which the
43
+ preset replaces. Skia's preset loads CanvasKit before each test file, about 20–30 ms;
44
+ `presets: { skia: false }` turns it off.
45
+ - **Presets of your own are listed by path.** A preset object of a project's own passed to `presets`
46
+ used to shadow its packages with undefined exports; it is now refused at startup. List the module that
47
+ exports it instead: `presets: { './test/presets/my-lib.ts': true }`.
48
+ - **Expo SDK 56–58 projects run real React Native with nothing extra installed.** When
49
+ `@react-native/babel-preset` does not resolve (from SDK 56, `babel-preset-expo` no longer depends on
50
+ it), the native engine compiles with Expo's preset, as Metro does. `reactNative()` used the mock
51
+ engine there before.
52
+ - **Expo's globals are installed before your setup files, and `fetch` stays Node's.** A `fetch` mocked
53
+ in a setup file, an MSW server, nock and undici's `MockAgent` keep working whether or not a test
54
+ imports `expo`. Every test file in an Expo project now sees Expo's `URL`, `structuredClone` and
55
+ `DOMException` polyfills, as under jest-expo.
56
+ - **Expo modules' own native-module mocks are served.** Values that were `undefined` are the mock's
57
+ (`digestStringAsync` resolves `""`), and a member a mock leaves out is `undefined` where the generic
58
+ stub gave a function.
59
+ - **An optional native module that is not installed reads as absent.** `requireOptionalNativeModule`
60
+ returns `null` for a module a package only probes for and no installed package defines, as on a
61
+ device.
62
+ - **Expo modules run as their installed packages.** Under the native engine, the `expo` preset no
63
+ longer replaces `expo-constants`, `expo-status-bar`, `expo-font`, `expo-asset`, `expo-splash-screen`
64
+ and `expo-linking`, so their whole API is the installed SDK's (`hide()`, `setOptions()`,
65
+ `useAssets` …) and their values are jest-expo's: `Constants.expoConfig` is `{}`,
66
+ `Linking.createURL()` needs a scheme mocked into `expo-constants`, and `Font.isLoaded()` is `false`
67
+ until a font loads. The Minor Changes entry lists each value; `presets: { expo: true }` keeps the
68
+ preset while a suite moves off it.
40
69
 
41
70
  ### Minor Changes
42
71
 
72
+ - 191c286: Under the native engine, Expo modules run as their installed packages, answering as they do under jest-expo. The `expo` preset no longer replaces `expo-constants`, `expo-status-bar`, `expo-font`, `expo-asset`, `expo-splash-screen` and `expo-linking` there; their own JavaScript runs, so their whole API is present and current with the installed SDK. `import { hide } from 'expo-splash-screen'`, Expo's call since SDK 52, was `undefined` under the preset (#319), as were `setOptions`, `useAssets`, `getLoadedFonts`, `canOpenURL` and others.
73
+
74
+ Their native modules answer as jest-expo answers them: from a package's own `mocks/`, else from Expo's table of the native modules, which jest-expo ships and vitest-native now carries for each SDK, extracted from jest-expo 57.0.6 and 58.0.12 (`src/native/expo-module-table-<sdk>.mjs`; a weekly check compares each with the newest jest-expo of its SDK, and fails when a new SDK has no table). The installed `expo`'s SDK picks the table. This also gives every other Expo module jest-expo's values: `Device.modelName` is `'mock'`, `Constants.statusBarHeight` is `54`. A constant the installed SDK's table does not list is `undefined`, as under jest-expo; on an SDK with no table of its own, the nearest SDK's table answers the members it lists and such a member keeps the stub's no-op function. On an Expo SDK 58 app, every probe of these six packages matches jest-expo (17 of 17, against 4 with the preset). One difference is deliberate: an asset a test `require`s is registered as Metro registers it, so `Asset.fromModule()` and `Font.loadAsync()` of it load, where jest-expo throws that it is missing from the asset registry.
75
+
76
+ What a suite that relied on the preset sees instead, each as under jest-expo:
77
+
78
+ - `Constants.expoConfig` is `{}` (was `{ name: 'test-app', slug: 'test-app', version: '1.0.0', extra: {} }`), so `expoConfig.name` and `expoConfig.extra` are `undefined`. `Constants.appOwnership` is `null` (was `'standalone'`), `executionEnvironment` is `'mock'` (was `'storeClient'`), and `getWebViewUserAgentAsync()` resolves `undefined`.
79
+ - `Linking.createURL()` and `Linking.parse()` throw for want of a scheme in the Expo manifest (they returned `exp://localhost:19000/…` URLs). A test that needs them mocks `expo-constants` with a scheme through `jest.mock` (the jest-compat layer), which now reaches expo-linking's own import of it, or mocks `expo-linking`; a `vi.mock` of `expo-constants` does not reach it yet (#322).
80
+ - `Font.isLoaded()` is `false` until a font is loaded (was always `true`), and `Asset.fromModule()` of a number that is not a bundled asset throws (it returned a made-up asset). Bundled images and fonts load through the real expo-asset and expo-font.
81
+ - `preventAutoHideAsync()` and `hideAsync()` resolve `undefined` (were `true`).
82
+
83
+ A suite can keep the preset while it moves off it with `reactNative({ presets: { expo: true } })`. The mock engine keeps the preset, whose `expo-splash-screen` now has `hide()` and `setOptions()`.
84
+
85
+ Three engine changes come with it. A module the ESM loader compiles is now loaded through Node's CommonJS loader, so an import and a require share one instance (expo-asset 57's asset registry was a second, empty copy) and a `jest.mock` factory reaches a package's own require of the mocked module. TypeScript under node_modules from a package nothing selected for compiling is compiled rather than refused (an Expo module installed without `expo`). `doctor` and `migrate` describe the new behaviour.
86
+
87
+ - 7b9b795: React Native 0.88 and Expo SDK 58 join the supported matrix
88
+
89
+ The verified range is now 0.81–0.88: the CI matrix gains a 0.88 row (and the Vitest 4 floor's newest-RN cell moves up to it), the workspace pins 0.88, and the published range statements follow. All 85 cross-check probes match on 0.88 and `check-compat` covers every stable export.
90
+
91
+ The packed Expo consumer moves to SDK 58 (React Native 0.88, RNTL 14), and an SDK 57 consumer stays alongside it. The SDK 58 consumer also checks that the presets provide every `expo-linking` and `expo-constants` member expo-router's build uses, and that loading `expo` and `expo-router` leaves Node's timers and `Promise` in place.
92
+
93
+ - 13f79b0: Under the native engine, an Expo module whose package ships a mock of its native module (`mocks/<Name>.ts`, generated by Expo for `expo-crypto`, `expo-file-system`, `expo-clipboard`, `expo-localization` and others) gets that mock as its native module, as under jest-expo. Its functions are `vi.fn`s that return the mock's values and reset between test files, classes keep their prototype, and members the mock leaves out are `undefined`. Before, every native module was a generic stub, so a package that read a value as it loaded failed: importing `expo-file-system/legacy` threw `p.replace is not a function`. Native modules without a package mock keep the generic stub.
94
+
95
+ - f107c6a: A `unistyles` preset for `react-native-unistyles` 3, which resolves styles in native code and could not load in tests. It is auto-detected when the package is installed. It covers everything Unistyles' own Jest mock does (themes from `StyleSheet.configure`, `StyleSheet.create`, `useUnistyles`, `withUnistyles`, `UnistylesRuntime`), and it follows the library's source where that mock does less:
96
+
97
+ - styles resolve as the device parses them: breakpoint values and `mq` keys against the screen, `_web` styles dropped;
98
+ - variants and compound variants apply by the device's rules, selected with `useVariants`;
99
+ - `StyleSheet.configure()` validates its input and picks the theme with the device runtime's messages; adaptive themes follow the colour scheme, and `setTheme`, `updateTheme` and `setAdaptiveThemes` take effect;
100
+ - `useUnistyles()`, `withUnistyles`, `Display`, `Hide` and `ScopedTheme` re-render on a theme or screen change;
101
+ - `ScopedTheme` scopes a theme to its children, and `withUnistyles` applies `uniProps`;
102
+ - `Display` and `Hide` follow `mq` against the screen size;
103
+ - `StyleSheet.flatten`, `compose`, `absoluteFill` and `hairlineWidth` are React Native's, as on a device;
104
+ - `resetAllMocks()` returns the theme to what `StyleSheet.configure()` set.
105
+
106
+ `vitest-native migrate` now deletes a library's own test setup file (such as `react-native-unistyles/mocks`) when a detected preset shadows that library, since its `jest.mock()` calls would replace the preset.
107
+
108
+ - 12a6dc5: A `skia` preset for Skia, which threw at import in tests ("Native Skia Module failed to correctly install JSI Bindings"). It covers both of Skia's package names, `react-native-skia` (2.15.0 and 3.x) and `@shopify/react-native-skia` (up to 2.14.0), shadows whichever is installed, and works under both engines.
109
+
110
+ - It loads CanvasKit, Skia compiled to WebAssembly, and serves Skia's own test mock over it, so the `Skia` API computes with real Skia, and `Canvas` and its drawing render as Views.
111
+ - Its named exports are read from the installed version's ESM build, since Skia's API changes between releases.
112
+ - It adds Skia's Reanimated helpers (`usePathValue`, `useTexture`, …), which the mock leaves out, and makes `matchFont` return a font.
113
+
114
+ The `Preset` type gains an optional async `prepare()`, which completes before any of the user's setup files or test files load, and `PresetModule` an optional `exportsFor()`, which reads the module's named exports from the installed package (or returns `null` when it is not installed, leaving it unshadowed). The skia preset uses both.
115
+
116
+ The project root given to test workers now follows `test.root` (or `--root`), as Vitest's does; a run started from a parent directory resolved packages from that directory in every worker.
117
+
118
+ - 51c351d: Presets of a project's own now work. A preset object passed to `presets: [...]` shadowed its packages with modules whose every export was undefined, under both engines: each test worker rebuilds the presets by name from vitest-native's own, and a preset's factories, being functions, cannot reach a worker from the config. A preset is now listed by the path of a module that default-exports it (or a function returning it): `presets: { './test/presets/my-lib.ts': true }` beside auto-detection, or `presets: ['./test/presets/my-lib.ts']` in a full list. The plugin reads its name and export names while loading the config, and each worker imports it, through Vitest so a TypeScript module loads. A preset object that is not exactly what one of vitest-native's factories returned, such as a built-in preset copied or extended, is refused at configuration time, naming the module form.
119
+
43
120
  - 6724815: Native engine: native module lookups answer the way a device does
44
121
 
45
122
  `NativeModules[name]` and `TurboModuleRegistry.get(name)` returned a stub for every name, so a module that no app registers looked present. Library feature detection then took the wrong branch: expo-constants checks `NativeModules.EXDevLauncher` and, finding it, threw at import while parsing the stub's `manifestString` as JSON.
@@ -145,6 +222,20 @@
145
222
 
146
223
  ### Patch Changes
147
224
 
225
+ - ce3be7a: Under the native engine, a test that imports `expo` or `expo-router` from Expo SDK 58 (React Native 0.88) no longer hangs. Expo's runtime requires `react-native/setup-env`, which replaced Node's timers with React Native's native-driven ones, so the first awaited timer never fired. That entry is now skipped, as `InitializeCore` already was. The `expo-linking` preset also adds `getLinkingURL`, `openURL` and `unwrapDevLaunchURL`, which expo-router 58 calls while rendering a route tree.
226
+
227
+ - 2ede5df: In an Expo project, the native engine installs Expo's runtime globals (`URL`, `structuredClone`, `DOMException` and the rest) before the project's setup files run, in every test file, as jest-expo does, instead of at a test's first `expo` import. A file that never imports Expo now sees Expo's polyfills for those globals, as under jest-expo. A `fetch` mocked in a setup file is no longer replaced once a test imports Expo. Global `fetch` stays Node's, so MSW, nock and undici's `MockAgent` keep intercepting, where Expo's native-driven `fetch` failed with `request.start is not a function`. Node's `FormData` also keeps working after Expo loads: Expo's patch for React Native's FormData made `append()` and `set()` throw.
228
+
229
+ - 2ac4de3: The native engine runs in an Expo project without `@react-native/babel-preset`. From SDK 56, `babel-preset-expo` carries React Native's Babel plugins itself and no longer depends on that preset, so a project created from the SDK 56, 57 or 58 template has none installed, and `reactNative()` fell back to the mock engine, where Expo modules failed to load. When `@react-native/babel-preset` does not resolve, the engine now compiles with Expo's preset (`expo/internal/babel-preset`), which Expo's Metro and jest-expo use in a project without a Babel config. A project that has `@react-native/babel-preset` keeps using it.
230
+
231
+ - 306b27a: Under the native engine, `expo-image` can be imported. `globalThis.expo.modules` answered every native module name, so a package probing for an optional module with `requireOptionalNativeModule` called into a stub instead of taking its fallback: expo-image found expo-observe's `ExpoObserve` and failed with `Cannot read properties of undefined (reading 'expo-image')`. A module that an installed package only probes for, and that no installed or local Expo module defines in its native sources, now reads as absent, as on a device. Every other module stays present, so a module that exists cannot read as missing. The scan is cached until the install changes.
232
+
233
+ - 61ae436: Preset mocks keep their behaviour through `vi.resetAllMocks()` and `mockReset: true`. A gesture-handler gesture built before a reset, such as `Gesture.Pan()` at module scope, keeps chaining. In the mock engine, `Platform.select()` follows `Platform.OS` after a reset, so a setup file's `setPlatform('android')` is no longer undone for `select()` while `Platform.OS` stays `"android"`. `Platform.select()` also picks by key presence, as React Native does, so an explicit `ios: undefined` selects `undefined`.
234
+
235
+ - de438fc: The reanimated preset's animation builders keep chaining after `vi.resetAllMocks()` or `mockReset: true`, so `LinearTransition.springify().damping(20)` and `SharedTransition.duration(300).custom(...)` no longer throw.
236
+
237
+ - df06716: Under the native engine, an imported BMP image's `width` and `height` are read as Metro 0.87.1 reads them. An OS/2 bitmap (12-byte header) now has its real dimensions instead of a misread width, and a file whose header size is not a bitmap's registers without dimensions, as other unreadable images do.
238
+
148
239
  - dc2543b: `migrate` writes Jest's mock-clearing behaviour correctly:
149
240
 
150
241
  - Jest's `resetMocks` becomes `test.mockReset`, Vitest's name for it. It was written as `test.resetMocks`, which Vitest ignores.
package/README.md CHANGED
@@ -4,8 +4,8 @@
4
4
 
5
5
  Run your React Native tests under Vitest, against **real React Native** — the same JavaScript that ships in your app, with only the native-module boundary mocked. That is the default and the point of the project. A lightweight pure-JS mock engine is available as an opt-in for fast, RN-free unit tests.
6
6
 
7
- > **Beta.** The release-supported native engine is validated across React Native 0.81–0.87,
8
- > Vite 6–8, Vitest 4–5, RNTL 12–14, bare apps, Expo SDK 57 (including expo-router's own testing
7
+ > **Beta.** The release-supported native engine is validated across React Native 0.81–0.88,
8
+ > Vite 6–8, Vitest 4–5, RNTL 12–14, bare apps, Expo SDK 58 and 57 (including expo-router's own testing
9
9
  > library), and hoisted monorepos. The hot
10
10
  > runtime (on by default where it can be bounded) is marked experimental because it uses Vitest's
11
11
  > experimental custom-pool APIs.
@@ -72,7 +72,9 @@ pnpm add -D vitest-native
72
72
  ```
73
73
 
74
74
  A real React Native project already provides what the native engine needs —
75
- `react-native`, `@react-native/babel-preset`, and `@babel/core`. Add
75
+ `react-native`, `@react-native/babel-preset`, and `@babel/core`. From Expo SDK 56,
76
+ `babel-preset-expo` no longer depends on `@react-native/babel-preset`, and the engine compiles
77
+ with Expo's own preset instead, as Metro does. Add
76
78
  `@testing-library/react-native` if you don't have it yet (the examples below use it):
77
79
 
78
80
  ```bash
@@ -202,13 +204,13 @@ Choose how React Native is provided to your tests:
202
204
  requires a device. Jest's `react-native` preset replaces many of these modules with
203
205
  stubs, so the native engine exercises behavior Jest's mocks skip (see [Fidelity](#fidelity)
204
206
  below). Best for components, integration, RNTL, virtualized lists, and anywhere a false
205
- pass is costly. Requires `@react-native/babel-preset` and `@babel/core` (present by
206
- default in React Native apps).
207
+ pass is costly. Requires `@react-native/babel-preset` (or, from Expo SDK 56, Expo's
208
+ preset) and `@babel/core`, present by default in React Native and Expo apps.
207
209
  - `'mock'` — a lightweight, pure-JS reimplementation of React Native with **zero extra
208
210
  dependencies**. Best for pure-logic/unit tests, maximum determinism, or when you can't
209
211
  add the babel deps. Like Jest's preset, it is a simplification — see [Fidelity](#fidelity).
210
- - `'auto'` _(default)_ — picks automatically, and **resolves to `'native'`** whenever
211
- `@react-native/babel-preset` and `@babel/core` are present (i.e. in any real RN app). It
212
+ - `'auto'` _(default)_ — picks automatically, and **resolves to `'native'`** whenever a React
213
+ Native Babel preset and `@babel/core` are present (i.e. in any real RN or Expo app). It
212
214
  falls back to `'mock'` only when those deps are absent, printing one line to explain why.
213
215
  So `reactNative()` with no options runs real React Native. Set `engine: 'mock'` to opt out.
214
216
 
@@ -555,6 +557,8 @@ export default defineConfig({
555
557
  | `presets.flashList()` | `@shopify/flash-list` | `FlashList` rendering its data through `renderItem`, the ref surface, v2 recycler hooks |
556
558
  | `presets.bottomSheet()` | `@gorhom/bottom-sheet` | `BottomSheet`, `BottomSheetModal` + provider, sheet views, scroll/list variants, `BottomSheetTextInput`, backdrop, footer |
557
559
  | `presets.keyboardController()` | `react-native-keyboard-controller` | `KeyboardProvider`, `KeyboardAvoidingView`, `KeyboardAwareScrollView`, `KeyboardStickyView`, `KeyboardToolbar`; the imperative `KeyboardController` is inert |
560
+ | `presets.unistyles()` | `react-native-unistyles`, `react-native-unistyles/reanimated` | Unistyles 3: `StyleSheet.configure`/`create` with themes, variants and compound variants, `useUnistyles`, `withUnistyles`, `UnistylesRuntime` theme switching, `mq` with `Display`/`Hide`; matches the library's own Jest mock and follows its source where that mock does less |
561
+ | `presets.skia()` | `react-native-skia`, `@shopify/react-native-skia` | Skia's own test mock (`Mock(CanvasKit)`) over CanvasKit, Skia compiled to WebAssembly: the `Skia` API computes with real Skia, `Canvas` and its drawing render as Views; plus Skia's Reanimated helpers (`usePathValue`, `useTexture`, …) and a `matchFont` that returns a font |
558
562
 
559
563
  Presets apply under **both** engines: the mock engine and `engine: 'native'` (where they shadow each
560
564
  library's native runtime — worklets, native modules — exactly as Jest does, while the surrounding tree
@@ -562,10 +566,10 @@ renders through real React Native).
562
566
 
563
567
  ### Expo
564
568
 
565
- Expo apps need no Expo-specific package. The `expo` preset shadows the common Expo modules
566
- (`expo-constants`, `expo-status-bar`, `expo-font`, `expo-asset`, `expo-splash-screen`,
567
- `expo-linking`) the way `jest-expo` mocks them, and Expo's own JavaScript — `expo` itself,
568
- expo-router and React Navigation — runs for real under the native engine.
569
+ Expo apps need no Expo-specific package. Under the native engine every Expo package's own
570
+ JavaScript runs for real — `expo` itself, expo-router, React Navigation and Expo modules such as
571
+ `expo-constants` or `expo-splash-screen` — and only their native modules are mocked, the way
572
+ `jest-expo` runs them. (The mock engine replaces the common Expo modules with the `expo` preset.)
569
573
 
570
574
  - **Coming from jest-expo:** `npx vitest-native migrate --write` translates the `jest-expo`
571
575
  presets (`jest-expo/android` → `platform: 'android'`) and, because jest-expo does not mock React
@@ -573,14 +577,17 @@ expo-router and React Navigation — runs for real under the native engine.
573
577
  - **expo-router screens:** `expo-router/testing-library` (`renderRouter`, `testRouter`,
574
578
  `toHavePathname`) runs as written with the jest-compat layer. From SDK 57 expo-router bundles its
575
579
  own React Navigation; before SDK 57, also set `presets: { navigation: false }`.
576
- - **Expo modules without a built-in preset** (e.g. `expo-image`, `expo-haptics`) still need a
577
- setup-file `vi.mock`.
580
+ - **Expo modules** run their real JavaScript, and their native modules answer as under
581
+ jest-expo: from the package's own `mocks/<Name>.ts` where it ships one, else from Expo's table
582
+ of the native modules (`Device.modelName` is `'mock'`). An optional native module a package
583
+ probes for, and that no installed package defines, is absent, as on a device.
578
584
  - **Expo SDK trails React Native.** Pin your `react-native` to the version your Expo SDK supports
579
585
  (SDK 54 and later are within this plugin's validated range), not the newest RN release.
580
586
 
581
- A packed Expo SDK 57 app is installed from the release tarball and tested in CI: Expo module
582
- auto-detection and rendering, expo-router's testing library against file-based `app/` routes, and
583
- the same routes under the configuration `migrate` generates from a jest-expo setup. See the
587
+ Packed Expo SDK 58 and SDK 57 apps are installed from the release tarball and tested in CI: Expo
588
+ module auto-detection and rendering, and expo-router's testing library against file-based `app/`
589
+ routes. The SDK 58 app also runs those routes under the configuration `migrate` generates from a
590
+ jest-expo setup. See the
584
591
  [Expo guide](https://danfry1.github.io/vitest-native/guide/expo).
585
592
 
586
593
  ---
@@ -643,7 +650,8 @@ Upgrade npm (`npm install --global npm@11`), or use pnpm, Yarn or Bun.
643
650
 
644
651
  **`@react-native/babel-preset not found — using the mock engine`**
645
652
  You asked for the default (`auto`) engine but the native babel deps aren't installed, so it
646
- fell back to the mock engine. To run real React Native, install them:
653
+ fell back to the mock engine. An Expo project from SDK 56 needs nothing extra: the engine uses
654
+ Expo's preset, and `expo` brings `@babel/core`. Otherwise, to run real React Native, install them:
647
655
 
648
656
  ```bash
649
657
  npm i -D @react-native/babel-preset @babel/core
@@ -965,13 +973,13 @@ Every release must pass:
965
973
 
966
974
  - Linux on Node 20.19, 22.13, and 24, plus macOS and Windows on Node 22.13.
967
975
  - The mock, native iOS, native Android, hot-runtime, isolation, and 100-file soak suites.
968
- - React Native 0.81–0.87 against both locked and newest-supported Vitest, plus the Vitest 4 floor
969
- on 0.81 and 0.87.
976
+ - React Native 0.81–0.88 against both locked and newest-supported Vitest, plus the Vitest 4 floor
977
+ on 0.81 and 0.88.
970
978
  - Vitest's own behaviour under the defaults, on Vitest 5 and the Vitest 4 floor: config and CLI
971
979
  flags, projects, watch mode, the jsdom and happy-dom environments, `--typecheck`, `vitest bench`,
972
980
  and the HTML reporter.
973
- - Packed consumers: bare RN 0.83/RNTL 12, a Jest-migration project, Expo SDK 57/RNTL 13 (with
974
- expo-router and a `migrate`-generated jest-expo config), a mock-engine RNTL 14 project, npm- and
981
+ - Packed consumers: bare RN 0.83/RNTL 12, a Jest-migration project, Expo SDK 58/RNTL 14 (with
982
+ expo-router and a `migrate`-generated jest-expo config), Expo SDK 57/RNTL 13 (with expo-router), a mock-engine RNTL 14 project, npm- and
975
983
  pnpm-workspace monorepos on Vite 8, and an RN 0.86 Android project.
976
984
  - Packed V8 and Istanbul coverage maps/counts matching default isolation exactly under hot workers.
977
985
  - Mock-versus-real-RN behavioral cross-checks, example-app tests, typecheck, lint, formatting, and
@@ -994,7 +1002,7 @@ see [versioning and stability](docs/versioning.md).
994
1002
  | `vite` | ^6.4.2, ^7.3.2, or ^8.0.5 |
995
1003
  | `vitest` | 4.x or 5.x |
996
1004
  | `node` | >= 20.19; RN/RNTL may impose a higher floor |
997
- | `react-native` (native engine) | 0.81–0.87 validated |
1005
+ | `react-native` (native engine) | 0.81–0.88 validated |
998
1006
  | `@react-native/babel-preset` (native engine) | Match the installed React Native minor |
999
1007
  | `@testing-library/react-native` (optional) | 12.x, 13.x, or 14.x |
1000
1008
 
package/dist/cli.cjs CHANGED
@@ -1,8 +1,8 @@
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-Bg7DgFeG.cjs");
5
- const require_preset_map = require("./preset-map-mzfu_YUy.cjs");
4
+ const require_ecosystem = require("./ecosystem-MFwkbnaC.cjs");
5
+ const require_preset_map = require("./preset-map-jSFsNy1Q.cjs");
6
6
  const require_memory = require("./memory-6EPHrJA1.cjs");
7
7
  let node_fs = require("node:fs");
8
8
  node_fs = require_rolldown_runtime.__toESM(node_fs, 1);
@@ -65,12 +65,13 @@ function installedTestsItself(root, pkg) {
65
65
  /**
66
66
  * The presets a run in this project enables, decided as the plugin decides it: a
67
67
  * preset is active when one of its packages is installed and does not test itself,
68
- * and the user has not switched it off.
68
+ * the engine applies it (autoDetectedPresetApplies), and the user has not switched it
69
+ * off.
69
70
  */
70
- function activePresets(root, disabled = []) {
71
+ function activePresets(root, disabled = [], engine = "native") {
71
72
  const active = /* @__PURE__ */ new Set();
72
73
  for (const [pkg, preset] of Object.entries(require_preset_map.AUTO_DETECT_PRESETS)) {
73
- if (disabled.includes(preset)) continue;
74
+ if (disabled.includes(preset) || !require_preset_map.autoDetectedPresetApplies(preset, engine)) continue;
74
75
  if (installedManifest(root, pkg) && !installedTestsItself(root, pkg)) active.add(preset);
75
76
  }
76
77
  return [...active];
@@ -525,12 +526,14 @@ function runDoctor(root, nodeVersion = process.versions.node) {
525
526
  lines.push("", "Engine");
526
527
  const rnVersion = packageVersion(rootFor("react-native"), "react-native");
527
528
  const decision = require_ecosystem.detectEngine("auto", rootFor("@react-native/babel-preset"));
528
- if (decision.engine === "native") pass(`engine 'auto' resolves to NATIVE — real React Native${rnVersion ? ` ${rnVersion}` : ""} with @react-native/babel-preset + @babel/core present.`);
529
- 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.`);
529
+ const transformPreset = require_ecosystem.resolveTransformPreset(rootFor("@react-native/babel-preset"));
530
+ const presetLabel = transformPreset ? `${transformPreset.name} ${transformPreset.version}` : "a React Native Babel preset";
531
+ if (decision.engine === "native") pass(`engine 'auto' resolves to NATIVE — real React Native${rnVersion ? ` ${rnVersion}` : ""} with ${presetLabel} + @babel/core present.`);
532
+ else if (rnVersion) warn(`engine 'auto' resolves to MOCK: react-native ${rnVersion} is installed but no React Native Babel preset (@react-native/babel-preset, or Expo's from SDK 56) and/or @babel/core resolve. Install both as devDependencies to run the real-RN native engine.`);
530
533
  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.");
531
534
  if (decision.engine === "native") {
532
535
  const inferredRoot = configRoot;
533
- const inferredEcosystem = require_ecosystem.detectEcosystemPackages([.../* @__PURE__ */ new Set([root, configRoot])], [], root === configRoot ? [] : [root], [], activePresets(root));
536
+ const inferredEcosystem = require_ecosystem.detectEcosystemPackages([.../* @__PURE__ */ new Set([root, configRoot])], [], root === configRoot ? [] : [root], [], activePresets(root, [], decision.engine));
534
537
  const inferredOwnership = require_ecosystem.createNativeOwnershipPolicy({
535
538
  projectRoot: inferredRoot,
536
539
  ecosystemPackages: inferredEcosystem,
@@ -562,22 +565,25 @@ function runDoctor(root, nodeVersion = process.versions.node) {
562
565
  }
563
566
  lines.push("", "Auto-detected presets");
564
567
  const detected = [];
568
+ let installedAny = false;
565
569
  for (const [pkg, preset] of Object.entries(require_preset_map.AUTO_DETECT_PRESETS)) {
566
570
  if (!installedManifest(root, pkg)) continue;
571
+ installedAny = true;
567
572
  if (installedTestsItself(root, pkg)) lines.push(` · ${pkg} ${installedMajor(root, pkg)} runs its own test mode under Vitest, so no preset replaces it`);
573
+ else if (!require_preset_map.autoDetectedPresetApplies(preset, decision.engine)) lines.push(` · ${pkg} runs as itself under the native engine, on its native-module mocks; the ${preset} preset applies under the mock engine or with \`presets: { ${preset}: true }\``);
568
574
  else detected.push(`${pkg} → ${preset}`);
569
575
  }
570
576
  if (detected.length) for (const d of detected) pass(d);
571
- else lines.push(" (none — no preset-covered packages installed)");
577
+ else if (!installedAny) lines.push(" (none — no preset-covered packages installed)");
572
578
  const expo = packageVersion(rootFor("expo"), "expo");
573
579
  if (expo) {
574
580
  lines.push("", "Expo");
575
- pass(`expo ${expo} detected. The auto-detected expo preset shadows ${require_preset_map.PRESET_MODULES.expo.join(", ")}; other Expo modules load their real JavaScript. Coming from jest-expo, run \`vitest-native migrate\`. See https://danfry1.github.io/vitest-native/guide/expo`);
581
+ pass((decision.engine === "native" ? `expo ${expo} detected. Under the native engine Expo modules run their real JavaScript on native-module mocks, as under jest-expo (unless the config sets \`engine: 'mock'\` or \`presets: { expo: true }\`, where the expo preset shadows ${require_preset_map.PRESET_MODULES.expo.join(", ")}). ` : `expo ${expo} detected. Under the mock engine the expo preset shadows ${require_preset_map.PRESET_MODULES.expo.join(", ")}; other Expo modules load their real JavaScript. `) + `Coming from jest-expo, run \`vitest-native migrate\`. See https://danfry1.github.io/vitest-native/guide/expo`);
576
582
  }
577
583
  const babel = readBabelConfig(root);
578
584
  if (babel.source) {
579
585
  lines.push("", "Babel");
580
- const classified = classifyBabelPlugins(babel, root, activePresets(root));
586
+ const classified = classifyBabelPlugins(babel, root, activePresets(root, [], decision.engine));
581
587
  const required = classified.filter((p) => p.verdict === "required");
582
588
  for (const p of classified) if (p.verdict === "required") warn(`${p.reason} Required: ${babelRecipe(viteMajor(rootFor("vite")), required)}.`);
583
589
  else if (p.verdict === "alias") warn(`${p.reason} \`vitest-native migrate\` writes them; otherwise add them to resolve.alias.`);
@@ -1409,11 +1415,13 @@ function list(items) {
1409
1415
  return items.length <= 1 ? items[0] ?? "" : `${items.slice(0, -1).join(", ")} and ${items[items.length - 1]}`;
1410
1416
  }
1411
1417
  /**
1412
- * What the expo preset covers, named from its module list. jest-expo's setup builds
1413
- * a whole Expo runtime; the preset shadows these modules and nothing else.
1418
+ * How Expo modules run after migrating. The generated config uses the native engine,
1419
+ * where Expo modules run their own JavaScript on native-module mocks, as jest-expo
1420
+ * runs them; the expo preset applies to the mock engine only (preset-map's
1421
+ * NATIVE_ENGINE_RUNS_PACKAGES).
1414
1422
  */
1415
1423
  function expoPresetCoverage() {
1416
- return `jest-expo's setup (its Expo runtime and native-module mocks) is not reproduced; the expo preset shadows ${list(require_preset_map.PRESET_MODULES.expo)} — other Expo modules load their real JavaScript, so check the tests that use them`;
1424
+ return "under the native engine, which the suggested config resolves to wherever React Native's Babel toolchain is installed, Expo modules run their own JavaScript on native-module mocks, as jest-expo runs them: each package's own mocks/ where it ships one, else jest-expo's table of the native modules; check tests that mock an Expo module's native side by hand";
1417
1425
  }
1418
1426
  /** Escape a literal for a JavaScript regex literal (including `/`). */
1419
1427
  function regexLiteral(literal) {
@@ -1531,14 +1539,19 @@ function analyzeJestConfig(root) {
1531
1539
  for (const key of ["setupFiles", "setupFilesAfterEnv"]) {
1532
1540
  const files = take(key);
1533
1541
  if (!files?.length) continue;
1534
- for (const f of files) if (/react-native\/jest\/setup/.test(f)) presetCovered.push(`${key}: '${f}' — the plugin injects its own setup; delete.`);
1535
- else if (/jest-expo/.test(f)) attention.push(`${key}: '${f}' — ${expoPresetCoverage()}.`);
1536
- else if (f.startsWith("<rootDir>")) {
1537
- setupFiles.push(absolutePath(f.replace(/^<rootDir>\/?/, "./")));
1538
- automatic.push(`${key}: '${f}' → test.setupFiles (its jest.* calls run under the jest-compat shim).`);
1539
- } else {
1540
- setupFiles.push(JSON.stringify(f));
1541
- automatic.push(`${key}: '${f}' → test.setupFiles (its jest.* calls run under the jest-compat shim).`);
1542
+ for (const f of files) {
1543
+ const setupPackage = /^(@[^/]+\/[^/]+|[^@./][^/]*)\//.exec(f)?.[1];
1544
+ const setupPreset = setupPackage ? require_preset_map.presetShadowing(setupPackage) : void 0;
1545
+ if (/react-native\/jest\/setup/.test(f)) presetCovered.push(`${key}: '${f}' — the plugin injects its own setup; delete.`);
1546
+ else if (setupPreset && active.includes(setupPreset)) presetCovered.push(`${key}: '${f}' — ${setupPackage}'s own test setup; the auto-detected ${setupPreset} preset shadows ${setupPackage}, and this file's jest.mock() calls would replace it; delete.`);
1547
+ else if (/jest-expo/.test(f)) attention.push(`${key}: '${f}' — ${expoPresetCoverage()}.`);
1548
+ else if (f.startsWith("<rootDir>")) {
1549
+ setupFiles.push(absolutePath(f.replace(/^<rootDir>\/?/, "./")));
1550
+ automatic.push(`${key}: '${f}' → test.setupFiles (its jest.* calls run under the jest-compat shim).`);
1551
+ } else {
1552
+ setupFiles.push(JSON.stringify(f));
1553
+ automatic.push(`${key}: '${f}' → test.setupFiles (its jest.* calls run under the jest-compat shim).`);
1554
+ }
1542
1555
  }
1543
1556
  }
1544
1557
  const mapper = take("moduleNameMapper");
package/dist/cli.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { d as validatePeerDependency, l as PEER_REQUIREMENTS, n as detectEngine, o as formatNativeOwnershipManifest, r as createNativeOwnershipPolicy, t as detectEcosystemPackages } from "./ecosystem-lBGWAeOw.mjs";
3
- import { a as presetShadowing, n as DEFAULT_ASSET_EXTS, o as testsItself, r as PRESET_MODULES, t as AUTO_DETECT_PRESETS } from "./preset-map-mriqY254.mjs";
2
+ import { f as validatePeerDependency, i as createNativeOwnershipPolicy, n as detectEngine, r as resolveTransformPreset, s as formatNativeOwnershipManifest, t as detectEcosystemPackages, u as PEER_REQUIREMENTS } from "./ecosystem-D6e1OVOg.mjs";
3
+ import { i as autoDetectedPresetApplies, n as DEFAULT_ASSET_EXTS, o as presetShadowing, r as PRESET_MODULES, s as testsItself, t as AUTO_DETECT_PRESETS } from "./preset-map-BlBriTA0.mjs";
4
4
  import { n as formatHotMemoryPlan, t as createHotMemoryPlan } from "./memory-FYbP0_gg.mjs";
5
5
  import { createRequire } from "node:module";
6
6
  import fs from "node:fs";
@@ -61,12 +61,13 @@ function installedTestsItself(root, pkg) {
61
61
  /**
62
62
  * The presets a run in this project enables, decided as the plugin decides it: a
63
63
  * preset is active when one of its packages is installed and does not test itself,
64
- * and the user has not switched it off.
64
+ * the engine applies it (autoDetectedPresetApplies), and the user has not switched it
65
+ * off.
65
66
  */
66
- function activePresets(root, disabled = []) {
67
+ function activePresets(root, disabled = [], engine = "native") {
67
68
  const active = /* @__PURE__ */ new Set();
68
69
  for (const [pkg, preset] of Object.entries(AUTO_DETECT_PRESETS)) {
69
- if (disabled.includes(preset)) continue;
70
+ if (disabled.includes(preset) || !autoDetectedPresetApplies(preset, engine)) continue;
70
71
  if (installedManifest(root, pkg) && !installedTestsItself(root, pkg)) active.add(preset);
71
72
  }
72
73
  return [...active];
@@ -521,12 +522,14 @@ function runDoctor(root, nodeVersion = process.versions.node) {
521
522
  lines.push("", "Engine");
522
523
  const rnVersion = packageVersion(rootFor("react-native"), "react-native");
523
524
  const decision = detectEngine("auto", rootFor("@react-native/babel-preset"));
524
- if (decision.engine === "native") pass(`engine 'auto' resolves to NATIVE — real React Native${rnVersion ? ` ${rnVersion}` : ""} with @react-native/babel-preset + @babel/core present.`);
525
- 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.`);
525
+ const transformPreset = resolveTransformPreset(rootFor("@react-native/babel-preset"));
526
+ const presetLabel = transformPreset ? `${transformPreset.name} ${transformPreset.version}` : "a React Native Babel preset";
527
+ if (decision.engine === "native") pass(`engine 'auto' resolves to NATIVE — real React Native${rnVersion ? ` ${rnVersion}` : ""} with ${presetLabel} + @babel/core present.`);
528
+ else if (rnVersion) warn(`engine 'auto' resolves to MOCK: react-native ${rnVersion} is installed but no React Native Babel preset (@react-native/babel-preset, or Expo's from SDK 56) and/or @babel/core resolve. Install both as devDependencies to run the real-RN native engine.`);
526
529
  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.");
527
530
  if (decision.engine === "native") {
528
531
  const inferredRoot = configRoot;
529
- const inferredEcosystem = detectEcosystemPackages([.../* @__PURE__ */ new Set([root, configRoot])], [], root === configRoot ? [] : [root], [], activePresets(root));
532
+ const inferredEcosystem = detectEcosystemPackages([.../* @__PURE__ */ new Set([root, configRoot])], [], root === configRoot ? [] : [root], [], activePresets(root, [], decision.engine));
530
533
  const inferredOwnership = createNativeOwnershipPolicy({
531
534
  projectRoot: inferredRoot,
532
535
  ecosystemPackages: inferredEcosystem,
@@ -558,22 +561,25 @@ function runDoctor(root, nodeVersion = process.versions.node) {
558
561
  }
559
562
  lines.push("", "Auto-detected presets");
560
563
  const detected = [];
564
+ let installedAny = false;
561
565
  for (const [pkg, preset] of Object.entries(AUTO_DETECT_PRESETS)) {
562
566
  if (!installedManifest(root, pkg)) continue;
567
+ installedAny = true;
563
568
  if (installedTestsItself(root, pkg)) lines.push(` · ${pkg} ${installedMajor(root, pkg)} runs its own test mode under Vitest, so no preset replaces it`);
569
+ else if (!autoDetectedPresetApplies(preset, decision.engine)) lines.push(` · ${pkg} runs as itself under the native engine, on its native-module mocks; the ${preset} preset applies under the mock engine or with \`presets: { ${preset}: true }\``);
564
570
  else detected.push(`${pkg} → ${preset}`);
565
571
  }
566
572
  if (detected.length) for (const d of detected) pass(d);
567
- else lines.push(" (none — no preset-covered packages installed)");
573
+ else if (!installedAny) lines.push(" (none — no preset-covered packages installed)");
568
574
  const expo = packageVersion(rootFor("expo"), "expo");
569
575
  if (expo) {
570
576
  lines.push("", "Expo");
571
- pass(`expo ${expo} detected. The auto-detected expo preset shadows ${PRESET_MODULES.expo.join(", ")}; other Expo modules load their real JavaScript. Coming from jest-expo, run \`vitest-native migrate\`. See https://danfry1.github.io/vitest-native/guide/expo`);
577
+ pass((decision.engine === "native" ? `expo ${expo} detected. Under the native engine Expo modules run their real JavaScript on native-module mocks, as under jest-expo (unless the config sets \`engine: 'mock'\` or \`presets: { expo: true }\`, where the expo preset shadows ${PRESET_MODULES.expo.join(", ")}). ` : `expo ${expo} detected. Under the mock engine the expo preset shadows ${PRESET_MODULES.expo.join(", ")}; other Expo modules load their real JavaScript. `) + `Coming from jest-expo, run \`vitest-native migrate\`. See https://danfry1.github.io/vitest-native/guide/expo`);
572
578
  }
573
579
  const babel = readBabelConfig(root);
574
580
  if (babel.source) {
575
581
  lines.push("", "Babel");
576
- const classified = classifyBabelPlugins(babel, root, activePresets(root));
582
+ const classified = classifyBabelPlugins(babel, root, activePresets(root, [], decision.engine));
577
583
  const required = classified.filter((p) => p.verdict === "required");
578
584
  for (const p of classified) if (p.verdict === "required") warn(`${p.reason} Required: ${babelRecipe(viteMajor(rootFor("vite")), required)}.`);
579
585
  else if (p.verdict === "alias") warn(`${p.reason} \`vitest-native migrate\` writes them; otherwise add them to resolve.alias.`);
@@ -1405,11 +1411,13 @@ function list(items) {
1405
1411
  return items.length <= 1 ? items[0] ?? "" : `${items.slice(0, -1).join(", ")} and ${items[items.length - 1]}`;
1406
1412
  }
1407
1413
  /**
1408
- * What the expo preset covers, named from its module list. jest-expo's setup builds
1409
- * a whole Expo runtime; the preset shadows these modules and nothing else.
1414
+ * How Expo modules run after migrating. The generated config uses the native engine,
1415
+ * where Expo modules run their own JavaScript on native-module mocks, as jest-expo
1416
+ * runs them; the expo preset applies to the mock engine only (preset-map's
1417
+ * NATIVE_ENGINE_RUNS_PACKAGES).
1410
1418
  */
1411
1419
  function expoPresetCoverage() {
1412
- return `jest-expo's setup (its Expo runtime and native-module mocks) is not reproduced; the expo preset shadows ${list(PRESET_MODULES.expo)} — other Expo modules load their real JavaScript, so check the tests that use them`;
1420
+ return "under the native engine, which the suggested config resolves to wherever React Native's Babel toolchain is installed, Expo modules run their own JavaScript on native-module mocks, as jest-expo runs them: each package's own mocks/ where it ships one, else jest-expo's table of the native modules; check tests that mock an Expo module's native side by hand";
1413
1421
  }
1414
1422
  /** Escape a literal for a JavaScript regex literal (including `/`). */
1415
1423
  function regexLiteral(literal) {
@@ -1527,14 +1535,19 @@ function analyzeJestConfig(root) {
1527
1535
  for (const key of ["setupFiles", "setupFilesAfterEnv"]) {
1528
1536
  const files = take(key);
1529
1537
  if (!files?.length) continue;
1530
- for (const f of files) if (/react-native\/jest\/setup/.test(f)) presetCovered.push(`${key}: '${f}' — the plugin injects its own setup; delete.`);
1531
- else if (/jest-expo/.test(f)) attention.push(`${key}: '${f}' — ${expoPresetCoverage()}.`);
1532
- else if (f.startsWith("<rootDir>")) {
1533
- setupFiles.push(absolutePath(f.replace(/^<rootDir>\/?/, "./")));
1534
- automatic.push(`${key}: '${f}' → test.setupFiles (its jest.* calls run under the jest-compat shim).`);
1535
- } else {
1536
- setupFiles.push(JSON.stringify(f));
1537
- automatic.push(`${key}: '${f}' → test.setupFiles (its jest.* calls run under the jest-compat shim).`);
1538
+ for (const f of files) {
1539
+ const setupPackage = /^(@[^/]+\/[^/]+|[^@./][^/]*)\//.exec(f)?.[1];
1540
+ const setupPreset = setupPackage ? presetShadowing(setupPackage) : void 0;
1541
+ if (/react-native\/jest\/setup/.test(f)) presetCovered.push(`${key}: '${f}' — the plugin injects its own setup; delete.`);
1542
+ else if (setupPreset && active.includes(setupPreset)) presetCovered.push(`${key}: '${f}' — ${setupPackage}'s own test setup; the auto-detected ${setupPreset} preset shadows ${setupPackage}, and this file's jest.mock() calls would replace it; delete.`);
1543
+ else if (/jest-expo/.test(f)) attention.push(`${key}: '${f}' — ${expoPresetCoverage()}.`);
1544
+ else if (f.startsWith("<rootDir>")) {
1545
+ setupFiles.push(absolutePath(f.replace(/^<rootDir>\/?/, "./")));
1546
+ automatic.push(`${key}: '${f}' → test.setupFiles (its jest.* calls run under the jest-compat shim).`);
1547
+ } else {
1548
+ setupFiles.push(JSON.stringify(f));
1549
+ automatic.push(`${key}: '${f}' → test.setupFiles (its jest.* calls run under the jest-compat shim).`);
1550
+ }
1538
1551
  }
1539
1552
  }
1540
1553
  const mapper = take("moduleNameMapper");
@@ -1,5 +1,5 @@
1
1
  import { n as VitestNativeTypeError } from "./errors-CxoBUfVJ.mjs";
2
- import { t as AUTO_DETECT_PRESETS } from "./preset-map-mriqY254.mjs";
2
+ import { t as AUTO_DETECT_PRESETS } from "./preset-map-BlBriTA0.mjs";
3
3
  import { createRequire } from "node:module";
4
4
  import fs from "node:fs";
5
5
  import path from "node:path";
@@ -626,6 +626,54 @@ function formatNativeOwnershipManifest(input) {
626
626
  if (manifest.enforcement === "overridden-by-inline-all") lines.push("WARNING: server.deps.inline=true takes precedence over Node ownership; graph uniqueness is not guaranteed");
627
627
  return lines;
628
628
  }
629
+ //#endregion
630
+ //#region src/native/babel-preset.mjs
631
+ /**
632
+ * The Babel preset the native engine compiles React Native and node_modules with,
633
+ * resolved from the project: the preset the project's Metro applies when the project
634
+ * has no Babel config of its own.
635
+ *
636
+ * - `@react-native/babel-preset`: React Native CLI projects, and Expo before SDK 56,
637
+ * whose babel-preset-expo depends on it.
638
+ * - `expo/internal/babel-preset` (babel-preset-expo): Expo from SDK 56. Its
639
+ * babel-preset-expo carries React Native's plugins itself and no longer depends on
640
+ * @react-native/babel-preset, so a project created from an SDK 56+ template has none
641
+ * installed. Expo's Metro (@expo/metro-config, loadBabelConfig) and jest-expo
642
+ * (src/resolveBabelOptions.js) load this preset in a project without a Babel config.
643
+ *
644
+ * The React Native preset is tried first, so a project that has it keeps compiling
645
+ * exactly as before. Null when neither resolves.
646
+ *
647
+ * @param {string} projectRoot
648
+ * @returns {{ name: string, file: string, version: string, packageDir: string } | null}
649
+ */
650
+ function resolveTransformPreset(projectRoot) {
651
+ const req = createRequire(path.join(projectRoot, "package.json"));
652
+ try {
653
+ const manifest = req.resolve("@react-native/babel-preset/package.json");
654
+ return {
655
+ name: "@react-native/babel-preset",
656
+ file: path.dirname(manifest),
657
+ version: readVersion(manifest),
658
+ packageDir: path.dirname(manifest)
659
+ };
660
+ } catch {}
661
+ try {
662
+ const file = req.resolve("expo/internal/babel-preset");
663
+ const manifest = createRequire(file).resolve("babel-preset-expo/package.json");
664
+ return {
665
+ name: "babel-preset-expo",
666
+ file,
667
+ version: readVersion(manifest),
668
+ packageDir: path.dirname(manifest)
669
+ };
670
+ } catch {
671
+ return null;
672
+ }
673
+ }
674
+ function readVersion(manifest) {
675
+ return JSON.parse(fs.readFileSync(manifest, "utf8")).version;
676
+ }
629
677
  /**
630
678
  * The native engine's dependencies that do NOT resolve from the project root.
631
679
  *
@@ -641,10 +689,11 @@ function missingNativeDeps(projectRoot) {
641
689
  const req = createRequire(path.join(projectRoot, "package.json"));
642
690
  const missing = [];
643
691
  if (!reactNativeInstalledNear(projectRoot)) missing.push("react-native");
644
- for (const dep of ["@react-native/babel-preset", "@babel/core"]) try {
645
- req.resolve(dep);
692
+ if (resolveTransformPreset(projectRoot) === null) missing.push("@react-native/babel-preset");
693
+ try {
694
+ req.resolve("@babel/core");
646
695
  } catch {
647
- missing.push(dep);
696
+ missing.push("@babel/core");
648
697
  }
649
698
  return missing;
650
699
  }
@@ -967,4 +1016,4 @@ function detectEcosystemPackages(projectRoot, explicit = [], testRoots = [], nev
967
1016
  return [...inClosure].sort();
968
1017
  }
969
1018
  //#endregion
970
- export { findNativeOwnershipConflict as a, packageDirOf as c, validatePeerDependency as d, warnUnknownOptions as f, findNativeInlineConflicts as i, PEER_REQUIREMENTS as l, detectEngine as n, formatNativeOwnershipManifest as o, createNativeOwnershipPolicy as r, containsPath as s, detectEcosystemPackages as t, validateOptions as u };
1019
+ export { findNativeInlineConflicts as a, containsPath as c, validateOptions as d, validatePeerDependency as f, createNativeOwnershipPolicy as i, packageDirOf as l, detectEngine as n, findNativeOwnershipConflict as o, warnUnknownOptions as p, resolveTransformPreset as r, formatNativeOwnershipManifest as s, detectEcosystemPackages as t, PEER_REQUIREMENTS as u };