vitest-native 0.4.1 → 0.6.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 +98 -1
- package/README.md +270 -180
- package/dist/helpers.cjs +13 -0
- package/dist/helpers.mjs +13 -0
- package/dist/{index-DEB7OFaJ.d.cts → index-DGNLmGjq.d.mts} +19 -12
- package/dist/{index-CJIhukN_.d.mts → index-Dr3WvKWI.d.cts} +21 -10
- package/dist/index.cjs +106 -39
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +103 -36
- package/dist/jest-compat.cjs +1 -1
- package/dist/native/boundary.mjs +82 -32
- package/dist/native/globals.mjs +1 -0
- package/dist/native/hooks.mjs +35 -7
- package/dist/native/loader.mjs +18 -5
- package/dist/native/reset.mjs +79 -43
- package/dist/native/resolve.mjs +25 -7
- package/dist/native/runner.mjs +13 -2
- package/dist/native/setup.mjs +95 -4
- package/dist/native/transform.mjs +15 -9
- package/dist/native/worker.mjs +20 -3
- package/dist/{pool-oPTZiSXU.mjs → pool-B7LBfcMQ.mjs} +10 -1
- package/dist/{pool-B4mWN3N5.cjs → pool-p54QV1dQ.cjs} +11 -2
- package/dist/{preset-map-OJm5IWuL.mjs → preset-map-C1UwEald.mjs} +3 -1
- package/dist/{preset-map-C3jxnkiX.cjs → preset-map-CNBOeqAu.cjs} +3 -1
- package/dist/{presets-2I68Ipyl.cjs → presets-BPVVlfI2.cjs} +93 -23
- package/dist/{presets-DOGXQzYT.mjs → presets-DVLDrPC-.mjs} +86 -22
- package/dist/presets.cjs +2 -1
- package/dist/presets.d.cts +2 -2
- package/dist/presets.d.mts +2 -2
- package/dist/presets.mjs +2 -2
- package/dist/setup.cjs +71 -13
- package/dist/setup.mjs +69 -11
- package/docs/migrating-from-jest.md +6 -4
- package/docs/migrating-from-vitest-react-native.md +6 -3
- package/docs/release-readiness.md +52 -0
- package/package.json +31 -20
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-CZWwpsFl.cjs");
|
|
2
2
|
let node_path = require("node:path");
|
|
3
|
-
node_path = require_chunk.__toESM(node_path);
|
|
3
|
+
node_path = require_chunk.__toESM(node_path, 1);
|
|
4
4
|
let node_module = require("node:module");
|
|
5
5
|
let vitest = require("vitest");
|
|
6
6
|
let react = require("react");
|
|
7
|
-
react = require_chunk.__toESM(react);
|
|
7
|
+
react = require_chunk.__toESM(react, 1);
|
|
8
8
|
//#region src/presets/reanimated.ts
|
|
9
9
|
/**
|
|
10
10
|
* Resolve the *active* React Native module — the mock under `engine: 'mock'`
|
|
@@ -418,20 +418,22 @@ function buildPressableHostProps(props, ref) {
|
|
|
418
418
|
...accessibilityState,
|
|
419
419
|
...disabled ? { disabled: true } : {}
|
|
420
420
|
} : void 0;
|
|
421
|
+
const pressProps = disabled ? {} : {
|
|
422
|
+
onStartShouldSetResponder: () => true,
|
|
423
|
+
onResponderGrant: (e) => onPressIn?.(e),
|
|
424
|
+
onResponderRelease: (e) => {
|
|
425
|
+
onPress?.(e);
|
|
426
|
+
onPressOut?.(e);
|
|
427
|
+
},
|
|
428
|
+
onPress,
|
|
429
|
+
onPressIn,
|
|
430
|
+
onPressOut,
|
|
431
|
+
onLongPress
|
|
432
|
+
};
|
|
421
433
|
return {
|
|
422
434
|
accessible: true,
|
|
423
|
-
...disabled ? {} : {
|
|
424
|
-
|
|
425
|
-
onResponderGrant: (e) => onPressIn?.(e),
|
|
426
|
-
onResponderRelease: (e) => {
|
|
427
|
-
onPress?.(e);
|
|
428
|
-
onPressOut?.(e);
|
|
429
|
-
},
|
|
430
|
-
onPress,
|
|
431
|
-
onPressIn,
|
|
432
|
-
onPressOut,
|
|
433
|
-
onLongPress
|
|
434
|
-
},
|
|
435
|
+
...disabled ? { pointerEvents: "none" } : {},
|
|
436
|
+
...pressProps,
|
|
435
437
|
...rest,
|
|
436
438
|
...mergedA11yState ? { accessibilityState: mergedA11yState } : {},
|
|
437
439
|
ref
|
|
@@ -693,9 +695,11 @@ function safeAreaContext() {
|
|
|
693
695
|
EdgeInsets: vitest.vi.fn(),
|
|
694
696
|
Rect: vitest.vi.fn(),
|
|
695
697
|
Metrics: vitest.vi.fn(),
|
|
698
|
+
/** Internal: update insets. Called by setInsets() helper. */
|
|
696
699
|
_setInsets: (insets) => {
|
|
697
700
|
Object.assign(state.insets, insets);
|
|
698
701
|
},
|
|
702
|
+
/** Internal: reset insets to defaults. Called by resetAllMocks(). */
|
|
699
703
|
_reset: () => {
|
|
700
704
|
Object.assign(state.insets, defaultInsets);
|
|
701
705
|
Object.assign(state.frame, defaultFrame);
|
|
@@ -1218,6 +1222,7 @@ function asyncStorage() {
|
|
|
1218
1222
|
});
|
|
1219
1223
|
}),
|
|
1220
1224
|
flushGetRequests: vitest.vi.fn(() => {}),
|
|
1225
|
+
/** Internal: reset store between tests. Called by resetAllMocks(). */
|
|
1221
1226
|
_resetStore: () => store.clear()
|
|
1222
1227
|
};
|
|
1223
1228
|
return {
|
|
@@ -1495,18 +1500,17 @@ const NUMBERS = {
|
|
|
1495
1500
|
getApiLevel: 33
|
|
1496
1501
|
};
|
|
1497
1502
|
function deviceInfo() {
|
|
1498
|
-
const exports = [
|
|
1499
|
-
...Object.keys(STRINGS),
|
|
1500
|
-
...Object.keys(BOOLEANS),
|
|
1501
|
-
...Object.keys(NUMBERS),
|
|
1502
|
-
...Object.keys(STRINGS).map((k) => k + "Sync"),
|
|
1503
|
-
...Object.keys(BOOLEANS).map((k) => k + "Sync"),
|
|
1504
|
-
...Object.keys(NUMBERS).map((k) => k + "Sync")
|
|
1505
|
-
];
|
|
1506
1503
|
return {
|
|
1507
1504
|
name: "deviceInfo",
|
|
1508
1505
|
modules: { "react-native-device-info": {
|
|
1509
|
-
exports
|
|
1506
|
+
exports: [
|
|
1507
|
+
...Object.keys(STRINGS),
|
|
1508
|
+
...Object.keys(BOOLEANS),
|
|
1509
|
+
...Object.keys(NUMBERS),
|
|
1510
|
+
...Object.keys(STRINGS).map((k) => k + "Sync"),
|
|
1511
|
+
...Object.keys(BOOLEANS).map((k) => k + "Sync"),
|
|
1512
|
+
...Object.keys(NUMBERS).map((k) => k + "Sync")
|
|
1513
|
+
],
|
|
1510
1514
|
factory: () => {
|
|
1511
1515
|
const api = {};
|
|
1512
1516
|
for (const [k, v] of Object.entries({
|
|
@@ -1737,6 +1741,65 @@ function webview() {
|
|
|
1737
1741
|
};
|
|
1738
1742
|
}
|
|
1739
1743
|
//#endregion
|
|
1744
|
+
//#region src/presets/vector-icons.ts
|
|
1745
|
+
const DEFAULT_ICON_SIZE = 12;
|
|
1746
|
+
const DEFAULT_ICON_COLOR = "black";
|
|
1747
|
+
function vectorIcons() {
|
|
1748
|
+
return {
|
|
1749
|
+
name: "vectorIcons",
|
|
1750
|
+
modules: { "@react-native-vector-icons/common": {
|
|
1751
|
+
exports: [
|
|
1752
|
+
"createIconSet",
|
|
1753
|
+
"DEFAULT_ICON_COLOR",
|
|
1754
|
+
"DEFAULT_ICON_SIZE",
|
|
1755
|
+
"isDynamicLoadingEnabled",
|
|
1756
|
+
"isDynamicLoadingSupported",
|
|
1757
|
+
"setDynamicLoadingEnabled",
|
|
1758
|
+
"setDynamicLoadingErrorCallback"
|
|
1759
|
+
],
|
|
1760
|
+
factory: () => {
|
|
1761
|
+
const createIconSet = (_glyphMap, _options) => {
|
|
1762
|
+
const Icon = react.default.forwardRef((props, ref) => {
|
|
1763
|
+
const { size = DEFAULT_ICON_SIZE, color = DEFAULT_ICON_COLOR, style, children, ...rest } = props;
|
|
1764
|
+
return react.default.createElement("Text", {
|
|
1765
|
+
ref,
|
|
1766
|
+
selectable: false,
|
|
1767
|
+
...rest,
|
|
1768
|
+
style: [{
|
|
1769
|
+
fontSize: size,
|
|
1770
|
+
color
|
|
1771
|
+
}, style]
|
|
1772
|
+
}, children);
|
|
1773
|
+
});
|
|
1774
|
+
Icon.displayName = "Icon";
|
|
1775
|
+
Icon.getImageSource = async () => null;
|
|
1776
|
+
Icon.getImageSourceSync = () => null;
|
|
1777
|
+
Icon.getFontFamily = () => "";
|
|
1778
|
+
Icon.hasIcon = () => false;
|
|
1779
|
+
Icon.getRawGlyphMap = () => ({});
|
|
1780
|
+
Icon.loadFont = async () => {};
|
|
1781
|
+
return Icon;
|
|
1782
|
+
};
|
|
1783
|
+
const noop = () => {};
|
|
1784
|
+
return {
|
|
1785
|
+
createIconSet,
|
|
1786
|
+
DEFAULT_ICON_COLOR,
|
|
1787
|
+
DEFAULT_ICON_SIZE,
|
|
1788
|
+
isDynamicLoadingEnabled: () => false,
|
|
1789
|
+
isDynamicLoadingSupported: () => false,
|
|
1790
|
+
setDynamicLoadingEnabled: noop,
|
|
1791
|
+
setDynamicLoadingErrorCallback: noop,
|
|
1792
|
+
default: {
|
|
1793
|
+
createIconSet,
|
|
1794
|
+
DEFAULT_ICON_COLOR,
|
|
1795
|
+
DEFAULT_ICON_SIZE
|
|
1796
|
+
}
|
|
1797
|
+
};
|
|
1798
|
+
}
|
|
1799
|
+
} }
|
|
1800
|
+
};
|
|
1801
|
+
}
|
|
1802
|
+
//#endregion
|
|
1740
1803
|
//#region src/presets/index.ts
|
|
1741
1804
|
var presets_exports = /* @__PURE__ */ require_chunk.__exportAll({
|
|
1742
1805
|
asyncStorage: () => asyncStorage,
|
|
@@ -1749,6 +1812,7 @@ var presets_exports = /* @__PURE__ */ require_chunk.__exportAll({
|
|
|
1749
1812
|
safeAreaContext: () => safeAreaContext,
|
|
1750
1813
|
screens: () => screens,
|
|
1751
1814
|
svg: () => svg,
|
|
1815
|
+
vectorIcons: () => vectorIcons,
|
|
1752
1816
|
webview: () => webview
|
|
1753
1817
|
});
|
|
1754
1818
|
//#endregion
|
|
@@ -1830,6 +1894,12 @@ Object.defineProperty(exports, "svg", {
|
|
|
1830
1894
|
return svg;
|
|
1831
1895
|
}
|
|
1832
1896
|
});
|
|
1897
|
+
Object.defineProperty(exports, "vectorIcons", {
|
|
1898
|
+
enumerable: true,
|
|
1899
|
+
get: function() {
|
|
1900
|
+
return vectorIcons;
|
|
1901
|
+
}
|
|
1902
|
+
});
|
|
1833
1903
|
Object.defineProperty(exports, "webview", {
|
|
1834
1904
|
enumerable: true,
|
|
1835
1905
|
get: function() {
|
|
@@ -416,20 +416,22 @@ function buildPressableHostProps(props, ref) {
|
|
|
416
416
|
...accessibilityState,
|
|
417
417
|
...disabled ? { disabled: true } : {}
|
|
418
418
|
} : void 0;
|
|
419
|
+
const pressProps = disabled ? {} : {
|
|
420
|
+
onStartShouldSetResponder: () => true,
|
|
421
|
+
onResponderGrant: (e) => onPressIn?.(e),
|
|
422
|
+
onResponderRelease: (e) => {
|
|
423
|
+
onPress?.(e);
|
|
424
|
+
onPressOut?.(e);
|
|
425
|
+
},
|
|
426
|
+
onPress,
|
|
427
|
+
onPressIn,
|
|
428
|
+
onPressOut,
|
|
429
|
+
onLongPress
|
|
430
|
+
};
|
|
419
431
|
return {
|
|
420
432
|
accessible: true,
|
|
421
|
-
...disabled ? {} : {
|
|
422
|
-
|
|
423
|
-
onResponderGrant: (e) => onPressIn?.(e),
|
|
424
|
-
onResponderRelease: (e) => {
|
|
425
|
-
onPress?.(e);
|
|
426
|
-
onPressOut?.(e);
|
|
427
|
-
},
|
|
428
|
-
onPress,
|
|
429
|
-
onPressIn,
|
|
430
|
-
onPressOut,
|
|
431
|
-
onLongPress
|
|
432
|
-
},
|
|
433
|
+
...disabled ? { pointerEvents: "none" } : {},
|
|
434
|
+
...pressProps,
|
|
433
435
|
...rest,
|
|
434
436
|
...mergedA11yState ? { accessibilityState: mergedA11yState } : {},
|
|
435
437
|
ref
|
|
@@ -691,9 +693,11 @@ function safeAreaContext() {
|
|
|
691
693
|
EdgeInsets: vi.fn(),
|
|
692
694
|
Rect: vi.fn(),
|
|
693
695
|
Metrics: vi.fn(),
|
|
696
|
+
/** Internal: update insets. Called by setInsets() helper. */
|
|
694
697
|
_setInsets: (insets) => {
|
|
695
698
|
Object.assign(state.insets, insets);
|
|
696
699
|
},
|
|
700
|
+
/** Internal: reset insets to defaults. Called by resetAllMocks(). */
|
|
697
701
|
_reset: () => {
|
|
698
702
|
Object.assign(state.insets, defaultInsets);
|
|
699
703
|
Object.assign(state.frame, defaultFrame);
|
|
@@ -1216,6 +1220,7 @@ function asyncStorage() {
|
|
|
1216
1220
|
});
|
|
1217
1221
|
}),
|
|
1218
1222
|
flushGetRequests: vi.fn(() => {}),
|
|
1223
|
+
/** Internal: reset store between tests. Called by resetAllMocks(). */
|
|
1219
1224
|
_resetStore: () => store.clear()
|
|
1220
1225
|
};
|
|
1221
1226
|
return {
|
|
@@ -1493,18 +1498,17 @@ const NUMBERS = {
|
|
|
1493
1498
|
getApiLevel: 33
|
|
1494
1499
|
};
|
|
1495
1500
|
function deviceInfo() {
|
|
1496
|
-
const exports = [
|
|
1497
|
-
...Object.keys(STRINGS),
|
|
1498
|
-
...Object.keys(BOOLEANS),
|
|
1499
|
-
...Object.keys(NUMBERS),
|
|
1500
|
-
...Object.keys(STRINGS).map((k) => k + "Sync"),
|
|
1501
|
-
...Object.keys(BOOLEANS).map((k) => k + "Sync"),
|
|
1502
|
-
...Object.keys(NUMBERS).map((k) => k + "Sync")
|
|
1503
|
-
];
|
|
1504
1501
|
return {
|
|
1505
1502
|
name: "deviceInfo",
|
|
1506
1503
|
modules: { "react-native-device-info": {
|
|
1507
|
-
exports
|
|
1504
|
+
exports: [
|
|
1505
|
+
...Object.keys(STRINGS),
|
|
1506
|
+
...Object.keys(BOOLEANS),
|
|
1507
|
+
...Object.keys(NUMBERS),
|
|
1508
|
+
...Object.keys(STRINGS).map((k) => k + "Sync"),
|
|
1509
|
+
...Object.keys(BOOLEANS).map((k) => k + "Sync"),
|
|
1510
|
+
...Object.keys(NUMBERS).map((k) => k + "Sync")
|
|
1511
|
+
],
|
|
1508
1512
|
factory: () => {
|
|
1509
1513
|
const api = {};
|
|
1510
1514
|
for (const [k, v] of Object.entries({
|
|
@@ -1735,6 +1739,65 @@ function webview() {
|
|
|
1735
1739
|
};
|
|
1736
1740
|
}
|
|
1737
1741
|
//#endregion
|
|
1742
|
+
//#region src/presets/vector-icons.ts
|
|
1743
|
+
const DEFAULT_ICON_SIZE = 12;
|
|
1744
|
+
const DEFAULT_ICON_COLOR = "black";
|
|
1745
|
+
function vectorIcons() {
|
|
1746
|
+
return {
|
|
1747
|
+
name: "vectorIcons",
|
|
1748
|
+
modules: { "@react-native-vector-icons/common": {
|
|
1749
|
+
exports: [
|
|
1750
|
+
"createIconSet",
|
|
1751
|
+
"DEFAULT_ICON_COLOR",
|
|
1752
|
+
"DEFAULT_ICON_SIZE",
|
|
1753
|
+
"isDynamicLoadingEnabled",
|
|
1754
|
+
"isDynamicLoadingSupported",
|
|
1755
|
+
"setDynamicLoadingEnabled",
|
|
1756
|
+
"setDynamicLoadingErrorCallback"
|
|
1757
|
+
],
|
|
1758
|
+
factory: () => {
|
|
1759
|
+
const createIconSet = (_glyphMap, _options) => {
|
|
1760
|
+
const Icon = React.forwardRef((props, ref) => {
|
|
1761
|
+
const { size = DEFAULT_ICON_SIZE, color = DEFAULT_ICON_COLOR, style, children, ...rest } = props;
|
|
1762
|
+
return React.createElement("Text", {
|
|
1763
|
+
ref,
|
|
1764
|
+
selectable: false,
|
|
1765
|
+
...rest,
|
|
1766
|
+
style: [{
|
|
1767
|
+
fontSize: size,
|
|
1768
|
+
color
|
|
1769
|
+
}, style]
|
|
1770
|
+
}, children);
|
|
1771
|
+
});
|
|
1772
|
+
Icon.displayName = "Icon";
|
|
1773
|
+
Icon.getImageSource = async () => null;
|
|
1774
|
+
Icon.getImageSourceSync = () => null;
|
|
1775
|
+
Icon.getFontFamily = () => "";
|
|
1776
|
+
Icon.hasIcon = () => false;
|
|
1777
|
+
Icon.getRawGlyphMap = () => ({});
|
|
1778
|
+
Icon.loadFont = async () => {};
|
|
1779
|
+
return Icon;
|
|
1780
|
+
};
|
|
1781
|
+
const noop = () => {};
|
|
1782
|
+
return {
|
|
1783
|
+
createIconSet,
|
|
1784
|
+
DEFAULT_ICON_COLOR,
|
|
1785
|
+
DEFAULT_ICON_SIZE,
|
|
1786
|
+
isDynamicLoadingEnabled: () => false,
|
|
1787
|
+
isDynamicLoadingSupported: () => false,
|
|
1788
|
+
setDynamicLoadingEnabled: noop,
|
|
1789
|
+
setDynamicLoadingErrorCallback: noop,
|
|
1790
|
+
default: {
|
|
1791
|
+
createIconSet,
|
|
1792
|
+
DEFAULT_ICON_COLOR,
|
|
1793
|
+
DEFAULT_ICON_SIZE
|
|
1794
|
+
}
|
|
1795
|
+
};
|
|
1796
|
+
}
|
|
1797
|
+
} }
|
|
1798
|
+
};
|
|
1799
|
+
}
|
|
1800
|
+
//#endregion
|
|
1738
1801
|
//#region src/presets/index.ts
|
|
1739
1802
|
var presets_exports = /* @__PURE__ */ __exportAll({
|
|
1740
1803
|
asyncStorage: () => asyncStorage,
|
|
@@ -1747,7 +1810,8 @@ var presets_exports = /* @__PURE__ */ __exportAll({
|
|
|
1747
1810
|
safeAreaContext: () => safeAreaContext,
|
|
1748
1811
|
screens: () => screens,
|
|
1749
1812
|
svg: () => svg,
|
|
1813
|
+
vectorIcons: () => vectorIcons,
|
|
1750
1814
|
webview: () => webview
|
|
1751
1815
|
});
|
|
1752
1816
|
//#endregion
|
|
1753
|
-
export {
|
|
1817
|
+
export { mmkv as a, screens as c, safeAreaContext as d, gestureHandler as f, reanimated as h, svg as i, asyncStorage as l, buildPressableHostProps as m, vectorIcons as n, deviceInfo as o, createPressableMock as p, webview as r, expo as s, presets_exports as t, navigation as u };
|
package/dist/presets.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_presets = require("./presets-
|
|
2
|
+
const require_presets = require("./presets-BPVVlfI2.cjs");
|
|
3
3
|
exports.asyncStorage = require_presets.asyncStorage;
|
|
4
4
|
exports.deviceInfo = require_presets.deviceInfo;
|
|
5
5
|
exports.expo = require_presets.expo;
|
|
@@ -10,4 +10,5 @@ exports.reanimated = require_presets.reanimated;
|
|
|
10
10
|
exports.safeAreaContext = require_presets.safeAreaContext;
|
|
11
11
|
exports.screens = require_presets.screens;
|
|
12
12
|
exports.svg = require_presets.svg;
|
|
13
|
+
exports.vectorIcons = require_presets.vectorIcons;
|
|
13
14
|
exports.webview = require_presets.webview;
|
package/dist/presets.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
export { asyncStorage, deviceInfo, expo, gestureHandler, mmkv, navigation, reanimated, safeAreaContext, screens, svg, webview };
|
|
1
|
+
import { a as mmkv, c as screens, d as safeAreaContext, f as gestureHandler, i as svg, l as asyncStorage, n as vectorIcons, o as deviceInfo, p as reanimated, r as webview, s as expo, u as navigation } from "./index-Dr3WvKWI.cjs";
|
|
2
|
+
export { asyncStorage, deviceInfo, expo, gestureHandler, mmkv, navigation, reanimated, safeAreaContext, screens, svg, vectorIcons, webview };
|
package/dist/presets.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
export { asyncStorage, deviceInfo, expo, gestureHandler, mmkv, navigation, reanimated, safeAreaContext, screens, svg, webview };
|
|
1
|
+
import { a as mmkv, c as screens, d as safeAreaContext, f as gestureHandler, i as svg, l as asyncStorage, n as vectorIcons, o as deviceInfo, p as reanimated, r as webview, s as expo, u as navigation } from "./index-DGNLmGjq.mjs";
|
|
2
|
+
export { asyncStorage, deviceInfo, expo, gestureHandler, mmkv, navigation, reanimated, safeAreaContext, screens, svg, vectorIcons, webview };
|
package/dist/presets.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
export { asyncStorage, deviceInfo, expo, gestureHandler, mmkv, navigation, reanimated, safeAreaContext, screens, svg, webview };
|
|
1
|
+
import { a as mmkv, c as screens, d as safeAreaContext, f as gestureHandler, h as reanimated, i as svg, l as asyncStorage, n as vectorIcons, o as deviceInfo, r as webview, s as expo, u as navigation } from "./presets-DVLDrPC-.mjs";
|
|
2
|
+
export { asyncStorage, deviceInfo, expo, gestureHandler, mmkv, navigation, reanimated, safeAreaContext, screens, svg, vectorIcons, webview };
|
package/dist/setup.cjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-CZWwpsFl.cjs");
|
|
2
|
-
const require_preset_map = require("./preset-map-
|
|
3
|
-
const require_presets = require("./presets-
|
|
2
|
+
const require_preset_map = require("./preset-map-CNBOeqAu.cjs");
|
|
3
|
+
const require_presets = require("./presets-BPVVlfI2.cjs");
|
|
4
4
|
const require_serializer = require("./serializer.cjs");
|
|
5
5
|
const require_matchers = require("./matchers.cjs");
|
|
6
6
|
let node_path = require("node:path");
|
|
7
|
-
node_path = require_chunk.__toESM(node_path);
|
|
7
|
+
node_path = require_chunk.__toESM(node_path, 1);
|
|
8
8
|
let node_module = require("node:module");
|
|
9
9
|
let vitest = require("vitest");
|
|
10
10
|
let react = require("react");
|
|
11
|
-
react = require_chunk.__toESM(react);
|
|
11
|
+
react = require_chunk.__toESM(react, 1);
|
|
12
12
|
//#region src/mocks/components/View.ts
|
|
13
13
|
function createViewMock() {
|
|
14
14
|
const View = react.default.forwardRef((props, ref) => {
|
|
@@ -255,6 +255,7 @@ function createTouchableNativeFeedbackMock() {
|
|
|
255
255
|
}
|
|
256
256
|
return react.default.createElement("TouchableNativeFeedback", {
|
|
257
257
|
accessible: true,
|
|
258
|
+
...disabled ? { pointerEvents: "none" } : {},
|
|
258
259
|
...rest,
|
|
259
260
|
...mergedA11yState ? { accessibilityState: mergedA11yState } : {},
|
|
260
261
|
ref
|
|
@@ -707,13 +708,14 @@ function colorToRgba(input) {
|
|
|
707
708
|
parseInt(n.slice(6, 8), 16) / 255
|
|
708
709
|
];
|
|
709
710
|
}
|
|
710
|
-
|
|
711
|
+
const compact = s.replace(/\s+/g, "");
|
|
712
|
+
if (m = compact.match(/^rgb\(([\d.]+),([\d.]+),([\d.]+)\)$/)) return [
|
|
711
713
|
+m[1],
|
|
712
714
|
+m[2],
|
|
713
715
|
+m[3],
|
|
714
716
|
1
|
|
715
717
|
];
|
|
716
|
-
if (m =
|
|
718
|
+
if (m = compact.match(/^rgba\(([\d.]+),([\d.]+),([\d.]+),([\d.]+)\)$/)) return [
|
|
717
719
|
+m[1],
|
|
718
720
|
+m[2],
|
|
719
721
|
+m[3],
|
|
@@ -938,7 +940,7 @@ const namedColorMap = {
|
|
|
938
940
|
]
|
|
939
941
|
};
|
|
940
942
|
function parseColorString(color) {
|
|
941
|
-
const rgba = color.match(/^rgba?\(
|
|
943
|
+
const rgba = color.replace(/\s+/g, "").match(/^rgba?\((\d+),(\d+),(\d+)(?:,([\d.]+))?\)$/);
|
|
942
944
|
if (rgba) return [
|
|
943
945
|
parseInt(rgba[1]),
|
|
944
946
|
parseInt(rgba[2]),
|
|
@@ -1056,9 +1058,39 @@ function createAnimation(onStart) {
|
|
|
1056
1058
|
reset: vitest.vi.fn()
|
|
1057
1059
|
};
|
|
1058
1060
|
}
|
|
1061
|
+
function resolveAnimatedLeaf(v) {
|
|
1062
|
+
if (v instanceof AnimatedValue) return v.getValue();
|
|
1063
|
+
if (v && typeof v === "object" && typeof v.__getValue === "function") return v.__getValue();
|
|
1064
|
+
if (v && typeof v === "object" && typeof v.getValue === "function") return v.getValue();
|
|
1065
|
+
return v;
|
|
1066
|
+
}
|
|
1067
|
+
function resolveAnimatedStyle(style) {
|
|
1068
|
+
if (Array.isArray(style)) return style.map(resolveAnimatedStyle);
|
|
1069
|
+
const asLeaf = resolveAnimatedLeaf(style);
|
|
1070
|
+
if (asLeaf !== style) return asLeaf;
|
|
1071
|
+
if (style && typeof style === "object") {
|
|
1072
|
+
const out = {};
|
|
1073
|
+
for (const key of Object.keys(style)) {
|
|
1074
|
+
const val = style[key];
|
|
1075
|
+
if (key === "transform" && Array.isArray(val)) out[key] = val.map((t) => t && typeof t === "object" && !(t instanceof AnimatedValue) ? Object.fromEntries(Object.keys(t).map((tk) => [tk, resolveAnimatedLeaf(t[tk])])) : resolveAnimatedLeaf(t));
|
|
1076
|
+
else out[key] = resolveAnimatedLeaf(val);
|
|
1077
|
+
}
|
|
1078
|
+
return out;
|
|
1079
|
+
}
|
|
1080
|
+
return style;
|
|
1081
|
+
}
|
|
1059
1082
|
function createAnimatedWrapper(displayName) {
|
|
1083
|
+
const hostName = displayName.replace(/^Animated\./, "");
|
|
1060
1084
|
const Component = react.default.forwardRef((props, ref) => {
|
|
1061
|
-
|
|
1085
|
+
if (props && props.style !== void 0) {
|
|
1086
|
+
const { style, ...rest } = props;
|
|
1087
|
+
return react.default.createElement(hostName, {
|
|
1088
|
+
...rest,
|
|
1089
|
+
style: resolveAnimatedStyle(style),
|
|
1090
|
+
ref
|
|
1091
|
+
});
|
|
1092
|
+
}
|
|
1093
|
+
return react.default.createElement(hostName, {
|
|
1062
1094
|
...props,
|
|
1063
1095
|
ref
|
|
1064
1096
|
});
|
|
@@ -2524,6 +2556,8 @@ function installPresetCjsBridge(moduleName, mockObject) {
|
|
|
2524
2556
|
*/
|
|
2525
2557
|
const platform = process.env.VITEST_NATIVE_PLATFORM || "ios";
|
|
2526
2558
|
const diagnostics = process.env.VITEST_NATIVE_DIAGNOSTICS === "true";
|
|
2559
|
+
const projectRoot = process.env.VITEST_NATIVE_PROJECT_ROOT || process.cwd();
|
|
2560
|
+
const projectReq = (0, node_module.createRequire)(node_path.default.join(projectRoot, "package.json"));
|
|
2527
2561
|
let customMocks = {};
|
|
2528
2562
|
if (process.env.VITEST_NATIVE_MOCKS) try {
|
|
2529
2563
|
customMocks = JSON.parse(process.env.VITEST_NATIVE_MOCKS);
|
|
@@ -2570,6 +2604,12 @@ Object.defineProperties(g, {
|
|
|
2570
2604
|
writable: true
|
|
2571
2605
|
}
|
|
2572
2606
|
});
|
|
2607
|
+
if (typeof g.expect === "undefined") Object.defineProperty(g, "expect", {
|
|
2608
|
+
configurable: true,
|
|
2609
|
+
enumerable: false,
|
|
2610
|
+
value: vitest.expect,
|
|
2611
|
+
writable: true
|
|
2612
|
+
});
|
|
2573
2613
|
g.IS_REACT_ACT_ENVIRONMENT = true;
|
|
2574
2614
|
g.IS_REACT_NATIVE_TEST_ENVIRONMENT = true;
|
|
2575
2615
|
const rnMock = buildReactNativeMock(platform);
|
|
@@ -2583,14 +2623,15 @@ function loadPresetFactory(exportName) {
|
|
|
2583
2623
|
return typeof factory === "function" ? factory : null;
|
|
2584
2624
|
}
|
|
2585
2625
|
function autoDetectPresets() {
|
|
2586
|
-
const projectRoot = process.env.VITEST_NATIVE_PROJECT_ROOT || process.cwd();
|
|
2587
|
-
const projectReq = (0, node_module.createRequire)(node_path.default.join(projectRoot, "package.json"));
|
|
2588
2626
|
const detected = [];
|
|
2627
|
+
const enabled = /* @__PURE__ */ new Set();
|
|
2589
2628
|
for (const [pkgName, exportName] of Object.entries(require_preset_map.AUTO_DETECT_PRESETS)) try {
|
|
2590
2629
|
projectReq.resolve(pkgName);
|
|
2630
|
+
if (enabled.has(exportName)) continue;
|
|
2591
2631
|
const factory = loadPresetFactory(exportName);
|
|
2592
2632
|
if (factory) {
|
|
2593
2633
|
detected.push(factory());
|
|
2634
|
+
enabled.add(exportName);
|
|
2594
2635
|
if (diagnostics) console.log(`[vitest-native] Auto-detected ${pkgName} → enabled ${exportName} preset`);
|
|
2595
2636
|
}
|
|
2596
2637
|
} catch {}
|
|
@@ -2613,8 +2654,13 @@ for (const preset of presets) for (const [modName, presetModule] of Object.entri
|
|
|
2613
2654
|
if (diagnostics) console.log(`[vitest-native] Registered preset mock: ${modName} (${preset.name})`);
|
|
2614
2655
|
}
|
|
2615
2656
|
try {
|
|
2616
|
-
const rntl =
|
|
2617
|
-
|
|
2657
|
+
const rntl = projectReq("@testing-library/react-native");
|
|
2658
|
+
let rntlMajor = 0;
|
|
2659
|
+
try {
|
|
2660
|
+
const { version } = projectReq("@testing-library/react-native/package.json");
|
|
2661
|
+
rntlMajor = Number(String(version).split(".")[0]) || 0;
|
|
2662
|
+
} catch {}
|
|
2663
|
+
if (rntl?.configure && rntlMajor < 14) rntl.configure({ hostComponentNames: {
|
|
2618
2664
|
text: "Text",
|
|
2619
2665
|
textInput: "TextInput",
|
|
2620
2666
|
switch: "RCTSwitch",
|
|
@@ -2630,7 +2676,19 @@ try {
|
|
|
2630
2676
|
if (diagnostics) console.log(`[vitest-native] @testing-library/react-native not available: ${e?.message}`);
|
|
2631
2677
|
}
|
|
2632
2678
|
try {
|
|
2633
|
-
|
|
2679
|
+
let matchers = null;
|
|
2680
|
+
let lastError;
|
|
2681
|
+
for (const moduleId of [
|
|
2682
|
+
"@testing-library/react-native/matchers",
|
|
2683
|
+
"@testing-library/react-native/build/matchers",
|
|
2684
|
+
"@testing-library/react-native/dist/matchers"
|
|
2685
|
+
]) try {
|
|
2686
|
+
matchers = projectReq(moduleId);
|
|
2687
|
+
break;
|
|
2688
|
+
} catch (error) {
|
|
2689
|
+
lastError = error;
|
|
2690
|
+
}
|
|
2691
|
+
if (!matchers) throw lastError;
|
|
2634
2692
|
if (matchers && Object.keys(matchers).length > 0) {
|
|
2635
2693
|
const matcherFns = {};
|
|
2636
2694
|
for (const [key, val] of Object.entries(matchers)) if (typeof val === "function" && key !== "__esModule") matcherFns[key] = val;
|