vitest-native 0.15.0 → 0.15.1

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.
@@ -1,2 +1,2 @@
1
- import { _ as navigation, a as keyboardController, b as reanimated, c as vectorIcons, d as netInfo, f as mmkv, g as asyncStorage, h as screens, i as worklets, l as webview, m as expo, n as skia, o as bottomSheet, p as deviceInfo, r as unistyles, s as flashList, u as svg, v as safeAreaContext, y as gestureHandler } from "./index-BpZ0E2eJ.mjs";
1
+ import { _ as navigation, a as keyboardController, b as reanimated, c as vectorIcons, d as netInfo, f as mmkv, g as asyncStorage, h as screens, i as worklets, l as webview, m as expo, n as skia, o as bottomSheet, p as deviceInfo, r as unistyles, s as flashList, u as svg, v as safeAreaContext, y as gestureHandler } from "./index-DQz6guT5.mjs";
2
2
  export { asyncStorage, bottomSheet, deviceInfo, expo, flashList, gestureHandler, keyboardController, mmkv, navigation, netInfo, reanimated, safeAreaContext, screens, skia, svg, unistyles, vectorIcons, webview, worklets };
package/dist/presets.mjs CHANGED
@@ -1 +1 @@
1
- export { S as asyncStorage, a as bottomSheet, y as deviceInfo, b as expo, p as flashList, w as gestureHandler, j as keyboardController, v as mmkv, C as navigation, _ as netInfo, D as reanimated, k as safeAreaContext, x as screens, n as skia, g as svg, r as unistyles, m as vectorIcons, h as webview, i as worklets } from "./presets-DLH7uRGA.mjs";
1
+ export { T as asyncStorage, s as bottomSheet, S as deviceInfo, C as expo, g as flashList, O as gestureHandler, a as keyboardController, x as mmkv, E as navigation, b as netInfo, j as reanimated, D as safeAreaContext, w as screens, n as skia, y as svg, r as unistyles, _ as vectorIcons, v as webview, i as worklets } from "./presets-cQiD0YHw.mjs";
@@ -0,0 +1,22 @@
1
+ // src/setup-files.ts
2
+ /**
3
+ * Inserts `files` into `test.setupFiles` in place: at the front, or straight after the
4
+ * last entry `after` matches. Entries already listed are moved, not repeated. Under
5
+ * `sequence.setupFiles: 'parallel'`, the project's setup files then run in order.
6
+ */
7
+ function placeSetupFiles(test, files, after) {
8
+ const existing = test.setupFiles;
9
+ const list = (Array.isArray(existing) ? existing : existing == null ? [] : [existing]).filter((entry) => !files.includes(entry));
10
+ let at = 0;
11
+ if (after) list.forEach((entry, index) => {
12
+ if (typeof entry === "string" && after(entry)) at = index + 1;
13
+ });
14
+ list.splice(at, 0, ...files);
15
+ test.setupFiles = list;
16
+ runSetupFilesInOrder(test);
17
+ }
18
+ /** Under `sequence.setupFiles: 'parallel'`, the project's setup files run in order. */
19
+ function runSetupFilesInOrder(test) {
20
+ if (test.sequence?.setupFiles === "parallel") test.sequence.setupFiles = "list";
21
+ }
22
+ export { runSetupFilesInOrder as n, placeSetupFiles as t };
package/dist/setup.mjs CHANGED
@@ -1,15 +1,17 @@
1
1
  import { n as __require } from "./rolldown-runtime-D70C1uOS.mjs";
2
- import { E as buildPressableHostProps, M as createScrollViewMock, N as createViewMock, P as hostComponent, T as createPressableMock, c as createTouchableOpacityMock, d as createFlatListMock, f as createTextInputMock, l as createVirtualizedListMock, o as createTouchableWithoutFeedbackMock, s as createTouchableHighlightMock, t as presets_exports, u as createSectionListMock } from "./presets-DLH7uRGA.mjs";
2
+ import { A as buildPressableHostProps, M as hosts, c as createTouchableWithoutFeedbackMock, d as createVirtualizedListMock, f as createSectionListMock, h as createTextInputMock, k as createPressableMock, l as createTouchableHighlightMock, m as createScrollViewMock, o as createViewMock, p as createFlatListMock, t as presets_exports, u as createTouchableOpacityMock } from "./presets-cQiD0YHw.mjs";
3
3
  import { d as presetForInstalled, t as AUTO_DETECT_PRESETS } from "./preset-map-DdAexIwz.mjs";
4
4
  import { animatedMatchers } from "./matchers.mjs";
5
5
  import Module$1, { createRequire } from "node:module";
6
6
  import path from "node:path";
7
7
  import { importPresetModule, presetModulePaths } from "./preset-modules.mjs";
8
+ import { projectContext } from "./context.mjs";
8
9
  import { afterAll, afterEach, expect, vi } from "vitest";
9
10
  import React from "react";
10
- import { projectContext } from "./context.mjs";
11
+ import { presetFactoryContext } from "./preset-react.mjs";
11
12
  import { installRendererReportError } from "./report-error.mjs";
12
13
  import { installRntlAutoCleanup, installRntlLoadTracking } from "./rntl-support.mjs";
14
+ const hostComponent = hosts(React).hostComponent;
13
15
  // src/mocks/components/Text.ts
14
16
  function createTextMock() {
15
17
  const Text = React.forwardRef((props, ref) => {
@@ -2439,18 +2441,18 @@ function createUseAnimatedColorMock() {
2439
2441
  }
2440
2442
  function buildReactNativeMock(platform = "ios") {
2441
2443
  const mock = {
2442
- View: createViewMock(),
2444
+ View: createViewMock(React),
2443
2445
  Text: createTextMock(),
2444
2446
  Image: createImageMock(() => mock),
2445
- TextInput: createTextInputMock(),
2446
- ScrollView: createScrollViewMock(),
2447
- FlatList: createFlatListMock(),
2448
- SectionList: createSectionListMock(),
2447
+ TextInput: createTextInputMock(React),
2448
+ ScrollView: createScrollViewMock(React),
2449
+ FlatList: createFlatListMock(React),
2450
+ SectionList: createSectionListMock(React),
2449
2451
  Modal: createModalMock(),
2450
- Pressable: createPressableMock(),
2451
- TouchableOpacity: createTouchableOpacityMock(),
2452
- TouchableHighlight: createTouchableHighlightMock(),
2453
- TouchableWithoutFeedback: createTouchableWithoutFeedbackMock(),
2452
+ Pressable: createPressableMock(React),
2453
+ TouchableOpacity: createTouchableOpacityMock(React),
2454
+ TouchableHighlight: createTouchableHighlightMock(React),
2455
+ TouchableWithoutFeedback: createTouchableWithoutFeedbackMock(React),
2454
2456
  TouchableNativeFeedback: createTouchableNativeFeedbackMock(),
2455
2457
  ActivityIndicator: createActivityIndicatorMock(),
2456
2458
  Button: createButtonMock(),
@@ -2460,7 +2462,7 @@ function buildReactNativeMock(platform = "ios") {
2460
2462
  SafeAreaView: createSafeAreaViewMock(),
2461
2463
  KeyboardAvoidingView: createKeyboardAvoidingViewMock(),
2462
2464
  ImageBackground: createImageBackgroundMock(),
2463
- VirtualizedList: createVirtualizedListMock(),
2465
+ VirtualizedList: createVirtualizedListMock(React),
2464
2466
  InputAccessoryView: createInputAccessoryViewMock(),
2465
2467
  DrawerLayoutAndroid: createDrawerLayoutAndroidMock(),
2466
2468
  Platform: createPlatformMock(platform),
@@ -2844,7 +2846,7 @@ function activate(preset) {
2844
2846
  const modules = Object.entries(preset.modules).filter(([modName]) => presetExports[modName] !== null);
2845
2847
  const register = () => {
2846
2848
  for (const [modName, presetModule] of modules) {
2847
- const presetMock = presetModule.factory();
2849
+ const presetMock = presetModule.factory(presetFactoryContext(modName, projectRoot));
2848
2850
  installPresetCjsBridge(modName, presetMock);
2849
2851
  g.__vitest_native_preset_mocks[modName] = presetMock;
2850
2852
  if (diagnostics) console.log(`[vitest-native] Registered preset mock: ${modName} (${preset.name})`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitest-native",
3
- "version": "0.15.0",
3
+ "version": "0.15.1",
4
4
  "description": "Run real React Native tests under Vitest. One install, zero config.",
5
5
  "keywords": [
6
6
  "expo",
@@ -24,7 +24,7 @@
24
24
  "directory": "packages/vitest-native"
25
25
  },
26
26
  "bin": {
27
- "vitest-native": "./dist/cli.mjs"
27
+ "vitest-native": "dist/cli.mjs"
28
28
  },
29
29
  "files": [
30
30
  "dist",
@@ -120,7 +120,8 @@
120
120
  "build": "bun --bun tsdown && node scripts/copy-static-types.mjs && node scripts/build-stamp.mjs write",
121
121
  "test": "node scripts/ci/vitest.mjs run",
122
122
  "test:e2e": "node scripts/ci/vitest.mjs run --config vitest.e2e.config.ts",
123
- "test:native": "node scripts/run-scripts.mjs test:native:no-globals test:native:main test:native:per-file test:native:rntl-timers test:native:one-instance test:native:context test:native:shared-root test:native:preset-modules test:native:permissive test:native:reanimated-fallback test:native:partial-mock-external test:native:tsconfig-paths test:native:regex-alias test:native:dispatch-alias test:native:jest-registry-node-mocks test:native:jest-compat-restore-mocks test:native:node-mocks test:native:ownership test:native:project-js-jsx test:native:jest-globals-require test:native:compile-error test:native:project-babel test:native:rn-deep-mock test:native:root-mocks test:native:library-setup-preset-off test:native:reanimated-shapes test:native:conformance",
123
+ "test:native": "node scripts/run-scripts.mjs test:native:no-globals test:native:main test:native:per-file test:native:rntl-timers test:native:one-instance test:native:context test:native:shared-root test:native:preset-modules test:native:permissive test:native:reanimated-fallback test:native:partial-mock-external test:native:tsconfig-paths test:native:regex-alias test:native:dispatch-alias test:native:jest-registry-node-mocks test:native:jest-compat-restore-mocks test:native:node-mocks test:native:ownership test:native:project-js-jsx test:native:jest-globals-require test:native:compile-error test:native:project-babel test:native:rn-deep-mock test:native:root-mocks test:native:library-setup-preset-off test:native:setup-order test:native:reanimated-shapes test:native:conformance",
124
+ "test:native:setup-order": "node scripts/ci/vitest.mjs run --config tests-native/vitest.setup-order.config.mts --mode list && node scripts/ci/vitest.mjs run --config tests-native/vitest.setup-order.config.mts --mode parallel && node scripts/ci/vitest.mjs run --config tests-native/vitest.setup-order.config.mts --mode compat-parallel",
124
125
  "test:native:library-setup-preset-off": "node scripts/ci/vitest.mjs run --config tests-native/vitest.library-setup-preset-off.config.mts",
125
126
  "test:native:reanimated-shapes": "node scripts/ci/vitest.mjs run --config tests-native/vitest.reanimated-shapes.config.mts --mode plain && node scripts/ci/vitest.mjs run --config tests-native/vitest.reanimated-shapes.config.mts --mode compat",
126
127
  "test:native:conformance": "node scripts/ci/vitest.mjs run --config tests-native/vitest.conformance.config.mts --mode plain && node scripts/ci/vitest.mjs run --config tests-native/vitest.conformance.config.mts --mode compat",
@@ -155,7 +156,7 @@
155
156
  "test:native:android": "node scripts/ci/vitest.mjs run --config tests-native/vitest.android.config.mts",
156
157
  "test:native:advice": "node scripts/ci/vitest.mjs run --config tests-native/vitest.advice.config.mts",
157
158
  "test:native:hot": "node scripts/ci/vitest.mjs run --config tests-native/vitest.hot.config.mts",
158
- "test:native:hot:isolation": "node scripts/ci/vitest.mjs run --config tests-native/vitest.hot-isolation.config.mts && node scripts/ci/vitest.mjs run --config tests-native/vitest.hot-user-setup.config.mts && node scripts/ci/vitest.mjs run --config tests-native/vitest.hot-jest-compat.config.mts --mode stock && node scripts/ci/vitest.mjs run --config tests-native/vitest.hot-jest-compat.config.mts --mode hot && node scripts/ci/vitest.mjs run --config tests-native/vitest.jest-registry-no-isolate.config.mts && bun run test:native:hot:file-accounting && bun run test:native:hot:act-scope && bun run test:native:hot:rntl-optout && bun run test:native:hot:worker-state && bun run test:native:hot:resident-mock && bun run test:native:hot:fresh-runtime && bun run test:native:hot:compile-cache && bun run test:native:hot:workspace-member && bun run test:native:hot:memory && bun run test:native:hot:generation-parity",
159
+ "test:native:hot:isolation": "node scripts/ci/vitest.mjs run --config tests-native/vitest.hot-isolation.config.mts && node scripts/ci/vitest.mjs run --config tests-native/vitest.hot-user-setup.config.mts && node scripts/ci/vitest.mjs run --config tests-native/vitest.hot-jest-compat.config.mts --mode stock && node scripts/ci/vitest.mjs run --config tests-native/vitest.hot-jest-compat.config.mts --mode hot && node scripts/ci/vitest.mjs run --config tests-native/vitest.jest-registry-no-isolate.config.mts && bun run test:native:hot:file-accounting && bun run test:native:hot:act-scope && bun run test:native:hot:rntl-optout && bun run test:native:hot:worker-state && bun run test:native:hot:nonconfigurable-global && bun run test:native:hot:diagnostics && bun run test:native:hot:resident-mock && bun run test:native:hot:fresh-runtime && bun run test:native:hot:compile-cache && bun run test:native:hot:workspace-member && bun run test:native:hot:memory && bun run test:native:hot:generation-parity",
159
160
  "test:native:hot:file-accounting": "node scripts/test-hot-file-accounting.mjs",
160
161
  "test:native:hot:act-scope": "node scripts/test-hot-act-scope.mjs",
161
162
  "test:native:hot:fresh-runtime": "node scripts/ci/vitest.mjs run --config tests-native/vitest.hot-fresh-runtime.config.mts && node scripts/ci/vitest.mjs run --config tests-native/vitest.hot-fresh-runtime-memory.config.mts --mode fresh && node scripts/ci/vitest.mjs run --config tests-native/vitest.hot-fresh-runtime-memory.config.mts --mode resident && node scripts/ci/vitest.mjs run --config tests-native/vitest.hot-fresh-runtime-timers.config.mts --mode fresh",
@@ -178,6 +179,7 @@
178
179
  "check:size": "node scripts/check-package-size.mjs",
179
180
  "check:structure": "node scripts/structural-scorecard.mjs",
180
181
  "check:exports": "node scripts/check-exports.mjs",
182
+ "check:publish-manifest": "node scripts/check-publish-manifest.mjs",
181
183
  "typecheck": "tsc --noEmit",
182
184
  "clean": "rm -rf dist",
183
185
  "prepublishOnly": "bun run build && bun run check:size && bun run test && bun run test:native && bun run test:native:forks && bun run test:native:navigation && bun run test:native:android && bun run test:native:advice && bun run test:native:hot && bun run test:native:hot:isolation && bun run test:native:hot:state-manifest && bun run test:native:hot:soak && bun run validate:hot-parity && bun run validate:registry-process && bun run fidelity:check && bun run test:consumers && bun run lint && bun run typecheck",
@@ -189,7 +191,9 @@
189
191
  "validate:hot-auto": "node validation/hot-auto/run.mjs",
190
192
  "validate:vitest-semantics": "node validation/vitest-semantics/run.mjs",
191
193
  "validate:registry-process": "node validation/module-isolation/run-registry-process.mjs",
192
- "validate:metro-profile": "node --expose-gc validation/module-isolation/run-metro-profile.mjs"
194
+ "validate:metro-profile": "node --expose-gc validation/module-isolation/run-metro-profile.mjs",
195
+ "test:native:hot:nonconfigurable-global": "node scripts/ci/vitest.mjs run --config tests-native/vitest.hot-nonconfigurable-global.config.mts",
196
+ "test:native:hot:diagnostics": "node scripts/test-hot-diagnostics.mjs"
193
197
  },
194
198
  "dependencies": {
195
199
  "flow-remove-types": "^2.337.0",
@@ -217,10 +221,12 @@
217
221
  "dispatch-target-lib": "file:./tests-native/fixtures/dispatch-target-lib",
218
222
  "expo": "58.0.21",
219
223
  "expo-constants": "58.0.14",
224
+ "expo-image": "58.0.18",
220
225
  "expo-status-bar": "58.0.4",
221
226
  "ext-platform-lib": "file:./tests-native/fixtures/ext-platform-lib",
222
227
  "ext-rn-named-lib": "file:./tests-native/fixtures/ext-rn-named-lib",
223
228
  "generic-mainfield-lib": "file:./tests-native/fixtures/generic-mainfield-lib",
229
+ "jsx-in-js-lib": "file:./tests-native/fixtures/jsx-in-js-lib",
224
230
  "metro": "0.87.2",
225
231
  "metro-resolver": "0.87.2",
226
232
  "react": "^19.3.1",
@@ -239,6 +245,7 @@
239
245
  "rn-condition-cjs-lib": "file:./tests-native/fixtures/rn-condition-cjs-lib",
240
246
  "rn-condition-lib": "file:./tests-native/fixtures/rn-condition-lib",
241
247
  "rn-ecosystem-lib": "file:./tests-native/fixtures/rn-ecosystem-lib",
248
+ "rn-esbuild-reexport-lib": "file:./tests-native/fixtures/rn-esbuild-reexport-lib",
242
249
  "rn-mainfield-lib": "file:./tests-native/fixtures/rn-mainfield-lib",
243
250
  "rn-platform-flow-lib": "file:./tests-native/fixtures/rn-platform-flow-lib",
244
251
  "rn-singleton-lib": "file:./tests-native/fixtures/rn-singleton-lib",