vitest-native 0.8.0 → 0.10.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 +1063 -0
- package/README.md +47 -2
- package/dist/cli.cjs +642 -0
- package/dist/cli.d.cts +4 -0
- package/dist/cli.d.mts +4 -0
- package/dist/cli.mjs +638 -0
- package/dist/ecosystem-CO5vqExO.mjs +318 -0
- package/dist/ecosystem-IuZ-Gv0R.cjs +356 -0
- package/dist/errors-Dm5yLNTF.mjs +64 -0
- package/dist/errors-flXDIeWk.cjs +75 -0
- package/dist/errors.d.mts +46 -0
- package/dist/errors.mjs +78 -0
- package/dist/helpers.cjs +6 -23
- package/dist/helpers.d.cts +0 -6
- package/dist/helpers.d.mts +0 -6
- package/dist/helpers.mjs +6 -23
- package/dist/{index-vlK4zxuK.d.mts → index-BJL4cQ-l.d.cts} +22 -7
- package/dist/{index-YjjYELG7.d.cts → index-CvCU0cLl.d.mts} +20 -9
- package/dist/index.d.mts +8 -6
- package/dist/index.mjs +563 -232
- package/dist/jest-compat/interop.mjs +15 -0
- package/dist/jest-compat/setup.mjs +164 -5
- package/dist/matchers.cjs +16 -7
- package/dist/matchers.mjs +16 -7
- package/dist/native/boundary.mjs +108 -30
- package/dist/native/compile-cache.mjs +10 -5
- package/dist/native/explain.mjs +69 -0
- package/dist/native/hooks.mjs +151 -4
- package/dist/native/loader.mjs +61 -12
- package/dist/native/match.mjs +107 -8
- package/dist/native/module-reset.mjs +63 -0
- package/dist/native/registry.mjs +540 -0
- package/dist/native/reset.mjs +18 -12
- package/dist/native/resolve.d.mts +22 -0
- package/dist/native/resolve.mjs +21 -13
- package/dist/native/runner.mjs +34 -7
- package/dist/native/setup.mjs +19 -3
- package/dist/native/transform.mjs +195 -21
- package/dist/native/worker.mjs +69 -17
- package/dist/pool-Bcxp4Qrg.mjs +118 -0
- package/dist/pool-CFND7plG.cjs +122 -0
- package/dist/{preset-map-DCWaM08s.mjs → preset-map-BpDG_D5m.mjs} +1 -1
- package/dist/{preset-map-BY9zk9Pj.cjs → preset-map-DxilQ4pI.cjs} +1 -1
- package/dist/{presets-7eMfp7o2.cjs → presets-BGTqVH6C.cjs} +227 -52
- package/dist/{presets-23FJ76O4.mjs → presets-CK85x8ey.mjs} +222 -53
- package/dist/presets.d.mts +2 -2
- package/dist/presets.mjs +2 -2
- package/dist/rntl-matchers.d.ts +35 -0
- package/dist/serializer.cjs +33 -3
- package/dist/serializer.mjs +33 -3
- package/dist/setup.mjs +544 -193
- package/docs/hot-default-design.md +129 -0
- package/docs/migrating-from-jest.md +43 -7
- package/docs/migrating-from-vitest-react-native.md +1 -1
- package/docs/release-readiness.md +24 -6
- package/docs/versioning.md +133 -0
- package/package.json +40 -38
- package/dist/index.cjs +0 -643
- package/dist/index.d.cts +0 -14
- package/dist/pool-B7LBfcMQ.mjs +0 -67
- package/dist/pool-p54QV1dQ.cjs +0 -69
- package/dist/presets.cjs +0 -17
- package/dist/presets.d.cts +0 -2
- package/dist/setup.cjs +0 -2514
- package/dist/setup.d.cts +0 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { t as __exportAll } from "./chunk-CjcI7cDX.mjs";
|
|
2
|
+
import { t as VitestNativeError } from "./errors-Dm5yLNTF.mjs";
|
|
2
3
|
import { createRequire } from "node:module";
|
|
3
4
|
import path from "node:path";
|
|
4
5
|
import { vi } from "vitest";
|
|
@@ -47,11 +48,6 @@ function reanimated() {
|
|
|
47
48
|
"addWhitelistedUIProps",
|
|
48
49
|
"addWhitelistedNativeProps",
|
|
49
50
|
"configureProps",
|
|
50
|
-
"View",
|
|
51
|
-
"Text",
|
|
52
|
-
"Image",
|
|
53
|
-
"ScrollView",
|
|
54
|
-
"FlatList",
|
|
55
51
|
"Easing",
|
|
56
52
|
"FadeIn",
|
|
57
53
|
"FadeOut",
|
|
@@ -231,7 +227,7 @@ function reanimated() {
|
|
|
231
227
|
function makeAnimatedHost(name) {
|
|
232
228
|
const Comp = React.forwardRef((props, ref) => {
|
|
233
229
|
const Base = getRN()[name];
|
|
234
|
-
if (!Base) throw new
|
|
230
|
+
if (!Base) throw new VitestNativeError("PRESET_UNAVAILABLE", `The reanimated preset needs React Native's '${name}' component to build Animated.${name}, and react-native did not provide it.\nThis usually means react-native resolved to something unexpected — a partially installed copy, or a mock replacing the whole module. Check that 'react-native' resolves in your project and that no vi.mock replaces it wholesale.`);
|
|
235
231
|
return React.createElement(Base, {
|
|
236
232
|
...props,
|
|
237
233
|
ref
|
|
@@ -278,11 +274,6 @@ function reanimated() {
|
|
|
278
274
|
addWhitelistedUIProps,
|
|
279
275
|
addWhitelistedNativeProps,
|
|
280
276
|
configureProps,
|
|
281
|
-
View,
|
|
282
|
-
Text,
|
|
283
|
-
Image,
|
|
284
|
-
ScrollView,
|
|
285
|
-
FlatList,
|
|
286
277
|
useSharedValue,
|
|
287
278
|
useAnimatedStyle,
|
|
288
279
|
useAnimatedProps,
|
|
@@ -440,7 +431,26 @@ function buildPressableHostProps(props, ref) {
|
|
|
440
431
|
//#endregion
|
|
441
432
|
//#region src/mocks/components/Pressable.ts
|
|
442
433
|
function createPressableMock() {
|
|
443
|
-
const Pressable = React.forwardRef((props, ref) =>
|
|
434
|
+
const Pressable = React.forwardRef((props, ref) => {
|
|
435
|
+
const { style, children, onPressIn, onPressOut, ...rest } = props;
|
|
436
|
+
const [pressed, setPressed] = React.useState(false);
|
|
437
|
+
const state = { pressed };
|
|
438
|
+
const resolvedStyle = typeof style === "function" ? style(state) : style;
|
|
439
|
+
const resolvedChildren = typeof children === "function" ? children(state) : children;
|
|
440
|
+
const hostProps = buildPressableHostProps({
|
|
441
|
+
...rest,
|
|
442
|
+
style: resolvedStyle,
|
|
443
|
+
onPressIn: (e) => {
|
|
444
|
+
setPressed(true);
|
|
445
|
+
onPressIn?.(e);
|
|
446
|
+
},
|
|
447
|
+
onPressOut: (e) => {
|
|
448
|
+
setPressed(false);
|
|
449
|
+
onPressOut?.(e);
|
|
450
|
+
}
|
|
451
|
+
}, ref);
|
|
452
|
+
return React.createElement("Pressable", hostProps, resolvedChildren);
|
|
453
|
+
});
|
|
444
454
|
Pressable.displayName = "Pressable";
|
|
445
455
|
return Pressable;
|
|
446
456
|
}
|
|
@@ -623,10 +633,7 @@ function safeAreaContext() {
|
|
|
623
633
|
"useSafeAreaFrame",
|
|
624
634
|
"withSafeAreaInsets",
|
|
625
635
|
"initialWindowMetrics",
|
|
626
|
-
"initialWindowSafeAreaInsets"
|
|
627
|
-
"EdgeInsets",
|
|
628
|
-
"Rect",
|
|
629
|
-
"Metrics"
|
|
636
|
+
"initialWindowSafeAreaInsets"
|
|
630
637
|
],
|
|
631
638
|
factory: () => {
|
|
632
639
|
const defaultInsets = {
|
|
@@ -1244,12 +1251,29 @@ function screens() {
|
|
|
1244
1251
|
"screensEnabled",
|
|
1245
1252
|
"enableFreeze",
|
|
1246
1253
|
"freezeEnabled",
|
|
1254
|
+
"featureFlags",
|
|
1255
|
+
"compatibilityFlags",
|
|
1256
|
+
"executeNativeBackPress",
|
|
1257
|
+
"isSearchBarAvailableForCurrentPlatform",
|
|
1258
|
+
"useTransitionProgress",
|
|
1247
1259
|
"Screen",
|
|
1260
|
+
"InnerScreen",
|
|
1248
1261
|
"ScreenContainer",
|
|
1262
|
+
"ScreenContentWrapper",
|
|
1263
|
+
"ScreenContext",
|
|
1264
|
+
"ScreenFooter",
|
|
1249
1265
|
"ScreenStack",
|
|
1266
|
+
"ScreenStackItem",
|
|
1250
1267
|
"ScreenStackHeaderConfig",
|
|
1268
|
+
"ScreenStackHeaderBackButtonImage",
|
|
1269
|
+
"ScreenStackHeaderCenterView",
|
|
1270
|
+
"ScreenStackHeaderLeftView",
|
|
1271
|
+
"ScreenStackHeaderRightView",
|
|
1272
|
+
"ScreenStackHeaderSearchBarView",
|
|
1273
|
+
"ScreenStackHeaderSubview",
|
|
1251
1274
|
"SearchBar",
|
|
1252
1275
|
"FullWindowOverlay",
|
|
1276
|
+
"Tabs",
|
|
1253
1277
|
"NativeScreen",
|
|
1254
1278
|
"NativeScreenContainer"
|
|
1255
1279
|
],
|
|
@@ -1280,6 +1304,24 @@ function screens() {
|
|
|
1280
1304
|
const FullWindowOverlay = createScreenComponent("FullWindowOverlay");
|
|
1281
1305
|
const NativeScreen = createScreenComponent("NativeScreen");
|
|
1282
1306
|
const NativeScreenContainer = createScreenComponent("NativeScreenContainer");
|
|
1307
|
+
const InnerScreen = createScreenComponent("InnerScreen");
|
|
1308
|
+
const ScreenContentWrapper = createScreenComponent("ScreenContentWrapper");
|
|
1309
|
+
const ScreenFooter = createScreenComponent("ScreenFooter");
|
|
1310
|
+
const ScreenStackItem = createScreenComponent("ScreenStackItem");
|
|
1311
|
+
const ScreenStackHeaderBackButtonImage = createScreenComponent("ScreenStackHeaderBackButtonImage");
|
|
1312
|
+
const ScreenStackHeaderCenterView = createScreenComponent("ScreenStackHeaderCenterView");
|
|
1313
|
+
const ScreenStackHeaderLeftView = createScreenComponent("ScreenStackHeaderLeftView");
|
|
1314
|
+
const ScreenStackHeaderRightView = createScreenComponent("ScreenStackHeaderRightView");
|
|
1315
|
+
const ScreenStackHeaderSearchBarView = createScreenComponent("ScreenStackHeaderSearchBarView");
|
|
1316
|
+
const ScreenStackHeaderSubview = createScreenComponent("ScreenStackHeaderSubview");
|
|
1317
|
+
const Tabs = createScreenComponent("Tabs");
|
|
1318
|
+
const ScreenContext = React.createContext(Screen);
|
|
1319
|
+
const useTransitionProgress = vi.fn(() => ({
|
|
1320
|
+
progress: 1,
|
|
1321
|
+
closing: 0,
|
|
1322
|
+
goingForward: 0
|
|
1323
|
+
}));
|
|
1324
|
+
const executeNativeBackPress = vi.fn(() => true);
|
|
1283
1325
|
return {
|
|
1284
1326
|
default: {
|
|
1285
1327
|
Screen,
|
|
@@ -1298,7 +1340,27 @@ function screens() {
|
|
|
1298
1340
|
SearchBar,
|
|
1299
1341
|
FullWindowOverlay,
|
|
1300
1342
|
NativeScreen,
|
|
1301
|
-
NativeScreenContainer
|
|
1343
|
+
NativeScreenContainer,
|
|
1344
|
+
InnerScreen,
|
|
1345
|
+
ScreenContentWrapper,
|
|
1346
|
+
ScreenContext,
|
|
1347
|
+
ScreenFooter,
|
|
1348
|
+
ScreenStackItem,
|
|
1349
|
+
ScreenStackHeaderBackButtonImage,
|
|
1350
|
+
ScreenStackHeaderCenterView,
|
|
1351
|
+
ScreenStackHeaderLeftView,
|
|
1352
|
+
ScreenStackHeaderRightView,
|
|
1353
|
+
ScreenStackHeaderSearchBarView,
|
|
1354
|
+
ScreenStackHeaderSubview,
|
|
1355
|
+
Tabs,
|
|
1356
|
+
useTransitionProgress,
|
|
1357
|
+
executeNativeBackPress,
|
|
1358
|
+
isSearchBarAvailableForCurrentPlatform: true,
|
|
1359
|
+
featureFlags: {
|
|
1360
|
+
experiment: {},
|
|
1361
|
+
flags: {}
|
|
1362
|
+
},
|
|
1363
|
+
compatibilityFlags: {}
|
|
1302
1364
|
};
|
|
1303
1365
|
}
|
|
1304
1366
|
} }
|
|
@@ -1312,42 +1374,44 @@ function expo() {
|
|
|
1312
1374
|
modules: {
|
|
1313
1375
|
"expo-constants": {
|
|
1314
1376
|
exports: [
|
|
1315
|
-
"
|
|
1316
|
-
"
|
|
1317
|
-
"
|
|
1318
|
-
"isDevice",
|
|
1319
|
-
"platform",
|
|
1320
|
-
"manifest",
|
|
1321
|
-
"manifest2",
|
|
1322
|
-
"expoGoConfig",
|
|
1323
|
-
"easConfig",
|
|
1324
|
-
"experienceUrl",
|
|
1325
|
-
"linkingUri",
|
|
1326
|
-
"getWebViewUserAgentAsync"
|
|
1377
|
+
"AppOwnership",
|
|
1378
|
+
"ExecutionEnvironment",
|
|
1379
|
+
"UserInterfaceIdiom"
|
|
1327
1380
|
],
|
|
1328
1381
|
factory: () => {
|
|
1329
|
-
const Constants = {
|
|
1330
|
-
expoConfig: {
|
|
1331
|
-
name: "test-app",
|
|
1332
|
-
slug: "test-app",
|
|
1333
|
-
version: "1.0.0",
|
|
1334
|
-
extra: {}
|
|
1335
|
-
},
|
|
1336
|
-
executionEnvironment: "storeClient",
|
|
1337
|
-
appOwnership: "standalone",
|
|
1338
|
-
isDevice: true,
|
|
1339
|
-
platform: {},
|
|
1340
|
-
manifest: null,
|
|
1341
|
-
manifest2: null,
|
|
1342
|
-
expoGoConfig: null,
|
|
1343
|
-
easConfig: null,
|
|
1344
|
-
experienceUrl: "",
|
|
1345
|
-
linkingUri: "",
|
|
1346
|
-
getWebViewUserAgentAsync: vi.fn(async () => "test-user-agent")
|
|
1347
|
-
};
|
|
1348
1382
|
return {
|
|
1349
|
-
default:
|
|
1350
|
-
|
|
1383
|
+
default: {
|
|
1384
|
+
expoConfig: {
|
|
1385
|
+
name: "test-app",
|
|
1386
|
+
slug: "test-app",
|
|
1387
|
+
version: "1.0.0",
|
|
1388
|
+
extra: {}
|
|
1389
|
+
},
|
|
1390
|
+
executionEnvironment: "storeClient",
|
|
1391
|
+
appOwnership: "standalone",
|
|
1392
|
+
isDevice: true,
|
|
1393
|
+
platform: {},
|
|
1394
|
+
manifest: null,
|
|
1395
|
+
manifest2: null,
|
|
1396
|
+
expoGoConfig: null,
|
|
1397
|
+
easConfig: null,
|
|
1398
|
+
experienceUrl: "",
|
|
1399
|
+
linkingUri: "",
|
|
1400
|
+
getWebViewUserAgentAsync: vi.fn(async () => "test-user-agent")
|
|
1401
|
+
},
|
|
1402
|
+
AppOwnership: { Expo: "expo" },
|
|
1403
|
+
ExecutionEnvironment: {
|
|
1404
|
+
Bare: "bare",
|
|
1405
|
+
Standalone: "standalone",
|
|
1406
|
+
StoreClient: "storeClient"
|
|
1407
|
+
},
|
|
1408
|
+
UserInterfaceIdiom: {
|
|
1409
|
+
Handset: "handset",
|
|
1410
|
+
Tablet: "tablet",
|
|
1411
|
+
Desktop: "desktop",
|
|
1412
|
+
TV: "tv",
|
|
1413
|
+
Unsupported: "unsupported"
|
|
1414
|
+
}
|
|
1351
1415
|
};
|
|
1352
1416
|
}
|
|
1353
1417
|
},
|
|
@@ -1809,7 +1873,6 @@ function flashList() {
|
|
|
1809
1873
|
"FlashList",
|
|
1810
1874
|
"AnimatedFlashList",
|
|
1811
1875
|
"LayoutCommitObserver",
|
|
1812
|
-
"ViewToken",
|
|
1813
1876
|
"RenderTargetOptions",
|
|
1814
1877
|
"useRecyclingState",
|
|
1815
1878
|
"useLayoutState",
|
|
@@ -2430,6 +2493,111 @@ function keyboardController() {
|
|
|
2430
2493
|
};
|
|
2431
2494
|
}
|
|
2432
2495
|
//#endregion
|
|
2496
|
+
//#region src/presets/worklets.ts
|
|
2497
|
+
const RuntimeKind = {
|
|
2498
|
+
ReactNative: 1,
|
|
2499
|
+
UI: 2,
|
|
2500
|
+
Worker: 3
|
|
2501
|
+
};
|
|
2502
|
+
const NOOP = () => {};
|
|
2503
|
+
const ID = (value) => value;
|
|
2504
|
+
const invoke = (callback) => callback();
|
|
2505
|
+
function worklets() {
|
|
2506
|
+
return {
|
|
2507
|
+
name: "worklets",
|
|
2508
|
+
modules: { "react-native-worklets": {
|
|
2509
|
+
exports: [
|
|
2510
|
+
"runOnJS",
|
|
2511
|
+
"runOnUI",
|
|
2512
|
+
"runOnUIAsync",
|
|
2513
|
+
"runOnUISync",
|
|
2514
|
+
"scheduleOnRN",
|
|
2515
|
+
"scheduleOnUI",
|
|
2516
|
+
"runOnRuntime",
|
|
2517
|
+
"runOnRuntimeAsync",
|
|
2518
|
+
"runOnRuntimeSync",
|
|
2519
|
+
"scheduleOnRuntime",
|
|
2520
|
+
"executeOnUIRuntimeSync",
|
|
2521
|
+
"createWorkletRuntime",
|
|
2522
|
+
"getRuntimeKind",
|
|
2523
|
+
"isRNRuntime",
|
|
2524
|
+
"isUIRuntime",
|
|
2525
|
+
"isWorkerRuntime",
|
|
2526
|
+
"isWorkletRuntime",
|
|
2527
|
+
"RuntimeKind",
|
|
2528
|
+
"makeShareable",
|
|
2529
|
+
"makeShareableCloneRecursive",
|
|
2530
|
+
"makeShareableCloneOnUIRecursive",
|
|
2531
|
+
"isShareable",
|
|
2532
|
+
"isShareableRef",
|
|
2533
|
+
"createShareable",
|
|
2534
|
+
"shareableMappingCache",
|
|
2535
|
+
"createSerializable",
|
|
2536
|
+
"isSerializableRef",
|
|
2537
|
+
"registerCustomSerializable",
|
|
2538
|
+
"serializableMappingCache",
|
|
2539
|
+
"createSynchronizable",
|
|
2540
|
+
"isSynchronizable",
|
|
2541
|
+
"getStaticFeatureFlag",
|
|
2542
|
+
"getDynamicFeatureFlag",
|
|
2543
|
+
"setDynamicFeatureFlag",
|
|
2544
|
+
"callMicrotasks",
|
|
2545
|
+
"isWorkletFunction",
|
|
2546
|
+
"WorkletsModule",
|
|
2547
|
+
"UIRuntimeId"
|
|
2548
|
+
],
|
|
2549
|
+
factory: () => {
|
|
2550
|
+
const runOnJS = (fn) => fn;
|
|
2551
|
+
const runOnUI = (fn) => fn;
|
|
2552
|
+
const runOnUIAsync = (worklet, ...args) => Promise.resolve(worklet(...args));
|
|
2553
|
+
const api = {
|
|
2554
|
+
__esModule: true,
|
|
2555
|
+
runOnJS,
|
|
2556
|
+
runOnUI,
|
|
2557
|
+
runOnUIAsync,
|
|
2558
|
+
runOnUISync: invoke,
|
|
2559
|
+
scheduleOnRN: (fn, ...args) => fn(...args),
|
|
2560
|
+
scheduleOnUI: (worklet, ...args) => worklet(...args),
|
|
2561
|
+
runOnRuntime: ID,
|
|
2562
|
+
runOnRuntimeAsync: (_runtime, worklet, ...args) => Promise.resolve(worklet(...args)),
|
|
2563
|
+
runOnRuntimeSync: (_runtime, worklet, ...args) => worklet(...args),
|
|
2564
|
+
scheduleOnRuntime: invoke,
|
|
2565
|
+
executeOnUIRuntimeSync: ID,
|
|
2566
|
+
callMicrotasks: NOOP,
|
|
2567
|
+
createWorkletRuntime: () => ({}),
|
|
2568
|
+
getRuntimeKind: () => RuntimeKind.ReactNative,
|
|
2569
|
+
RuntimeKind,
|
|
2570
|
+
isRNRuntime: () => true,
|
|
2571
|
+
isUIRuntime: () => false,
|
|
2572
|
+
isWorkerRuntime: () => false,
|
|
2573
|
+
isWorkletRuntime: () => false,
|
|
2574
|
+
UIRuntimeId: 1,
|
|
2575
|
+
makeShareable: ID,
|
|
2576
|
+
makeShareableCloneRecursive: ID,
|
|
2577
|
+
makeShareableCloneOnUIRecursive: ID,
|
|
2578
|
+
createShareable: ID,
|
|
2579
|
+
isShareable: () => false,
|
|
2580
|
+
isShareableRef: () => true,
|
|
2581
|
+
shareableMappingCache: /* @__PURE__ */ new Map(),
|
|
2582
|
+
createSerializable: ID,
|
|
2583
|
+
isSerializableRef: ID,
|
|
2584
|
+
registerCustomSerializable: NOOP,
|
|
2585
|
+
serializableMappingCache: /* @__PURE__ */ new Map(),
|
|
2586
|
+
createSynchronizable: ID,
|
|
2587
|
+
isSynchronizable: () => false,
|
|
2588
|
+
getStaticFeatureFlag: () => false,
|
|
2589
|
+
getDynamicFeatureFlag: () => false,
|
|
2590
|
+
setDynamicFeatureFlag: NOOP,
|
|
2591
|
+
isWorkletFunction: () => false,
|
|
2592
|
+
WorkletsModule: {}
|
|
2593
|
+
};
|
|
2594
|
+
api.default = api;
|
|
2595
|
+
return api;
|
|
2596
|
+
}
|
|
2597
|
+
} }
|
|
2598
|
+
};
|
|
2599
|
+
}
|
|
2600
|
+
//#endregion
|
|
2433
2601
|
//#region src/presets/index.ts
|
|
2434
2602
|
var presets_exports = /* @__PURE__ */ __exportAll({
|
|
2435
2603
|
asyncStorage: () => asyncStorage,
|
|
@@ -2446,7 +2614,8 @@ var presets_exports = /* @__PURE__ */ __exportAll({
|
|
|
2446
2614
|
screens: () => screens,
|
|
2447
2615
|
svg: () => svg,
|
|
2448
2616
|
vectorIcons: () => vectorIcons,
|
|
2449
|
-
webview: () => webview
|
|
2617
|
+
webview: () => webview,
|
|
2618
|
+
worklets: () => worklets
|
|
2450
2619
|
});
|
|
2451
2620
|
//#endregion
|
|
2452
|
-
export {
|
|
2621
|
+
export { navigation as C, buildPressableHostProps as D, createPressableMock as E, reanimated as O, asyncStorage as S, gestureHandler as T, svg as _, bottomSheet as a, expo as b, createTouchableOpacityMock as c, createFlatListMock as d, createScrollViewMock as f, webview as g, vectorIcons as h, createViewMock as i, createVirtualizedListMock as l, flashList as m, worklets as n, createTouchableWithoutFeedbackMock as o, createTextInputMock as p, keyboardController as r, createTouchableHighlightMock as s, presets_exports as t, createSectionListMock as u, mmkv as v, safeAreaContext as w, screens as x, deviceInfo as y };
|
package/dist/presets.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
export { asyncStorage, bottomSheet, deviceInfo, expo, flashList, gestureHandler, keyboardController, mmkv, navigation, reanimated, safeAreaContext, screens, svg, vectorIcons, webview };
|
|
1
|
+
import { _ as reanimated, a as flashList, c as svg, d as expo, f as screens, g as gestureHandler, h as safeAreaContext, i as bottomSheet, l as mmkv, m as navigation, n as worklets, o as vectorIcons, p as asyncStorage, r as keyboardController, s as webview, u as deviceInfo } from "./index-CvCU0cLl.mjs";
|
|
2
|
+
export { asyncStorage, bottomSheet, deviceInfo, expo, flashList, gestureHandler, keyboardController, mmkv, navigation, reanimated, safeAreaContext, screens, svg, vectorIcons, webview, worklets };
|
package/dist/presets.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { C as
|
|
2
|
-
export { asyncStorage, bottomSheet, deviceInfo, expo, flashList, gestureHandler, keyboardController, mmkv, navigation, reanimated, safeAreaContext, screens, svg, vectorIcons, webview };
|
|
1
|
+
import { C as navigation, O as reanimated, S as asyncStorage, T as gestureHandler, _ as svg, a as bottomSheet, b as expo, g as webview, h as vectorIcons, m as flashList, n as worklets, r as keyboardController, v as mmkv, w as safeAreaContext, x as screens, y as deviceInfo } from "./presets-CK85x8ey.mjs";
|
|
2
|
+
export { asyncStorage, bottomSheet, deviceInfo, expo, flashList, gestureHandler, keyboardController, mmkv, navigation, reanimated, safeAreaContext, screens, svg, vectorIcons, webview, worklets };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Opt-in types for React Native Testing Library's matchers under Vitest.
|
|
3
|
+
*
|
|
4
|
+
* RNTL's matchers work at runtime under this plugin, but it declares their types only
|
|
5
|
+
* for Jest — `dist/matchers/types.d.ts` augments the global `jest` namespace and the
|
|
6
|
+
* `@jest/expect` module, and neither reaches Vitest's `Assertion`. Without this,
|
|
7
|
+
* `toHaveTextContent`, `toHaveStyle`, `toBeVisible` and the rest are
|
|
8
|
+
* `Property 'x' does not exist on type 'Assertion<...>'` for anyone who typechecks.
|
|
9
|
+
*
|
|
10
|
+
* Reference it once, anywhere in the project:
|
|
11
|
+
*
|
|
12
|
+
* /// <reference types="vitest-native/rntl-matchers" />
|
|
13
|
+
*
|
|
14
|
+
* or add "vitest-native/rntl-matchers" to `compilerOptions.types` in tsconfig.json.
|
|
15
|
+
*
|
|
16
|
+
* SEPARATE, rather than folded into the package's main types, because
|
|
17
|
+
* @testing-library/react-native is an OPTIONAL peer. An unresolvable type import
|
|
18
|
+
* inside a shipped .d.ts is invisible under `skipLibCheck: true` — React Native's own
|
|
19
|
+
* tsconfig default — but reports TS2307 under `skipLibCheck: false`, which would break
|
|
20
|
+
* projects that use the mock engine without RNTL. Measured both ways before choosing
|
|
21
|
+
* this shape. @testing-library/jest-dom ships its `/vitest` entry for the same reason.
|
|
22
|
+
*
|
|
23
|
+
* The import is a deep path because RNTL does not re-export the interface from its
|
|
24
|
+
* entry point. It has no `exports` map, so the path resolves; if a future RNTL moves
|
|
25
|
+
* it, this file fails loudly at the reference site rather than silently dropping the
|
|
26
|
+
* matchers.
|
|
27
|
+
*/
|
|
28
|
+
import type { JestNativeMatchers } from "@testing-library/react-native/dist/matchers/types";
|
|
29
|
+
|
|
30
|
+
declare module "vitest" {
|
|
31
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
32
|
+
interface Assertion<T = any> extends JestNativeMatchers<T> {}
|
|
33
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
34
|
+
interface AsymmetricMatchersContaining extends JestNativeMatchers<void> {}
|
|
35
|
+
}
|
package/dist/serializer.cjs
CHANGED
|
@@ -45,6 +45,37 @@ function getTypeName(type) {
|
|
|
45
45
|
return "Unknown";
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
48
|
+
* JSON-ish rendering of a prop value, for the cases `JSON.stringify` gets wrong here.
|
|
49
|
+
*
|
|
50
|
+
* - Cycles print as `"[Circular]"` instead of throwing. A prop holding a navigation
|
|
51
|
+
* object, a store, or anything with a parent back-reference made the serializer
|
|
52
|
+
* raise `Converting circular structure to JSON`, which fails the test with a
|
|
53
|
+
* TypeError instead of producing a snapshot.
|
|
54
|
+
* - Object keys are sorted, so two structurally equal props serialize identically.
|
|
55
|
+
* Unsorted, `{ a: 1, b: 2 }` and `{ b: 2, a: 1 }` produced different snapshots and
|
|
56
|
+
* churned on a rewrite that changed nothing. Prop KEYS were already sorted below;
|
|
57
|
+
* this extends the same rule inside values. Arrays keep their order, which is
|
|
58
|
+
* meaningful.
|
|
59
|
+
* - Functions and `undefined` are rendered rather than dropped. `JSON.stringify`
|
|
60
|
+
* silently removes them, so `{ onPress: fn }` printed as `{}` — an empty object
|
|
61
|
+
* that reads like missing data.
|
|
62
|
+
*/
|
|
63
|
+
function stableStringify(value, seen = /* @__PURE__ */ new Set()) {
|
|
64
|
+
if (value === null) return "null";
|
|
65
|
+
if (typeof value === "function") return `"[Function ${value.name || "anonymous"}]"`;
|
|
66
|
+
if (typeof value === "undefined") return `"[undefined]"`;
|
|
67
|
+
if (typeof value !== "object") return JSON.stringify(value) ?? "null";
|
|
68
|
+
const obj = value;
|
|
69
|
+
if (seen.has(obj)) return `"[Circular]"`;
|
|
70
|
+
seen.add(obj);
|
|
71
|
+
try {
|
|
72
|
+
if (Array.isArray(obj)) return `[${obj.map((entry) => stableStringify(entry, seen)).join(",")}]`;
|
|
73
|
+
return `{${Object.keys(obj).sort().map((key) => `${JSON.stringify(key)}:${stableStringify(obj[key], seen)}`).join(",")}}`;
|
|
74
|
+
} finally {
|
|
75
|
+
seen.delete(obj);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
48
79
|
* Format a single prop value for snapshot display.
|
|
49
80
|
*/
|
|
50
81
|
function formatPropValue(value) {
|
|
@@ -53,8 +84,7 @@ function formatPropValue(value) {
|
|
|
53
84
|
if (typeof value === "function") return `{[Function ${value.name || "anonymous"}]}`;
|
|
54
85
|
if (value === null) return "{null}";
|
|
55
86
|
if (value === void 0) return "{undefined}";
|
|
56
|
-
if (Array.isArray(value)) return `{${
|
|
57
|
-
if (typeof value === "object") return `{${JSON.stringify(value)}}`;
|
|
87
|
+
if (Array.isArray(value) || typeof value === "object") return `{${stableStringify(value)}}`;
|
|
58
88
|
return `{${String(value)}}`;
|
|
59
89
|
}
|
|
60
90
|
/**
|
|
@@ -108,7 +138,7 @@ const serializer = {
|
|
|
108
138
|
if (typeof child === "string") result += `\n${nextIndentation}${child}`;
|
|
109
139
|
else if (typeof child === "number") result += `\n${nextIndentation}${String(child)}`;
|
|
110
140
|
else if (isReactTestInstance(child)) result += "\n" + printer(child, config, nextIndentation, depth + 1, refs);
|
|
111
|
-
else result += "\n" +
|
|
141
|
+
else result += "\n" + printer(child, config, nextIndentation, depth + 1, refs);
|
|
112
142
|
}
|
|
113
143
|
result += `\n${indentation}</${typeName}>`;
|
|
114
144
|
return result;
|
package/dist/serializer.mjs
CHANGED
|
@@ -44,6 +44,37 @@ function getTypeName(type) {
|
|
|
44
44
|
return "Unknown";
|
|
45
45
|
}
|
|
46
46
|
/**
|
|
47
|
+
* JSON-ish rendering of a prop value, for the cases `JSON.stringify` gets wrong here.
|
|
48
|
+
*
|
|
49
|
+
* - Cycles print as `"[Circular]"` instead of throwing. A prop holding a navigation
|
|
50
|
+
* object, a store, or anything with a parent back-reference made the serializer
|
|
51
|
+
* raise `Converting circular structure to JSON`, which fails the test with a
|
|
52
|
+
* TypeError instead of producing a snapshot.
|
|
53
|
+
* - Object keys are sorted, so two structurally equal props serialize identically.
|
|
54
|
+
* Unsorted, `{ a: 1, b: 2 }` and `{ b: 2, a: 1 }` produced different snapshots and
|
|
55
|
+
* churned on a rewrite that changed nothing. Prop KEYS were already sorted below;
|
|
56
|
+
* this extends the same rule inside values. Arrays keep their order, which is
|
|
57
|
+
* meaningful.
|
|
58
|
+
* - Functions and `undefined` are rendered rather than dropped. `JSON.stringify`
|
|
59
|
+
* silently removes them, so `{ onPress: fn }` printed as `{}` — an empty object
|
|
60
|
+
* that reads like missing data.
|
|
61
|
+
*/
|
|
62
|
+
function stableStringify(value, seen = /* @__PURE__ */ new Set()) {
|
|
63
|
+
if (value === null) return "null";
|
|
64
|
+
if (typeof value === "function") return `"[Function ${value.name || "anonymous"}]"`;
|
|
65
|
+
if (typeof value === "undefined") return `"[undefined]"`;
|
|
66
|
+
if (typeof value !== "object") return JSON.stringify(value) ?? "null";
|
|
67
|
+
const obj = value;
|
|
68
|
+
if (seen.has(obj)) return `"[Circular]"`;
|
|
69
|
+
seen.add(obj);
|
|
70
|
+
try {
|
|
71
|
+
if (Array.isArray(obj)) return `[${obj.map((entry) => stableStringify(entry, seen)).join(",")}]`;
|
|
72
|
+
return `{${Object.keys(obj).sort().map((key) => `${JSON.stringify(key)}:${stableStringify(obj[key], seen)}`).join(",")}}`;
|
|
73
|
+
} finally {
|
|
74
|
+
seen.delete(obj);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
47
78
|
* Format a single prop value for snapshot display.
|
|
48
79
|
*/
|
|
49
80
|
function formatPropValue(value) {
|
|
@@ -52,8 +83,7 @@ function formatPropValue(value) {
|
|
|
52
83
|
if (typeof value === "function") return `{[Function ${value.name || "anonymous"}]}`;
|
|
53
84
|
if (value === null) return "{null}";
|
|
54
85
|
if (value === void 0) return "{undefined}";
|
|
55
|
-
if (Array.isArray(value)) return `{${
|
|
56
|
-
if (typeof value === "object") return `{${JSON.stringify(value)}}`;
|
|
86
|
+
if (Array.isArray(value) || typeof value === "object") return `{${stableStringify(value)}}`;
|
|
57
87
|
return `{${String(value)}}`;
|
|
58
88
|
}
|
|
59
89
|
/**
|
|
@@ -107,7 +137,7 @@ const serializer = {
|
|
|
107
137
|
if (typeof child === "string") result += `\n${nextIndentation}${child}`;
|
|
108
138
|
else if (typeof child === "number") result += `\n${nextIndentation}${String(child)}`;
|
|
109
139
|
else if (isReactTestInstance(child)) result += "\n" + printer(child, config, nextIndentation, depth + 1, refs);
|
|
110
|
-
else result += "\n" +
|
|
140
|
+
else result += "\n" + printer(child, config, nextIndentation, depth + 1, refs);
|
|
111
141
|
}
|
|
112
142
|
result += `\n${indentation}</${typeName}>`;
|
|
113
143
|
return result;
|