vitest-native 0.1.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,13 @@
1
+ # vitest-native
2
+
3
+ ## 0.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Add Metro-compatible extensionless module resolution for node_modules. Add navigation preset mocks for @react-navigation/native-stack, @react-navigation/bottom-tabs, and @react-navigation/elements. Support custom presets.
8
+
9
+ ## 0.1.3
10
+
11
+ ### Patch Changes
12
+
13
+ - 260ae84: Fix package metadata: correct GitHub URLs and Node >= 20 engine requirement.
package/README.md CHANGED
@@ -446,7 +446,7 @@ This prints details about which presets were detected, which modules are being m
446
446
  | `react` | >= 18 |
447
447
  | `vite` | >= 5 |
448
448
  | `vitest` | >= 4 |
449
- | `node` | >= 18 |
449
+ | `node` | >= 20 |
450
450
  | `@testing-library/react-native` (optional) | >= 12 |
451
451
 
452
452
  ---
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_presets = require("./presets-ArwboRy7.cjs");
3
- const require_preset_map = require("./preset-map-C5d8DSY7.cjs");
2
+ const require_presets = require("./presets-D4jrt194.cjs");
3
+ const require_preset_map = require("./preset-map-Bt4dXkZO.cjs");
4
4
  let node_url = require("node:url");
5
5
  let node_path = require("node:path");
6
6
  node_path = require_presets.__toESM(node_path);
@@ -197,16 +197,6 @@ const RN_EXPORT_NAMES = [
197
197
  "NativeDialogManagerAndroid",
198
198
  "usePressability"
199
199
  ];
200
- /** Names of all built-in presets that can be reconstructed in the worker. */
201
- const BUILT_IN_PRESET_NAMES = new Set([
202
- "reanimated",
203
- "gestureHandler",
204
- "safeAreaContext",
205
- "navigation",
206
- "asyncStorage",
207
- "screens",
208
- "expo"
209
- ]);
210
200
  /** Check if a value (or any nested value) contains functions. */
211
201
  function containsFunctions(value, visited = /* @__PURE__ */ new WeakSet()) {
212
202
  if (typeof value === "function") return true;
@@ -224,9 +214,6 @@ function containsFunctions(value, visited = /* @__PURE__ */ new WeakSet()) {
224
214
  * React Native code in a Node/JSDOM environment.
225
215
  */
226
216
  function reactNative(options) {
227
- if (options?.presets) {
228
- for (const preset of options.presets) if (!BUILT_IN_PRESET_NAMES.has(preset.name)) throw new Error(`[vitest-native] Unknown preset "${preset.name}". Only built-in presets are supported: ${[...BUILT_IN_PRESET_NAMES].join(", ")}. For custom module mocking, use vi.mock() in a setup file.`);
229
- }
230
217
  if (options?.mocks && containsFunctions(options.mocks)) throw new Error("[vitest-native] The \"mocks\" option contains function values, which cannot be transferred to Vitest worker processes. Only JSON-serializable values (strings, numbers, booleans, plain objects, arrays) are supported.\n\nFor function-based mock overrides, use vi.mock() in a setup file:\n\n // vitest.setup.ts\n import { vi } from 'vitest';\n vi.mock('react-native', async (importOriginal) => {\n const actual = await importOriginal();\n return { ...actual, Alert: { alert: vi.fn() } };\n });");
231
218
  let resolved;
232
219
  const presetModules = /* @__PURE__ */ new Map();
@@ -272,10 +259,22 @@ function reactNative(options) {
272
259
  }
273
260
  assetPattern = new RegExp(`\\.(${resolved.assetExts.join("|")})$`);
274
261
  },
275
- resolveId(source) {
262
+ resolveId(source, importer) {
276
263
  if (source === "react-native") return "\0virtual:react-native";
277
264
  if (source.startsWith("react-native/")) return `\0virtual:rn-subpath:${source}`;
278
265
  if (presetModules.has(source)) return `\0virtual:preset:${source}`;
266
+ if (importer && importer.includes("node_modules") && source.startsWith(".") && !node_path.default.extname(source)) {
267
+ const importerDir = node_path.default.dirname(importer);
268
+ const absolute = node_path.default.resolve(importerDir, source);
269
+ for (const ext of extensions) {
270
+ const candidate = absolute + ext;
271
+ if (node_fs.default.existsSync(candidate)) return candidate;
272
+ }
273
+ for (const ext of extensions) {
274
+ const candidate = node_path.default.join(absolute, `index${ext}`);
275
+ if (node_fs.default.existsSync(candidate)) return candidate;
276
+ }
277
+ }
279
278
  },
280
279
  load(id) {
281
280
  if (id === "\0virtual:react-native") return "export default {};";
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { t as AUTO_DETECT_PRESETS } from "./preset-map-CTAjv5aa.mjs";
2
- import { t as presets_exports } from "./presets-DgEuMxfn.mjs";
1
+ import { t as AUTO_DETECT_PRESETS } from "./preset-map-D224CC5w.mjs";
2
+ import { t as presets_exports } from "./presets-C9tAPD15.mjs";
3
3
  import { createRequire } from "node:module";
4
4
  import { fileURLToPath } from "node:url";
5
5
  import path from "node:path";
@@ -194,16 +194,6 @@ const RN_EXPORT_NAMES = [
194
194
  "NativeDialogManagerAndroid",
195
195
  "usePressability"
196
196
  ];
197
- /** Names of all built-in presets that can be reconstructed in the worker. */
198
- const BUILT_IN_PRESET_NAMES = new Set([
199
- "reanimated",
200
- "gestureHandler",
201
- "safeAreaContext",
202
- "navigation",
203
- "asyncStorage",
204
- "screens",
205
- "expo"
206
- ]);
207
197
  /** Check if a value (or any nested value) contains functions. */
208
198
  function containsFunctions(value, visited = /* @__PURE__ */ new WeakSet()) {
209
199
  if (typeof value === "function") return true;
@@ -221,9 +211,6 @@ function containsFunctions(value, visited = /* @__PURE__ */ new WeakSet()) {
221
211
  * React Native code in a Node/JSDOM environment.
222
212
  */
223
213
  function reactNative(options) {
224
- if (options?.presets) {
225
- for (const preset of options.presets) if (!BUILT_IN_PRESET_NAMES.has(preset.name)) throw new Error(`[vitest-native] Unknown preset "${preset.name}". Only built-in presets are supported: ${[...BUILT_IN_PRESET_NAMES].join(", ")}. For custom module mocking, use vi.mock() in a setup file.`);
226
- }
227
214
  if (options?.mocks && containsFunctions(options.mocks)) throw new Error("[vitest-native] The \"mocks\" option contains function values, which cannot be transferred to Vitest worker processes. Only JSON-serializable values (strings, numbers, booleans, plain objects, arrays) are supported.\n\nFor function-based mock overrides, use vi.mock() in a setup file:\n\n // vitest.setup.ts\n import { vi } from 'vitest';\n vi.mock('react-native', async (importOriginal) => {\n const actual = await importOriginal();\n return { ...actual, Alert: { alert: vi.fn() } };\n });");
228
215
  let resolved;
229
216
  const presetModules = /* @__PURE__ */ new Map();
@@ -269,10 +256,22 @@ function reactNative(options) {
269
256
  }
270
257
  assetPattern = new RegExp(`\\.(${resolved.assetExts.join("|")})$`);
271
258
  },
272
- resolveId(source) {
259
+ resolveId(source, importer) {
273
260
  if (source === "react-native") return "\0virtual:react-native";
274
261
  if (source.startsWith("react-native/")) return `\0virtual:rn-subpath:${source}`;
275
262
  if (presetModules.has(source)) return `\0virtual:preset:${source}`;
263
+ if (importer && importer.includes("node_modules") && source.startsWith(".") && !path.extname(source)) {
264
+ const importerDir = path.dirname(importer);
265
+ const absolute = path.resolve(importerDir, source);
266
+ for (const ext of extensions) {
267
+ const candidate = absolute + ext;
268
+ if (fs.existsSync(candidate)) return candidate;
269
+ }
270
+ for (const ext of extensions) {
271
+ const candidate = path.join(absolute, `index${ext}`);
272
+ if (fs.existsSync(candidate)) return candidate;
273
+ }
274
+ }
276
275
  },
277
276
  load(id) {
278
277
  if (id === "\0virtual:react-native") return "export default {};";
@@ -8,6 +8,9 @@ const AUTO_DETECT_PRESETS = {
8
8
  "react-native-gesture-handler": "gestureHandler",
9
9
  "react-native-safe-area-context": "safeAreaContext",
10
10
  "@react-navigation/native": "navigation",
11
+ "@react-navigation/native-stack": "navigation",
12
+ "@react-navigation/bottom-tabs": "navigation",
13
+ "@react-navigation/elements": "navigation",
11
14
  "@react-native-async-storage/async-storage": "asyncStorage",
12
15
  "react-native-screens": "screens",
13
16
  "expo-constants": "expo"
@@ -8,6 +8,9 @@ const AUTO_DETECT_PRESETS = {
8
8
  "react-native-gesture-handler": "gestureHandler",
9
9
  "react-native-safe-area-context": "safeAreaContext",
10
10
  "@react-navigation/native": "navigation",
11
+ "@react-navigation/native-stack": "navigation",
12
+ "@react-navigation/bottom-tabs": "navigation",
13
+ "@react-navigation/elements": "navigation",
11
14
  "@react-native-async-storage/async-storage": "asyncStorage",
12
15
  "react-native-screens": "screens",
13
16
  "expo-constants": "expo"
@@ -436,138 +436,244 @@ function safeAreaContext() {
436
436
  function navigation() {
437
437
  return {
438
438
  name: "navigation",
439
- modules: { "@react-navigation/native": {
440
- exports: [
441
- "NavigationContainer",
442
- "useNavigation",
443
- "useRoute",
444
- "useFocusEffect",
445
- "useIsFocused",
446
- "useNavigationState",
447
- "createNavigationContainerRef",
448
- "NavigationContext",
449
- "NavigationRouteContext",
450
- "CommonActions",
451
- "StackActions",
452
- "TabActions",
453
- "DrawerActions",
454
- "useLinkTo",
455
- "Link"
456
- ],
457
- factory: () => {
458
- const NavigationContainer = React.forwardRef((props, ref) => React.createElement("NavigationContainer", {
459
- ...props,
460
- ref
461
- }, props.children));
462
- NavigationContainer.displayName = "NavigationContainer";
463
- const navigate = vi.fn();
464
- const goBack = vi.fn();
465
- const reset = vi.fn();
466
- const setParams = vi.fn();
467
- const setOptions = vi.fn();
468
- const dispatch = vi.fn();
469
- const canGoBack = vi.fn(() => false);
470
- const getParent = vi.fn(() => void 0);
471
- const getState = vi.fn(() => ({
472
- index: 0,
473
- key: "root",
474
- routeNames: [],
475
- routes: [],
476
- type: "stack",
477
- stale: false
478
- }));
479
- function useNavigation() {
439
+ modules: {
440
+ "@react-navigation/native": {
441
+ exports: [
442
+ "NavigationContainer",
443
+ "useNavigation",
444
+ "useRoute",
445
+ "useFocusEffect",
446
+ "useIsFocused",
447
+ "useNavigationState",
448
+ "createNavigationContainerRef",
449
+ "NavigationContext",
450
+ "NavigationRouteContext",
451
+ "CommonActions",
452
+ "StackActions",
453
+ "TabActions",
454
+ "DrawerActions",
455
+ "useLinkTo",
456
+ "Link"
457
+ ],
458
+ factory: () => {
459
+ const NavigationContainer = React.forwardRef((props, ref) => React.createElement("NavigationContainer", {
460
+ ...props,
461
+ ref
462
+ }, props.children));
463
+ NavigationContainer.displayName = "NavigationContainer";
464
+ const navigate = vi.fn();
465
+ const goBack = vi.fn();
466
+ const reset = vi.fn();
467
+ const setParams = vi.fn();
468
+ const setOptions = vi.fn();
469
+ const dispatch = vi.fn();
470
+ const canGoBack = vi.fn(() => false);
471
+ const getParent = vi.fn(() => void 0);
472
+ const getState = vi.fn(() => ({
473
+ index: 0,
474
+ key: "root",
475
+ routeNames: [],
476
+ routes: [],
477
+ type: "stack",
478
+ stale: false
479
+ }));
480
+ function useNavigation() {
481
+ return {
482
+ navigate,
483
+ goBack,
484
+ reset,
485
+ setParams,
486
+ setOptions,
487
+ dispatch,
488
+ canGoBack,
489
+ getParent,
490
+ getState,
491
+ isFocused: vi.fn(() => true),
492
+ addListener: vi.fn(() => vi.fn()),
493
+ removeListener: vi.fn(),
494
+ getId: vi.fn(() => void 0)
495
+ };
496
+ }
497
+ function useRoute() {
498
+ return {
499
+ key: "test-route-key",
500
+ name: "TestScreen",
501
+ params: {}
502
+ };
503
+ }
504
+ function useFocusEffect(callback) {
505
+ React.useEffect(callback, []);
506
+ }
507
+ function useIsFocused() {
508
+ return true;
509
+ }
510
+ function useNavigationState(selector) {
511
+ return selector(getState());
512
+ }
513
+ function createNavigationContainerRef() {
514
+ return {
515
+ current: null,
516
+ isReady: vi.fn(() => true),
517
+ navigate,
518
+ goBack,
519
+ reset,
520
+ dispatch,
521
+ canGoBack,
522
+ getState,
523
+ getRootState: getState,
524
+ getCurrentRoute: vi.fn(() => ({
525
+ key: "test",
526
+ name: "TestScreen"
527
+ })),
528
+ getCurrentOptions: vi.fn(() => ({})),
529
+ addListener: vi.fn(() => vi.fn())
530
+ };
531
+ }
532
+ const NavigationContext = React.createContext(null);
533
+ const NavigationRouteContext = React.createContext(null);
480
534
  return {
481
- navigate,
482
- goBack,
483
- reset,
484
- setParams,
485
- setOptions,
486
- dispatch,
487
- canGoBack,
488
- getParent,
489
- getState,
490
- isFocused: vi.fn(() => true),
491
- addListener: vi.fn(() => vi.fn()),
492
- removeListener: vi.fn(),
493
- getId: vi.fn(() => void 0)
535
+ default: { NavigationContainer },
536
+ NavigationContainer,
537
+ useNavigation,
538
+ useRoute,
539
+ useFocusEffect,
540
+ useIsFocused,
541
+ useNavigationState,
542
+ createNavigationContainerRef,
543
+ NavigationContext,
544
+ NavigationRouteContext,
545
+ CommonActions: {
546
+ navigate: vi.fn(),
547
+ reset: vi.fn(),
548
+ goBack: vi.fn(),
549
+ setParams: vi.fn()
550
+ },
551
+ StackActions: {
552
+ push: vi.fn(),
553
+ pop: vi.fn(),
554
+ popToTop: vi.fn(),
555
+ replace: vi.fn()
556
+ },
557
+ TabActions: { jumpTo: vi.fn() },
558
+ DrawerActions: {
559
+ openDrawer: vi.fn(),
560
+ closeDrawer: vi.fn(),
561
+ toggleDrawer: vi.fn(),
562
+ jumpTo: vi.fn()
563
+ },
564
+ useLinkTo: vi.fn(() => vi.fn()),
565
+ Link: React.forwardRef((props, ref) => React.createElement("Link", {
566
+ ...props,
567
+ ref
568
+ }, props.children))
494
569
  };
495
570
  }
496
- function useRoute() {
571
+ },
572
+ "@react-navigation/native-stack": {
573
+ exports: ["createNativeStackNavigator"],
574
+ factory: () => {
575
+ function createNativeStackNavigator() {
576
+ return {
577
+ Navigator: React.forwardRef((props, ref) => React.createElement("NativeStackNavigator", {
578
+ ...props,
579
+ ref
580
+ }, props.children)),
581
+ Screen: React.forwardRef((props, ref) => React.createElement("Screen", {
582
+ ...props,
583
+ ref
584
+ }, props.children)),
585
+ Group: React.forwardRef((props, ref) => React.createElement("Group", {
586
+ ...props,
587
+ ref
588
+ }, props.children))
589
+ };
590
+ }
497
591
  return {
498
- key: "test-route-key",
499
- name: "TestScreen",
500
- params: {}
592
+ default: { createNativeStackNavigator },
593
+ createNativeStackNavigator
501
594
  };
502
595
  }
503
- function useFocusEffect(callback) {
504
- React.useEffect(callback, []);
505
- }
506
- function useIsFocused() {
507
- return true;
508
- }
509
- function useNavigationState(selector) {
510
- return selector(getState());
511
- }
512
- function createNavigationContainerRef() {
596
+ },
597
+ "@react-navigation/bottom-tabs": {
598
+ exports: ["createBottomTabNavigator"],
599
+ factory: () => {
600
+ function createBottomTabNavigator() {
601
+ return {
602
+ Navigator: React.forwardRef((props, ref) => React.createElement("BottomTabNavigator", {
603
+ ...props,
604
+ ref
605
+ }, props.children)),
606
+ Screen: React.forwardRef((props, ref) => React.createElement("Screen", {
607
+ ...props,
608
+ ref
609
+ }, props.children)),
610
+ Group: React.forwardRef((props, ref) => React.createElement("Group", {
611
+ ...props,
612
+ ref
613
+ }, props.children))
614
+ };
615
+ }
513
616
  return {
514
- current: null,
515
- isReady: vi.fn(() => true),
516
- navigate,
517
- goBack,
518
- reset,
519
- dispatch,
520
- canGoBack,
521
- getState,
522
- getRootState: getState,
523
- getCurrentRoute: vi.fn(() => ({
524
- key: "test",
525
- name: "TestScreen"
526
- })),
527
- getCurrentOptions: vi.fn(() => ({})),
528
- addListener: vi.fn(() => vi.fn())
617
+ default: { createBottomTabNavigator },
618
+ createBottomTabNavigator
529
619
  };
530
620
  }
531
- const NavigationContext = React.createContext(null);
532
- const NavigationRouteContext = React.createContext(null);
533
- return {
534
- default: { NavigationContainer },
535
- NavigationContainer,
536
- useNavigation,
537
- useRoute,
538
- useFocusEffect,
539
- useIsFocused,
540
- useNavigationState,
541
- createNavigationContainerRef,
542
- NavigationContext,
543
- NavigationRouteContext,
544
- CommonActions: {
545
- navigate: vi.fn(),
546
- reset: vi.fn(),
547
- goBack: vi.fn(),
548
- setParams: vi.fn()
549
- },
550
- StackActions: {
551
- push: vi.fn(),
552
- pop: vi.fn(),
553
- popToTop: vi.fn(),
554
- replace: vi.fn()
555
- },
556
- TabActions: { jumpTo: vi.fn() },
557
- DrawerActions: {
558
- openDrawer: vi.fn(),
559
- closeDrawer: vi.fn(),
560
- toggleDrawer: vi.fn(),
561
- jumpTo: vi.fn()
562
- },
563
- useLinkTo: vi.fn(() => vi.fn()),
564
- Link: React.forwardRef((props, ref) => React.createElement("Link", {
621
+ },
622
+ "@react-navigation/elements": {
623
+ exports: [
624
+ "Header",
625
+ "HeaderBackground",
626
+ "HeaderBackButton",
627
+ "HeaderTitle",
628
+ "HeaderBackContext",
629
+ "HeaderShownContext",
630
+ "HeaderHeightContext",
631
+ "useHeaderHeight",
632
+ "getDefaultHeaderHeight",
633
+ "getHeaderTitle"
634
+ ],
635
+ factory: () => {
636
+ const Header = React.forwardRef((props, ref) => React.createElement("Header", {
565
637
  ...props,
566
638
  ref
567
- }, props.children))
568
- };
639
+ }, props.children));
640
+ Header.displayName = "Header";
641
+ const HeaderBackground = React.forwardRef((props, ref) => React.createElement("HeaderBackground", {
642
+ ...props,
643
+ ref
644
+ }, props.children));
645
+ HeaderBackground.displayName = "HeaderBackground";
646
+ const HeaderBackButton = React.forwardRef((props, ref) => React.createElement("HeaderBackButton", {
647
+ ...props,
648
+ ref
649
+ }));
650
+ HeaderBackButton.displayName = "HeaderBackButton";
651
+ const HeaderTitle = React.forwardRef((props, ref) => React.createElement("HeaderTitle", {
652
+ ...props,
653
+ ref
654
+ }, props.children));
655
+ HeaderTitle.displayName = "HeaderTitle";
656
+ return {
657
+ default: {
658
+ Header,
659
+ HeaderBackground,
660
+ HeaderBackButton,
661
+ HeaderTitle
662
+ },
663
+ Header,
664
+ HeaderBackground,
665
+ HeaderBackButton,
666
+ HeaderTitle,
667
+ HeaderBackContext: React.createContext(void 0),
668
+ HeaderShownContext: React.createContext(true),
669
+ HeaderHeightContext: React.createContext(64),
670
+ useHeaderHeight: () => 64,
671
+ getDefaultHeaderHeight: vi.fn(() => 64),
672
+ getHeaderTitle: vi.fn((options, fallback) => options?.headerTitle ?? options?.title ?? fallback)
673
+ };
674
+ }
569
675
  }
570
- } }
676
+ }
571
677
  };
572
678
  }
573
679
  //#endregion
@@ -467,138 +467,244 @@ function safeAreaContext() {
467
467
  function navigation() {
468
468
  return {
469
469
  name: "navigation",
470
- modules: { "@react-navigation/native": {
471
- exports: [
472
- "NavigationContainer",
473
- "useNavigation",
474
- "useRoute",
475
- "useFocusEffect",
476
- "useIsFocused",
477
- "useNavigationState",
478
- "createNavigationContainerRef",
479
- "NavigationContext",
480
- "NavigationRouteContext",
481
- "CommonActions",
482
- "StackActions",
483
- "TabActions",
484
- "DrawerActions",
485
- "useLinkTo",
486
- "Link"
487
- ],
488
- factory: () => {
489
- const NavigationContainer = react.default.forwardRef((props, ref) => react.default.createElement("NavigationContainer", {
490
- ...props,
491
- ref
492
- }, props.children));
493
- NavigationContainer.displayName = "NavigationContainer";
494
- const navigate = vitest.vi.fn();
495
- const goBack = vitest.vi.fn();
496
- const reset = vitest.vi.fn();
497
- const setParams = vitest.vi.fn();
498
- const setOptions = vitest.vi.fn();
499
- const dispatch = vitest.vi.fn();
500
- const canGoBack = vitest.vi.fn(() => false);
501
- const getParent = vitest.vi.fn(() => void 0);
502
- const getState = vitest.vi.fn(() => ({
503
- index: 0,
504
- key: "root",
505
- routeNames: [],
506
- routes: [],
507
- type: "stack",
508
- stale: false
509
- }));
510
- function useNavigation() {
470
+ modules: {
471
+ "@react-navigation/native": {
472
+ exports: [
473
+ "NavigationContainer",
474
+ "useNavigation",
475
+ "useRoute",
476
+ "useFocusEffect",
477
+ "useIsFocused",
478
+ "useNavigationState",
479
+ "createNavigationContainerRef",
480
+ "NavigationContext",
481
+ "NavigationRouteContext",
482
+ "CommonActions",
483
+ "StackActions",
484
+ "TabActions",
485
+ "DrawerActions",
486
+ "useLinkTo",
487
+ "Link"
488
+ ],
489
+ factory: () => {
490
+ const NavigationContainer = react.default.forwardRef((props, ref) => react.default.createElement("NavigationContainer", {
491
+ ...props,
492
+ ref
493
+ }, props.children));
494
+ NavigationContainer.displayName = "NavigationContainer";
495
+ const navigate = vitest.vi.fn();
496
+ const goBack = vitest.vi.fn();
497
+ const reset = vitest.vi.fn();
498
+ const setParams = vitest.vi.fn();
499
+ const setOptions = vitest.vi.fn();
500
+ const dispatch = vitest.vi.fn();
501
+ const canGoBack = vitest.vi.fn(() => false);
502
+ const getParent = vitest.vi.fn(() => void 0);
503
+ const getState = vitest.vi.fn(() => ({
504
+ index: 0,
505
+ key: "root",
506
+ routeNames: [],
507
+ routes: [],
508
+ type: "stack",
509
+ stale: false
510
+ }));
511
+ function useNavigation() {
512
+ return {
513
+ navigate,
514
+ goBack,
515
+ reset,
516
+ setParams,
517
+ setOptions,
518
+ dispatch,
519
+ canGoBack,
520
+ getParent,
521
+ getState,
522
+ isFocused: vitest.vi.fn(() => true),
523
+ addListener: vitest.vi.fn(() => vitest.vi.fn()),
524
+ removeListener: vitest.vi.fn(),
525
+ getId: vitest.vi.fn(() => void 0)
526
+ };
527
+ }
528
+ function useRoute() {
529
+ return {
530
+ key: "test-route-key",
531
+ name: "TestScreen",
532
+ params: {}
533
+ };
534
+ }
535
+ function useFocusEffect(callback) {
536
+ react.default.useEffect(callback, []);
537
+ }
538
+ function useIsFocused() {
539
+ return true;
540
+ }
541
+ function useNavigationState(selector) {
542
+ return selector(getState());
543
+ }
544
+ function createNavigationContainerRef() {
545
+ return {
546
+ current: null,
547
+ isReady: vitest.vi.fn(() => true),
548
+ navigate,
549
+ goBack,
550
+ reset,
551
+ dispatch,
552
+ canGoBack,
553
+ getState,
554
+ getRootState: getState,
555
+ getCurrentRoute: vitest.vi.fn(() => ({
556
+ key: "test",
557
+ name: "TestScreen"
558
+ })),
559
+ getCurrentOptions: vitest.vi.fn(() => ({})),
560
+ addListener: vitest.vi.fn(() => vitest.vi.fn())
561
+ };
562
+ }
563
+ const NavigationContext = react.default.createContext(null);
564
+ const NavigationRouteContext = react.default.createContext(null);
511
565
  return {
512
- navigate,
513
- goBack,
514
- reset,
515
- setParams,
516
- setOptions,
517
- dispatch,
518
- canGoBack,
519
- getParent,
520
- getState,
521
- isFocused: vitest.vi.fn(() => true),
522
- addListener: vitest.vi.fn(() => vitest.vi.fn()),
523
- removeListener: vitest.vi.fn(),
524
- getId: vitest.vi.fn(() => void 0)
566
+ default: { NavigationContainer },
567
+ NavigationContainer,
568
+ useNavigation,
569
+ useRoute,
570
+ useFocusEffect,
571
+ useIsFocused,
572
+ useNavigationState,
573
+ createNavigationContainerRef,
574
+ NavigationContext,
575
+ NavigationRouteContext,
576
+ CommonActions: {
577
+ navigate: vitest.vi.fn(),
578
+ reset: vitest.vi.fn(),
579
+ goBack: vitest.vi.fn(),
580
+ setParams: vitest.vi.fn()
581
+ },
582
+ StackActions: {
583
+ push: vitest.vi.fn(),
584
+ pop: vitest.vi.fn(),
585
+ popToTop: vitest.vi.fn(),
586
+ replace: vitest.vi.fn()
587
+ },
588
+ TabActions: { jumpTo: vitest.vi.fn() },
589
+ DrawerActions: {
590
+ openDrawer: vitest.vi.fn(),
591
+ closeDrawer: vitest.vi.fn(),
592
+ toggleDrawer: vitest.vi.fn(),
593
+ jumpTo: vitest.vi.fn()
594
+ },
595
+ useLinkTo: vitest.vi.fn(() => vitest.vi.fn()),
596
+ Link: react.default.forwardRef((props, ref) => react.default.createElement("Link", {
597
+ ...props,
598
+ ref
599
+ }, props.children))
525
600
  };
526
601
  }
527
- function useRoute() {
602
+ },
603
+ "@react-navigation/native-stack": {
604
+ exports: ["createNativeStackNavigator"],
605
+ factory: () => {
606
+ function createNativeStackNavigator() {
607
+ return {
608
+ Navigator: react.default.forwardRef((props, ref) => react.default.createElement("NativeStackNavigator", {
609
+ ...props,
610
+ ref
611
+ }, props.children)),
612
+ Screen: react.default.forwardRef((props, ref) => react.default.createElement("Screen", {
613
+ ...props,
614
+ ref
615
+ }, props.children)),
616
+ Group: react.default.forwardRef((props, ref) => react.default.createElement("Group", {
617
+ ...props,
618
+ ref
619
+ }, props.children))
620
+ };
621
+ }
528
622
  return {
529
- key: "test-route-key",
530
- name: "TestScreen",
531
- params: {}
623
+ default: { createNativeStackNavigator },
624
+ createNativeStackNavigator
532
625
  };
533
626
  }
534
- function useFocusEffect(callback) {
535
- react.default.useEffect(callback, []);
536
- }
537
- function useIsFocused() {
538
- return true;
539
- }
540
- function useNavigationState(selector) {
541
- return selector(getState());
542
- }
543
- function createNavigationContainerRef() {
627
+ },
628
+ "@react-navigation/bottom-tabs": {
629
+ exports: ["createBottomTabNavigator"],
630
+ factory: () => {
631
+ function createBottomTabNavigator() {
632
+ return {
633
+ Navigator: react.default.forwardRef((props, ref) => react.default.createElement("BottomTabNavigator", {
634
+ ...props,
635
+ ref
636
+ }, props.children)),
637
+ Screen: react.default.forwardRef((props, ref) => react.default.createElement("Screen", {
638
+ ...props,
639
+ ref
640
+ }, props.children)),
641
+ Group: react.default.forwardRef((props, ref) => react.default.createElement("Group", {
642
+ ...props,
643
+ ref
644
+ }, props.children))
645
+ };
646
+ }
544
647
  return {
545
- current: null,
546
- isReady: vitest.vi.fn(() => true),
547
- navigate,
548
- goBack,
549
- reset,
550
- dispatch,
551
- canGoBack,
552
- getState,
553
- getRootState: getState,
554
- getCurrentRoute: vitest.vi.fn(() => ({
555
- key: "test",
556
- name: "TestScreen"
557
- })),
558
- getCurrentOptions: vitest.vi.fn(() => ({})),
559
- addListener: vitest.vi.fn(() => vitest.vi.fn())
648
+ default: { createBottomTabNavigator },
649
+ createBottomTabNavigator
560
650
  };
561
651
  }
562
- const NavigationContext = react.default.createContext(null);
563
- const NavigationRouteContext = react.default.createContext(null);
564
- return {
565
- default: { NavigationContainer },
566
- NavigationContainer,
567
- useNavigation,
568
- useRoute,
569
- useFocusEffect,
570
- useIsFocused,
571
- useNavigationState,
572
- createNavigationContainerRef,
573
- NavigationContext,
574
- NavigationRouteContext,
575
- CommonActions: {
576
- navigate: vitest.vi.fn(),
577
- reset: vitest.vi.fn(),
578
- goBack: vitest.vi.fn(),
579
- setParams: vitest.vi.fn()
580
- },
581
- StackActions: {
582
- push: vitest.vi.fn(),
583
- pop: vitest.vi.fn(),
584
- popToTop: vitest.vi.fn(),
585
- replace: vitest.vi.fn()
586
- },
587
- TabActions: { jumpTo: vitest.vi.fn() },
588
- DrawerActions: {
589
- openDrawer: vitest.vi.fn(),
590
- closeDrawer: vitest.vi.fn(),
591
- toggleDrawer: vitest.vi.fn(),
592
- jumpTo: vitest.vi.fn()
593
- },
594
- useLinkTo: vitest.vi.fn(() => vitest.vi.fn()),
595
- Link: react.default.forwardRef((props, ref) => react.default.createElement("Link", {
652
+ },
653
+ "@react-navigation/elements": {
654
+ exports: [
655
+ "Header",
656
+ "HeaderBackground",
657
+ "HeaderBackButton",
658
+ "HeaderTitle",
659
+ "HeaderBackContext",
660
+ "HeaderShownContext",
661
+ "HeaderHeightContext",
662
+ "useHeaderHeight",
663
+ "getDefaultHeaderHeight",
664
+ "getHeaderTitle"
665
+ ],
666
+ factory: () => {
667
+ const Header = react.default.forwardRef((props, ref) => react.default.createElement("Header", {
596
668
  ...props,
597
669
  ref
598
- }, props.children))
599
- };
670
+ }, props.children));
671
+ Header.displayName = "Header";
672
+ const HeaderBackground = react.default.forwardRef((props, ref) => react.default.createElement("HeaderBackground", {
673
+ ...props,
674
+ ref
675
+ }, props.children));
676
+ HeaderBackground.displayName = "HeaderBackground";
677
+ const HeaderBackButton = react.default.forwardRef((props, ref) => react.default.createElement("HeaderBackButton", {
678
+ ...props,
679
+ ref
680
+ }));
681
+ HeaderBackButton.displayName = "HeaderBackButton";
682
+ const HeaderTitle = react.default.forwardRef((props, ref) => react.default.createElement("HeaderTitle", {
683
+ ...props,
684
+ ref
685
+ }, props.children));
686
+ HeaderTitle.displayName = "HeaderTitle";
687
+ return {
688
+ default: {
689
+ Header,
690
+ HeaderBackground,
691
+ HeaderBackButton,
692
+ HeaderTitle
693
+ },
694
+ Header,
695
+ HeaderBackground,
696
+ HeaderBackButton,
697
+ HeaderTitle,
698
+ HeaderBackContext: react.default.createContext(void 0),
699
+ HeaderShownContext: react.default.createContext(true),
700
+ HeaderHeightContext: react.default.createContext(64),
701
+ useHeaderHeight: () => 64,
702
+ getDefaultHeaderHeight: vitest.vi.fn(() => 64),
703
+ getHeaderTitle: vitest.vi.fn((options, fallback) => options?.headerTitle ?? options?.title ?? fallback)
704
+ };
705
+ }
600
706
  }
601
- } }
707
+ }
602
708
  };
603
709
  }
604
710
  //#endregion
package/dist/presets.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_presets = require("./presets-ArwboRy7.cjs");
2
+ const require_presets = require("./presets-D4jrt194.cjs");
3
3
  exports.asyncStorage = require_presets.asyncStorage;
4
4
  exports.expo = require_presets.expo;
5
5
  exports.gestureHandler = require_presets.gestureHandler;
package/dist/presets.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { a as navigation, c as reanimated, i as asyncStorage, n as expo, o as safeAreaContext, r as screens, s as gestureHandler } from "./presets-DgEuMxfn.mjs";
1
+ import { a as navigation, c as reanimated, i as asyncStorage, n as expo, o as safeAreaContext, r as screens, s as gestureHandler } from "./presets-C9tAPD15.mjs";
2
2
  export { asyncStorage, expo, gestureHandler, navigation, reanimated, safeAreaContext, screens };
package/dist/setup.cjs CHANGED
@@ -1,5 +1,5 @@
1
- const require_presets = require("./presets-ArwboRy7.cjs");
2
- const require_preset_map = require("./preset-map-C5d8DSY7.cjs");
1
+ const require_presets = require("./presets-D4jrt194.cjs");
2
+ const require_preset_map = require("./preset-map-Bt4dXkZO.cjs");
3
3
  const require_serializer = require("./serializer.cjs");
4
4
  let node_path = require("node:path");
5
5
  node_path = require_presets.__toESM(node_path);
package/dist/setup.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { n as __require } from "./chunk-CjcI7cDX.mjs";
2
- import { t as AUTO_DETECT_PRESETS } from "./preset-map-CTAjv5aa.mjs";
3
- import { t as presets_exports } from "./presets-DgEuMxfn.mjs";
2
+ import { t as AUTO_DETECT_PRESETS } from "./preset-map-D224CC5w.mjs";
3
+ import { t as presets_exports } from "./presets-C9tAPD15.mjs";
4
4
  import { serializer } from "./serializer.mjs";
5
5
  import { createRequire } from "node:module";
6
6
  import path from "node:path";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitest-native",
3
- "version": "0.1.2",
3
+ "version": "0.2.0",
4
4
  "type": "module",
5
5
  "description": "A Vitest plugin for React Native. One install, zero config.",
6
6
  "license": "MIT",
@@ -79,9 +79,13 @@
79
79
  }
80
80
  }
81
81
  },
82
- "files": ["dist", "LICENSE"],
82
+ "files": [
83
+ "dist",
84
+ "LICENSE",
85
+ "CHANGELOG.md"
86
+ ],
83
87
  "engines": {
84
- "node": ">=18"
88
+ "node": ">=20"
85
89
  },
86
90
  "sideEffects": false,
87
91
  "publishConfig": {