vitest-native 0.9.0 → 0.11.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 +921 -0
- package/README.md +33 -1
- package/dist/cli.cjs +185 -31
- package/dist/cli.mjs +182 -28
- package/dist/ecosystem-BJzJU3Cf.cjs +568 -0
- package/dist/ecosystem-C4qT_vl3.mjs +506 -0
- package/dist/errors-B3lJK46O.cjs +75 -0
- package/dist/errors-CxoBUfVJ.mjs +64 -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-CEgRDdhd.d.cts → index-CrMeE8rd.d.mts} +14 -9
- package/dist/{index-j-0tueBr.d.mts → index-DIMbjH8R.d.cts} +15 -7
- package/dist/index.d.mts +8 -7
- package/dist/index.mjs +307 -91
- package/dist/jest-compat/interop.mjs +15 -0
- package/dist/jest-compat/setup.mjs +102 -7
- package/dist/jest-compat.cjs +4 -4
- package/dist/jest-compat.d.cts +0 -1
- package/dist/jest-compat.d.mts +0 -1
- package/dist/jest-compat.mjs +2 -2
- package/dist/matchers.cjs +16 -7
- package/dist/matchers.mjs +16 -7
- package/dist/native/hooks.mjs +152 -13
- package/dist/native/loader.mjs +36 -11
- package/dist/native/match.d.mts +33 -0
- package/dist/native/match.mjs +94 -22
- package/dist/native/module-reset.mjs +63 -0
- package/dist/native/registry.mjs +110 -13
- package/dist/native/resolve.d.mts +22 -0
- package/dist/native/resolve.mjs +21 -13
- package/dist/native/runner.mjs +21 -0
- package/dist/native/setup.mjs +4 -2
- package/dist/native/transform.mjs +108 -3
- package/dist/native/worker.mjs +59 -16
- package/dist/{pool-DzsEo9vv.cjs → pool-BU-1ecIF.cjs} +7 -6
- package/dist/{pool-CJmjRgsB.mjs → pool-Bcxn9a3I.mjs} +4 -3
- package/dist/{preset-map-CG4FMtsl.cjs → preset-map-BoG19dLa.cjs} +1 -1
- package/dist/{preset-map-CNsZKfvu.mjs → preset-map-DuX0ocdn.mjs} +1 -1
- package/dist/{presets-C4faM3ds.cjs → presets-CwO_c4aL.cjs} +224 -55
- package/dist/{presets-CuDrNA_W.mjs → presets-IStcJEOa.mjs} +216 -53
- package/dist/presets.d.mts +2 -2
- package/dist/presets.mjs +2 -2
- package/dist/rntl-matchers.d.ts +35 -0
- package/dist/{chunk-CjcI7cDX.mjs → rolldown-runtime-BhDjJH2R.mjs} +1 -1
- package/dist/{chunk-CZWwpsFl.cjs → rolldown-runtime-C0BPl7ul.cjs} +1 -1
- package/dist/serializer.cjs +34 -4
- package/dist/serializer.mjs +34 -4
- package/dist/setup.d.mts +1 -1
- package/dist/setup.mjs +237 -74
- package/docs/release-readiness.md +22 -5
- package/docs/versioning.md +133 -0
- package/package.json +38 -46
- package/dist/ecosystem-BIWaVwYL.cjs +0 -294
- package/dist/ecosystem-EFtHnKS9.mjs +0 -256
- package/dist/index.cjs +0 -788
- package/dist/index.d.cts +0 -14
- package/dist/presets.cjs +0 -18
- package/dist/presets.d.cts +0 -2
- package/dist/setup.cjs +0 -2702
- package/dist/setup.d.cts +0 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { t as __exportAll } from "./
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-BhDjJH2R.mjs";
|
|
2
|
+
import { t as VitestNativeError } from "./errors-CxoBUfVJ.mjs";
|
|
2
3
|
import { createRequire } from "node:module";
|
|
3
4
|
import path from "node:path";
|
|
4
5
|
import { vi } from "vitest";
|
|
@@ -14,7 +15,8 @@ let _rnCache = null;
|
|
|
14
15
|
function getRN() {
|
|
15
16
|
if (_rnCache) return _rnCache;
|
|
16
17
|
try {
|
|
17
|
-
|
|
18
|
+
const base = path.join(process.env.VITEST_NATIVE_PROJECT_ROOT || process.cwd(), "package.json");
|
|
19
|
+
_rnCache = createRequire(base)("react-native");
|
|
18
20
|
} catch {
|
|
19
21
|
_rnCache = {};
|
|
20
22
|
}
|
|
@@ -47,11 +49,6 @@ function reanimated() {
|
|
|
47
49
|
"addWhitelistedUIProps",
|
|
48
50
|
"addWhitelistedNativeProps",
|
|
49
51
|
"configureProps",
|
|
50
|
-
"View",
|
|
51
|
-
"Text",
|
|
52
|
-
"Image",
|
|
53
|
-
"ScrollView",
|
|
54
|
-
"FlatList",
|
|
55
52
|
"Easing",
|
|
56
53
|
"FadeIn",
|
|
57
54
|
"FadeOut",
|
|
@@ -231,7 +228,7 @@ function reanimated() {
|
|
|
231
228
|
function makeAnimatedHost(name) {
|
|
232
229
|
const Comp = React.forwardRef((props, ref) => {
|
|
233
230
|
const Base = getRN()[name];
|
|
234
|
-
if (!Base) throw new
|
|
231
|
+
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
232
|
return React.createElement(Base, {
|
|
236
233
|
...props,
|
|
237
234
|
ref
|
|
@@ -278,11 +275,6 @@ function reanimated() {
|
|
|
278
275
|
addWhitelistedUIProps,
|
|
279
276
|
addWhitelistedNativeProps,
|
|
280
277
|
configureProps,
|
|
281
|
-
View,
|
|
282
|
-
Text,
|
|
283
|
-
Image,
|
|
284
|
-
ScrollView,
|
|
285
|
-
FlatList,
|
|
286
278
|
useSharedValue,
|
|
287
279
|
useAnimatedStyle,
|
|
288
280
|
useAnimatedProps,
|
|
@@ -642,10 +634,7 @@ function safeAreaContext() {
|
|
|
642
634
|
"useSafeAreaFrame",
|
|
643
635
|
"withSafeAreaInsets",
|
|
644
636
|
"initialWindowMetrics",
|
|
645
|
-
"initialWindowSafeAreaInsets"
|
|
646
|
-
"EdgeInsets",
|
|
647
|
-
"Rect",
|
|
648
|
-
"Metrics"
|
|
637
|
+
"initialWindowSafeAreaInsets"
|
|
649
638
|
],
|
|
650
639
|
factory: () => {
|
|
651
640
|
const defaultInsets = {
|
|
@@ -1263,12 +1252,29 @@ function screens() {
|
|
|
1263
1252
|
"screensEnabled",
|
|
1264
1253
|
"enableFreeze",
|
|
1265
1254
|
"freezeEnabled",
|
|
1255
|
+
"featureFlags",
|
|
1256
|
+
"compatibilityFlags",
|
|
1257
|
+
"executeNativeBackPress",
|
|
1258
|
+
"isSearchBarAvailableForCurrentPlatform",
|
|
1259
|
+
"useTransitionProgress",
|
|
1266
1260
|
"Screen",
|
|
1261
|
+
"InnerScreen",
|
|
1267
1262
|
"ScreenContainer",
|
|
1263
|
+
"ScreenContentWrapper",
|
|
1264
|
+
"ScreenContext",
|
|
1265
|
+
"ScreenFooter",
|
|
1268
1266
|
"ScreenStack",
|
|
1267
|
+
"ScreenStackItem",
|
|
1269
1268
|
"ScreenStackHeaderConfig",
|
|
1269
|
+
"ScreenStackHeaderBackButtonImage",
|
|
1270
|
+
"ScreenStackHeaderCenterView",
|
|
1271
|
+
"ScreenStackHeaderLeftView",
|
|
1272
|
+
"ScreenStackHeaderRightView",
|
|
1273
|
+
"ScreenStackHeaderSearchBarView",
|
|
1274
|
+
"ScreenStackHeaderSubview",
|
|
1270
1275
|
"SearchBar",
|
|
1271
1276
|
"FullWindowOverlay",
|
|
1277
|
+
"Tabs",
|
|
1272
1278
|
"NativeScreen",
|
|
1273
1279
|
"NativeScreenContainer"
|
|
1274
1280
|
],
|
|
@@ -1299,6 +1305,24 @@ function screens() {
|
|
|
1299
1305
|
const FullWindowOverlay = createScreenComponent("FullWindowOverlay");
|
|
1300
1306
|
const NativeScreen = createScreenComponent("NativeScreen");
|
|
1301
1307
|
const NativeScreenContainer = createScreenComponent("NativeScreenContainer");
|
|
1308
|
+
const InnerScreen = createScreenComponent("InnerScreen");
|
|
1309
|
+
const ScreenContentWrapper = createScreenComponent("ScreenContentWrapper");
|
|
1310
|
+
const ScreenFooter = createScreenComponent("ScreenFooter");
|
|
1311
|
+
const ScreenStackItem = createScreenComponent("ScreenStackItem");
|
|
1312
|
+
const ScreenStackHeaderBackButtonImage = createScreenComponent("ScreenStackHeaderBackButtonImage");
|
|
1313
|
+
const ScreenStackHeaderCenterView = createScreenComponent("ScreenStackHeaderCenterView");
|
|
1314
|
+
const ScreenStackHeaderLeftView = createScreenComponent("ScreenStackHeaderLeftView");
|
|
1315
|
+
const ScreenStackHeaderRightView = createScreenComponent("ScreenStackHeaderRightView");
|
|
1316
|
+
const ScreenStackHeaderSearchBarView = createScreenComponent("ScreenStackHeaderSearchBarView");
|
|
1317
|
+
const ScreenStackHeaderSubview = createScreenComponent("ScreenStackHeaderSubview");
|
|
1318
|
+
const Tabs = createScreenComponent("Tabs");
|
|
1319
|
+
const ScreenContext = React.createContext(Screen);
|
|
1320
|
+
const useTransitionProgress = vi.fn(() => ({
|
|
1321
|
+
progress: 1,
|
|
1322
|
+
closing: 0,
|
|
1323
|
+
goingForward: 0
|
|
1324
|
+
}));
|
|
1325
|
+
const executeNativeBackPress = vi.fn(() => true);
|
|
1302
1326
|
return {
|
|
1303
1327
|
default: {
|
|
1304
1328
|
Screen,
|
|
@@ -1317,7 +1341,27 @@ function screens() {
|
|
|
1317
1341
|
SearchBar,
|
|
1318
1342
|
FullWindowOverlay,
|
|
1319
1343
|
NativeScreen,
|
|
1320
|
-
NativeScreenContainer
|
|
1344
|
+
NativeScreenContainer,
|
|
1345
|
+
InnerScreen,
|
|
1346
|
+
ScreenContentWrapper,
|
|
1347
|
+
ScreenContext,
|
|
1348
|
+
ScreenFooter,
|
|
1349
|
+
ScreenStackItem,
|
|
1350
|
+
ScreenStackHeaderBackButtonImage,
|
|
1351
|
+
ScreenStackHeaderCenterView,
|
|
1352
|
+
ScreenStackHeaderLeftView,
|
|
1353
|
+
ScreenStackHeaderRightView,
|
|
1354
|
+
ScreenStackHeaderSearchBarView,
|
|
1355
|
+
ScreenStackHeaderSubview,
|
|
1356
|
+
Tabs,
|
|
1357
|
+
useTransitionProgress,
|
|
1358
|
+
executeNativeBackPress,
|
|
1359
|
+
isSearchBarAvailableForCurrentPlatform: true,
|
|
1360
|
+
featureFlags: {
|
|
1361
|
+
experiment: {},
|
|
1362
|
+
flags: {}
|
|
1363
|
+
},
|
|
1364
|
+
compatibilityFlags: {}
|
|
1321
1365
|
};
|
|
1322
1366
|
}
|
|
1323
1367
|
} }
|
|
@@ -1331,42 +1375,44 @@ function expo() {
|
|
|
1331
1375
|
modules: {
|
|
1332
1376
|
"expo-constants": {
|
|
1333
1377
|
exports: [
|
|
1334
|
-
"
|
|
1335
|
-
"
|
|
1336
|
-
"
|
|
1337
|
-
"isDevice",
|
|
1338
|
-
"platform",
|
|
1339
|
-
"manifest",
|
|
1340
|
-
"manifest2",
|
|
1341
|
-
"expoGoConfig",
|
|
1342
|
-
"easConfig",
|
|
1343
|
-
"experienceUrl",
|
|
1344
|
-
"linkingUri",
|
|
1345
|
-
"getWebViewUserAgentAsync"
|
|
1378
|
+
"AppOwnership",
|
|
1379
|
+
"ExecutionEnvironment",
|
|
1380
|
+
"UserInterfaceIdiom"
|
|
1346
1381
|
],
|
|
1347
1382
|
factory: () => {
|
|
1348
|
-
const Constants = {
|
|
1349
|
-
expoConfig: {
|
|
1350
|
-
name: "test-app",
|
|
1351
|
-
slug: "test-app",
|
|
1352
|
-
version: "1.0.0",
|
|
1353
|
-
extra: {}
|
|
1354
|
-
},
|
|
1355
|
-
executionEnvironment: "storeClient",
|
|
1356
|
-
appOwnership: "standalone",
|
|
1357
|
-
isDevice: true,
|
|
1358
|
-
platform: {},
|
|
1359
|
-
manifest: null,
|
|
1360
|
-
manifest2: null,
|
|
1361
|
-
expoGoConfig: null,
|
|
1362
|
-
easConfig: null,
|
|
1363
|
-
experienceUrl: "",
|
|
1364
|
-
linkingUri: "",
|
|
1365
|
-
getWebViewUserAgentAsync: vi.fn(async () => "test-user-agent")
|
|
1366
|
-
};
|
|
1367
1383
|
return {
|
|
1368
|
-
default:
|
|
1369
|
-
|
|
1384
|
+
default: {
|
|
1385
|
+
expoConfig: {
|
|
1386
|
+
name: "test-app",
|
|
1387
|
+
slug: "test-app",
|
|
1388
|
+
version: "1.0.0",
|
|
1389
|
+
extra: {}
|
|
1390
|
+
},
|
|
1391
|
+
executionEnvironment: "storeClient",
|
|
1392
|
+
appOwnership: "standalone",
|
|
1393
|
+
isDevice: true,
|
|
1394
|
+
platform: {},
|
|
1395
|
+
manifest: null,
|
|
1396
|
+
manifest2: null,
|
|
1397
|
+
expoGoConfig: null,
|
|
1398
|
+
easConfig: null,
|
|
1399
|
+
experienceUrl: "",
|
|
1400
|
+
linkingUri: "",
|
|
1401
|
+
getWebViewUserAgentAsync: vi.fn(async () => "test-user-agent")
|
|
1402
|
+
},
|
|
1403
|
+
AppOwnership: { Expo: "expo" },
|
|
1404
|
+
ExecutionEnvironment: {
|
|
1405
|
+
Bare: "bare",
|
|
1406
|
+
Standalone: "standalone",
|
|
1407
|
+
StoreClient: "storeClient"
|
|
1408
|
+
},
|
|
1409
|
+
UserInterfaceIdiom: {
|
|
1410
|
+
Handset: "handset",
|
|
1411
|
+
Tablet: "tablet",
|
|
1412
|
+
Desktop: "desktop",
|
|
1413
|
+
TV: "tv",
|
|
1414
|
+
Unsupported: "unsupported"
|
|
1415
|
+
}
|
|
1370
1416
|
};
|
|
1371
1417
|
}
|
|
1372
1418
|
},
|
|
@@ -1665,6 +1711,123 @@ function mmkv() {
|
|
|
1665
1711
|
};
|
|
1666
1712
|
}
|
|
1667
1713
|
//#endregion
|
|
1714
|
+
//#region src/presets/netinfo.ts
|
|
1715
|
+
/**
|
|
1716
|
+
* The state every fetch/listener resolves to until a test changes it.
|
|
1717
|
+
*
|
|
1718
|
+
* Derived from ONE constant so `_reset()` and the initial value cannot drift — the
|
|
1719
|
+
* failure mode where `beforeEach(_reset())` masks the default it claims to test.
|
|
1720
|
+
*
|
|
1721
|
+
* The real library starts at `{ type: 'unknown', isConnected: null, … }` and resolves
|
|
1722
|
+
* to the device's actual connection a moment later. A mock has no device, and a null
|
|
1723
|
+
* resting state would send every component under test down its offline branch, so the
|
|
1724
|
+
* resting state here is a connected wifi device — the same reasoning that gives
|
|
1725
|
+
* Dimensions a device-shaped default.
|
|
1726
|
+
*/
|
|
1727
|
+
const RESTING = {
|
|
1728
|
+
type: "wifi",
|
|
1729
|
+
isConnected: true,
|
|
1730
|
+
isInternetReachable: true,
|
|
1731
|
+
details: {
|
|
1732
|
+
isConnectionExpensive: false,
|
|
1733
|
+
ssid: null,
|
|
1734
|
+
bssid: null,
|
|
1735
|
+
strength: null,
|
|
1736
|
+
ipAddress: null,
|
|
1737
|
+
subnet: null,
|
|
1738
|
+
frequency: null,
|
|
1739
|
+
linkSpeed: null,
|
|
1740
|
+
rxLinkSpeed: null,
|
|
1741
|
+
txLinkSpeed: null
|
|
1742
|
+
}
|
|
1743
|
+
};
|
|
1744
|
+
const state = () => structuredClone(RESTING);
|
|
1745
|
+
function netInfo() {
|
|
1746
|
+
return {
|
|
1747
|
+
name: "netInfo",
|
|
1748
|
+
modules: { "@react-native-community/netinfo": {
|
|
1749
|
+
exports: [
|
|
1750
|
+
"configure",
|
|
1751
|
+
"fetch",
|
|
1752
|
+
"refresh",
|
|
1753
|
+
"addEventListener",
|
|
1754
|
+
"useNetInfo",
|
|
1755
|
+
"useNetInfoInstance",
|
|
1756
|
+
"NetInfoStateType",
|
|
1757
|
+
"NetInfoCellularGeneration"
|
|
1758
|
+
],
|
|
1759
|
+
factory: () => {
|
|
1760
|
+
let current = state();
|
|
1761
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
1762
|
+
const emit = () => {
|
|
1763
|
+
for (const listener of listeners) listener(current);
|
|
1764
|
+
};
|
|
1765
|
+
const fetch = vi.fn(async () => current);
|
|
1766
|
+
const refresh = vi.fn(async () => current);
|
|
1767
|
+
const configure = vi.fn(() => {
|
|
1768
|
+
listeners.clear();
|
|
1769
|
+
});
|
|
1770
|
+
const addEventListener = vi.fn((listener) => {
|
|
1771
|
+
listeners.add(listener);
|
|
1772
|
+
listener(current);
|
|
1773
|
+
return () => {
|
|
1774
|
+
listeners.delete(listener);
|
|
1775
|
+
};
|
|
1776
|
+
});
|
|
1777
|
+
const useNetInfo = vi.fn(() => current);
|
|
1778
|
+
const useNetInfoInstance = vi.fn(() => ({
|
|
1779
|
+
netInfo: current,
|
|
1780
|
+
refresh
|
|
1781
|
+
}));
|
|
1782
|
+
const NetInfoStateType = {
|
|
1783
|
+
unknown: "unknown",
|
|
1784
|
+
none: "none",
|
|
1785
|
+
cellular: "cellular",
|
|
1786
|
+
wifi: "wifi",
|
|
1787
|
+
bluetooth: "bluetooth",
|
|
1788
|
+
ethernet: "ethernet",
|
|
1789
|
+
wimax: "wimax",
|
|
1790
|
+
vpn: "vpn",
|
|
1791
|
+
other: "other"
|
|
1792
|
+
};
|
|
1793
|
+
const NetInfoCellularGeneration = {
|
|
1794
|
+
"2g": "2g",
|
|
1795
|
+
"3g": "3g",
|
|
1796
|
+
"4g": "4g",
|
|
1797
|
+
"5g": "5g"
|
|
1798
|
+
};
|
|
1799
|
+
const api = {
|
|
1800
|
+
configure,
|
|
1801
|
+
fetch,
|
|
1802
|
+
refresh,
|
|
1803
|
+
addEventListener,
|
|
1804
|
+
useNetInfo,
|
|
1805
|
+
useNetInfoInstance
|
|
1806
|
+
};
|
|
1807
|
+
return {
|
|
1808
|
+
...api,
|
|
1809
|
+
NetInfoStateType,
|
|
1810
|
+
NetInfoCellularGeneration,
|
|
1811
|
+
default: api,
|
|
1812
|
+
/** Drive the connection state from a test. */
|
|
1813
|
+
_setState: (next) => {
|
|
1814
|
+
current = {
|
|
1815
|
+
...current,
|
|
1816
|
+
...next
|
|
1817
|
+
};
|
|
1818
|
+
emit();
|
|
1819
|
+
},
|
|
1820
|
+
/** Internal: restore the resting state. Called by resetAllMocks(). */
|
|
1821
|
+
_reset: () => {
|
|
1822
|
+
current = state();
|
|
1823
|
+
listeners.clear();
|
|
1824
|
+
}
|
|
1825
|
+
};
|
|
1826
|
+
}
|
|
1827
|
+
} }
|
|
1828
|
+
};
|
|
1829
|
+
}
|
|
1830
|
+
//#endregion
|
|
1668
1831
|
//#region src/presets/svg.ts
|
|
1669
1832
|
const SVG_COMPONENTS = [
|
|
1670
1833
|
"Svg",
|
|
@@ -1828,7 +1991,6 @@ function flashList() {
|
|
|
1828
1991
|
"FlashList",
|
|
1829
1992
|
"AnimatedFlashList",
|
|
1830
1993
|
"LayoutCommitObserver",
|
|
1831
|
-
"ViewToken",
|
|
1832
1994
|
"RenderTargetOptions",
|
|
1833
1995
|
"useRecyclingState",
|
|
1834
1996
|
"useLayoutState",
|
|
@@ -2565,6 +2727,7 @@ var presets_exports = /* @__PURE__ */ __exportAll({
|
|
|
2565
2727
|
keyboardController: () => keyboardController,
|
|
2566
2728
|
mmkv: () => mmkv,
|
|
2567
2729
|
navigation: () => navigation,
|
|
2730
|
+
netInfo: () => netInfo,
|
|
2568
2731
|
reanimated: () => reanimated,
|
|
2569
2732
|
safeAreaContext: () => safeAreaContext,
|
|
2570
2733
|
screens: () => screens,
|
|
@@ -2574,4 +2737,4 @@ var presets_exports = /* @__PURE__ */ __exportAll({
|
|
|
2574
2737
|
worklets: () => worklets
|
|
2575
2738
|
});
|
|
2576
2739
|
//#endregion
|
|
2577
|
-
export {
|
|
2740
|
+
export { asyncStorage as C, createPressableMock as D, gestureHandler as E, buildPressableHostProps as O, screens as S, safeAreaContext as T, svg as _, bottomSheet as a, deviceInfo as b, createTouchableOpacityMock as c, createFlatListMock as d, createScrollViewMock as f, webview as g, vectorIcons as h, createViewMock as i, reanimated as k, 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, netInfo as v, navigation as w, expo as x, mmkv as y };
|
package/dist/presets.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as
|
|
2
|
-
export { asyncStorage, bottomSheet, deviceInfo, expo, flashList, gestureHandler, keyboardController, mmkv, navigation, reanimated, safeAreaContext, screens, svg, vectorIcons, webview, worklets };
|
|
1
|
+
import { _ as gestureHandler, a as flashList, c as svg, d as deviceInfo, f as expo, g as safeAreaContext, h as navigation, i as bottomSheet, l as netInfo, m as asyncStorage, n as worklets, o as vectorIcons, p as screens, r as keyboardController, s as webview, u as mmkv, v as reanimated } from "./index-CrMeE8rd.mjs";
|
|
2
|
+
export { asyncStorage, bottomSheet, deviceInfo, expo, flashList, gestureHandler, keyboardController, mmkv, navigation, netInfo, 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, worklets };
|
|
1
|
+
import { C as asyncStorage, E as gestureHandler, S as screens, T as safeAreaContext, _ as svg, a as bottomSheet, b as deviceInfo, g as webview, h as vectorIcons, k as reanimated, m as flashList, n as worklets, r as keyboardController, v as netInfo, w as navigation, x as expo, y as mmkv } from "./presets-IStcJEOa.mjs";
|
|
2
|
+
export { asyncStorage, bottomSheet, deviceInfo, expo, flashList, gestureHandler, keyboardController, mmkv, navigation, netInfo, 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
|
+
}
|
|
@@ -10,6 +10,6 @@ var __exportAll = (all, no_symbols) => {
|
|
|
10
10
|
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
11
11
|
return target;
|
|
12
12
|
};
|
|
13
|
-
var __require = /*
|
|
13
|
+
var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
|
|
14
14
|
//#endregion
|
|
15
15
|
export { __require as n, __exportAll as t };
|
|
@@ -24,7 +24,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
24
24
|
}
|
|
25
25
|
return to;
|
|
26
26
|
};
|
|
27
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
27
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
28
28
|
value: mod,
|
|
29
29
|
enumerable: true
|
|
30
30
|
}) : target, mod));
|
package/dist/serializer.cjs
CHANGED
|
@@ -9,7 +9,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
9
9
|
* Usage: expect.addSnapshotSerializer(serializer)
|
|
10
10
|
*/
|
|
11
11
|
/** Props that are React internals and should be omitted from snapshot output. */
|
|
12
|
-
const INTERNAL_PROPS = new Set([
|
|
12
|
+
const INTERNAL_PROPS = /* @__PURE__ */ new Set([
|
|
13
13
|
"__reactFiber",
|
|
14
14
|
"__reactInternalInstance",
|
|
15
15
|
"__reactEvents",
|
|
@@ -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
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* Usage: expect.addSnapshotSerializer(serializer)
|
|
9
9
|
*/
|
|
10
10
|
/** Props that are React internals and should be omitted from snapshot output. */
|
|
11
|
-
const INTERNAL_PROPS = new Set([
|
|
11
|
+
const INTERNAL_PROPS = /* @__PURE__ */ new Set([
|
|
12
12
|
"__reactFiber",
|
|
13
13
|
"__reactInternalInstance",
|
|
14
14
|
"__reactEvents",
|
|
@@ -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;
|
package/dist/setup.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export {}
|