vitest-native 0.6.1 → 0.8.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 +84 -0
- package/README.md +60 -13
- package/dist/{index-DGNLmGjq.d.mts → index-YjjYELG7.d.cts} +40 -3
- package/dist/{index-Dr3WvKWI.d.cts → index-vlK4zxuK.d.mts} +38 -5
- package/dist/index.cjs +12 -4
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +12 -4
- package/dist/jest-compat/setup.mjs +15 -0
- package/dist/native/compile-cache.mjs +40 -0
- package/dist/native/hooks.mjs +9 -2
- package/dist/native/loader.mjs +50 -5
- package/dist/native/resolve.mjs +18 -0
- package/dist/native/setup.mjs +39 -2
- package/dist/native/transform.mjs +5 -3
- package/dist/native/worker.mjs +4 -0
- package/dist/{preset-map-CNBOeqAu.cjs → preset-map-BY9zk9Pj.cjs} +4 -1
- package/dist/{preset-map-C1UwEald.mjs → preset-map-DCWaM08s.mjs} +4 -1
- package/dist/{presets-DVLDrPC-.mjs → presets-23FJ76O4.mjs} +641 -6
- package/dist/{presets-BPVVlfI2.cjs → presets-7eMfp7o2.cjs} +712 -5
- package/dist/presets.cjs +4 -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 +24 -219
- package/dist/setup.mjs +15 -210
- package/docs/migrating-from-jest.md +3 -1
- package/package.json +11 -5
package/dist/presets.cjs
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_presets = require("./presets-
|
|
2
|
+
const require_presets = require("./presets-7eMfp7o2.cjs");
|
|
3
3
|
exports.asyncStorage = require_presets.asyncStorage;
|
|
4
|
+
exports.bottomSheet = require_presets.bottomSheet;
|
|
4
5
|
exports.deviceInfo = require_presets.deviceInfo;
|
|
5
6
|
exports.expo = require_presets.expo;
|
|
7
|
+
exports.flashList = require_presets.flashList;
|
|
6
8
|
exports.gestureHandler = require_presets.gestureHandler;
|
|
9
|
+
exports.keyboardController = require_presets.keyboardController;
|
|
7
10
|
exports.mmkv = require_presets.mmkv;
|
|
8
11
|
exports.navigation = require_presets.navigation;
|
|
9
12
|
exports.reanimated = require_presets.reanimated;
|
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, vectorIcons, webview };
|
|
1
|
+
import { a as vectorIcons, c as mmkv, d as screens, f as asyncStorage, g as reanimated, h as gestureHandler, i as flashList, l as deviceInfo, m as safeAreaContext, n as keyboardController, o as webview, p as navigation, r as bottomSheet, s as svg, u as expo } from "./index-YjjYELG7.cjs";
|
|
2
|
+
export { asyncStorage, bottomSheet, deviceInfo, expo, flashList, gestureHandler, keyboardController, 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, vectorIcons, webview };
|
|
1
|
+
import { a as vectorIcons, c as mmkv, d as screens, f as asyncStorage, g as reanimated, h as gestureHandler, i as flashList, l as deviceInfo, m as safeAreaContext, n as keyboardController, o as webview, p as navigation, r as bottomSheet, s as svg, u as expo } from "./index-vlK4zxuK.mjs";
|
|
2
|
+
export { asyncStorage, bottomSheet, deviceInfo, expo, flashList, gestureHandler, keyboardController, mmkv, navigation, reanimated, safeAreaContext, screens, svg, vectorIcons, webview };
|
package/dist/presets.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { asyncStorage, deviceInfo, expo, gestureHandler, mmkv, navigation, reanimated, safeAreaContext, screens, svg, vectorIcons, webview };
|
|
1
|
+
import { C as safeAreaContext, D as reanimated, S as navigation, _ as mmkv, b as screens, g as svg, h as webview, i as bottomSheet, m as vectorIcons, n as keyboardController, p as flashList, v as deviceInfo, w as gestureHandler, x as asyncStorage, y as expo } from "./presets-23FJ76O4.mjs";
|
|
2
|
+
export { asyncStorage, bottomSheet, deviceInfo, expo, flashList, gestureHandler, keyboardController, mmkv, navigation, reanimated, safeAreaContext, screens, svg, vectorIcons, webview };
|
package/dist/setup.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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-BY9zk9Pj.cjs");
|
|
3
|
+
const require_presets = require("./presets-7eMfp7o2.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");
|
|
@@ -9,18 +9,6 @@ let node_module = require("node:module");
|
|
|
9
9
|
let vitest = require("vitest");
|
|
10
10
|
let react = require("react");
|
|
11
11
|
react = require_chunk.__toESM(react, 1);
|
|
12
|
-
//#region src/mocks/components/View.ts
|
|
13
|
-
function createViewMock() {
|
|
14
|
-
const View = react.default.forwardRef((props, ref) => {
|
|
15
|
-
return react.default.createElement("View", {
|
|
16
|
-
...props,
|
|
17
|
-
ref
|
|
18
|
-
});
|
|
19
|
-
});
|
|
20
|
-
View.displayName = "View";
|
|
21
|
-
return View;
|
|
22
|
-
}
|
|
23
|
-
//#endregion
|
|
24
12
|
//#region src/mocks/components/Text.ts
|
|
25
13
|
function createTextMock() {
|
|
26
14
|
const Text = react.default.forwardRef((props, ref) => {
|
|
@@ -68,141 +56,6 @@ function createImageMock() {
|
|
|
68
56
|
return Image;
|
|
69
57
|
}
|
|
70
58
|
//#endregion
|
|
71
|
-
//#region src/mocks/components/TextInput.ts
|
|
72
|
-
function createTextInputMock() {
|
|
73
|
-
const TextInput = react.default.forwardRef((props, ref) => {
|
|
74
|
-
const instanceMethods = {
|
|
75
|
-
focus: vitest.vi.fn(),
|
|
76
|
-
blur: vitest.vi.fn(),
|
|
77
|
-
clear: vitest.vi.fn(),
|
|
78
|
-
isFocused: vitest.vi.fn(() => false),
|
|
79
|
-
setNativeProps: vitest.vi.fn()
|
|
80
|
-
};
|
|
81
|
-
react.default.useImperativeHandle(ref, () => instanceMethods);
|
|
82
|
-
return react.default.createElement("TextInput", {
|
|
83
|
-
...props,
|
|
84
|
-
ref
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
TextInput.displayName = "TextInput";
|
|
88
|
-
return TextInput;
|
|
89
|
-
}
|
|
90
|
-
//#endregion
|
|
91
|
-
//#region src/mocks/components/ScrollView.ts
|
|
92
|
-
function createScrollViewMock() {
|
|
93
|
-
const ScrollView = react.default.forwardRef((props, ref) => {
|
|
94
|
-
const { children, refreshControl, ...rest } = props;
|
|
95
|
-
const instanceMethods = {
|
|
96
|
-
scrollTo: vitest.vi.fn(),
|
|
97
|
-
scrollToEnd: vitest.vi.fn(),
|
|
98
|
-
flashScrollIndicators: vitest.vi.fn(),
|
|
99
|
-
getScrollResponder: vitest.vi.fn(() => ({})),
|
|
100
|
-
getInnerViewNode: vitest.vi.fn(),
|
|
101
|
-
setNativeProps: vitest.vi.fn()
|
|
102
|
-
};
|
|
103
|
-
react.default.useImperativeHandle(ref, () => instanceMethods);
|
|
104
|
-
return react.default.createElement("RCTScrollView", {
|
|
105
|
-
...rest,
|
|
106
|
-
ref
|
|
107
|
-
}, refreshControl, react.default.createElement("View", null, children));
|
|
108
|
-
});
|
|
109
|
-
ScrollView.displayName = "ScrollView";
|
|
110
|
-
return ScrollView;
|
|
111
|
-
}
|
|
112
|
-
//#endregion
|
|
113
|
-
//#region src/mocks/components/FlatList.ts
|
|
114
|
-
function createFlatListMock() {
|
|
115
|
-
const FlatList = react.default.forwardRef((props, ref) => {
|
|
116
|
-
const { data, renderItem, keyExtractor, ListHeaderComponent, ListFooterComponent, ListEmptyComponent, ItemSeparatorComponent, refreshControl, ...rest } = props;
|
|
117
|
-
const instanceMethods = {
|
|
118
|
-
scrollToEnd: vitest.vi.fn(),
|
|
119
|
-
scrollToIndex: vitest.vi.fn(),
|
|
120
|
-
scrollToItem: vitest.vi.fn(),
|
|
121
|
-
scrollToOffset: vitest.vi.fn(),
|
|
122
|
-
recordInteraction: vitest.vi.fn(),
|
|
123
|
-
flashScrollIndicators: vitest.vi.fn(),
|
|
124
|
-
getScrollResponder: vitest.vi.fn(() => ({})),
|
|
125
|
-
getNativeScrollRef: vitest.vi.fn(),
|
|
126
|
-
getScrollableNode: vitest.vi.fn(),
|
|
127
|
-
setNativeProps: vitest.vi.fn()
|
|
128
|
-
};
|
|
129
|
-
react.default.useImperativeHandle(ref, () => instanceMethods);
|
|
130
|
-
const children = [];
|
|
131
|
-
if (ListHeaderComponent) children.push(react.default.createElement("FlatList-Header", { key: "__header" }, typeof ListHeaderComponent === "function" ? react.default.createElement(ListHeaderComponent) : ListHeaderComponent));
|
|
132
|
-
if (data && data.length > 0) data.forEach((item, index) => {
|
|
133
|
-
const key = keyExtractor ? keyExtractor(item, index) : String(index);
|
|
134
|
-
children.push(react.default.createElement(react.default.Fragment, { key }, renderItem({
|
|
135
|
-
item,
|
|
136
|
-
index,
|
|
137
|
-
separators: {
|
|
138
|
-
highlight: vitest.vi.fn(),
|
|
139
|
-
unhighlight: vitest.vi.fn(),
|
|
140
|
-
updateProps: vitest.vi.fn()
|
|
141
|
-
}
|
|
142
|
-
})));
|
|
143
|
-
if (ItemSeparatorComponent && index < data.length - 1) children.push(react.default.createElement(react.default.Fragment, { key: `separator-${index}` }, typeof ItemSeparatorComponent === "function" ? react.default.createElement(ItemSeparatorComponent) : ItemSeparatorComponent));
|
|
144
|
-
});
|
|
145
|
-
else if (ListEmptyComponent) children.push(react.default.createElement("FlatList-Empty", { key: "__empty" }, typeof ListEmptyComponent === "function" ? react.default.createElement(ListEmptyComponent) : ListEmptyComponent));
|
|
146
|
-
if (ListFooterComponent) children.push(react.default.createElement("FlatList-Footer", { key: "__footer" }, typeof ListFooterComponent === "function" ? react.default.createElement(ListFooterComponent) : ListFooterComponent));
|
|
147
|
-
if (refreshControl) children.unshift(refreshControl);
|
|
148
|
-
return react.default.createElement("FlatList", {
|
|
149
|
-
...rest,
|
|
150
|
-
ref
|
|
151
|
-
}, ...children);
|
|
152
|
-
});
|
|
153
|
-
FlatList.displayName = "FlatList";
|
|
154
|
-
return FlatList;
|
|
155
|
-
}
|
|
156
|
-
//#endregion
|
|
157
|
-
//#region src/mocks/components/SectionList.ts
|
|
158
|
-
function createSectionListMock() {
|
|
159
|
-
const SectionList = react.default.forwardRef((props, ref) => {
|
|
160
|
-
const { sections, renderItem, renderSectionHeader, renderSectionFooter, keyExtractor, refreshControl, ListEmptyComponent, ListHeaderComponent, ListFooterComponent, ItemSeparatorComponent, SectionSeparatorComponent, ...rest } = props;
|
|
161
|
-
const instanceMethods = {
|
|
162
|
-
scrollToEnd: vitest.vi.fn(),
|
|
163
|
-
scrollToIndex: vitest.vi.fn(),
|
|
164
|
-
scrollToLocation: vitest.vi.fn(),
|
|
165
|
-
recordInteraction: vitest.vi.fn(),
|
|
166
|
-
flashScrollIndicators: vitest.vi.fn(),
|
|
167
|
-
getScrollResponder: vitest.vi.fn(() => ({})),
|
|
168
|
-
getNativeScrollRef: vitest.vi.fn(),
|
|
169
|
-
getScrollableNode: vitest.vi.fn(),
|
|
170
|
-
setNativeProps: vitest.vi.fn()
|
|
171
|
-
};
|
|
172
|
-
react.default.useImperativeHandle(ref, () => instanceMethods);
|
|
173
|
-
const children = [];
|
|
174
|
-
if (ListHeaderComponent) children.push(react.default.createElement("SectionList-Header", { key: "__header" }, typeof ListHeaderComponent === "function" ? react.default.createElement(ListHeaderComponent) : ListHeaderComponent));
|
|
175
|
-
if (sections) sections.forEach((section, sectionIndex) => {
|
|
176
|
-
if (renderSectionHeader) children.push(react.default.createElement(react.default.Fragment, { key: `header-${sectionIndex}` }, renderSectionHeader({ section })));
|
|
177
|
-
if (SectionSeparatorComponent && sectionIndex > 0) children.push(react.default.createElement(react.default.Fragment, { key: `section-sep-${sectionIndex}` }, typeof SectionSeparatorComponent === "function" ? react.default.createElement(SectionSeparatorComponent) : SectionSeparatorComponent));
|
|
178
|
-
if (section.data) section.data.forEach((item, index) => {
|
|
179
|
-
const key = keyExtractor ? keyExtractor(item, index) : `${sectionIndex}-${index}`;
|
|
180
|
-
children.push(react.default.createElement(react.default.Fragment, { key }, renderItem({
|
|
181
|
-
item,
|
|
182
|
-
index,
|
|
183
|
-
section,
|
|
184
|
-
separators: {
|
|
185
|
-
highlight: vitest.vi.fn(),
|
|
186
|
-
unhighlight: vitest.vi.fn(),
|
|
187
|
-
updateProps: vitest.vi.fn()
|
|
188
|
-
}
|
|
189
|
-
})));
|
|
190
|
-
if (ItemSeparatorComponent && index < section.data.length - 1) children.push(react.default.createElement(react.default.Fragment, { key: `sep-${sectionIndex}-${index}` }, typeof ItemSeparatorComponent === "function" ? react.default.createElement(ItemSeparatorComponent) : ItemSeparatorComponent));
|
|
191
|
-
});
|
|
192
|
-
if (renderSectionFooter) children.push(react.default.createElement(react.default.Fragment, { key: `footer-${sectionIndex}` }, renderSectionFooter({ section })));
|
|
193
|
-
});
|
|
194
|
-
if (ListFooterComponent) children.push(react.default.createElement("SectionList-Footer", { key: "__footer" }, typeof ListFooterComponent === "function" ? react.default.createElement(ListFooterComponent) : ListFooterComponent));
|
|
195
|
-
if (refreshControl) children.unshift(refreshControl);
|
|
196
|
-
if ((!sections || sections.length === 0) && ListEmptyComponent) children.push(react.default.createElement("SectionList-Empty", { key: "__empty" }, typeof ListEmptyComponent === "function" ? react.default.createElement(ListEmptyComponent) : ListEmptyComponent));
|
|
197
|
-
return react.default.createElement("SectionList", {
|
|
198
|
-
...rest,
|
|
199
|
-
ref
|
|
200
|
-
}, ...children);
|
|
201
|
-
});
|
|
202
|
-
SectionList.displayName = "SectionList";
|
|
203
|
-
return SectionList;
|
|
204
|
-
}
|
|
205
|
-
//#endregion
|
|
206
59
|
//#region src/mocks/components/Modal.ts
|
|
207
60
|
function createModalMock() {
|
|
208
61
|
const Modal = react.default.forwardRef((props, ref) => {
|
|
@@ -218,27 +71,6 @@ function createModalMock() {
|
|
|
218
71
|
return Modal;
|
|
219
72
|
}
|
|
220
73
|
//#endregion
|
|
221
|
-
//#region src/mocks/components/TouchableOpacity.ts
|
|
222
|
-
function createTouchableOpacityMock() {
|
|
223
|
-
const TouchableOpacity = react.default.forwardRef((props, ref) => react.default.createElement("TouchableOpacity", require_presets.buildPressableHostProps(props, ref)));
|
|
224
|
-
TouchableOpacity.displayName = "TouchableOpacity";
|
|
225
|
-
return TouchableOpacity;
|
|
226
|
-
}
|
|
227
|
-
//#endregion
|
|
228
|
-
//#region src/mocks/components/TouchableHighlight.ts
|
|
229
|
-
function createTouchableHighlightMock() {
|
|
230
|
-
const TouchableHighlight = react.default.forwardRef((props, ref) => react.default.createElement("TouchableHighlight", require_presets.buildPressableHostProps(props, ref)));
|
|
231
|
-
TouchableHighlight.displayName = "TouchableHighlight";
|
|
232
|
-
return TouchableHighlight;
|
|
233
|
-
}
|
|
234
|
-
//#endregion
|
|
235
|
-
//#region src/mocks/components/TouchableWithoutFeedback.ts
|
|
236
|
-
function createTouchableWithoutFeedbackMock() {
|
|
237
|
-
const TouchableWithoutFeedback = react.default.forwardRef((props, ref) => react.default.createElement("TouchableWithoutFeedback", require_presets.buildPressableHostProps(props, ref)));
|
|
238
|
-
TouchableWithoutFeedback.displayName = "TouchableWithoutFeedback";
|
|
239
|
-
return TouchableWithoutFeedback;
|
|
240
|
-
}
|
|
241
|
-
//#endregion
|
|
242
74
|
//#region src/mocks/components/TouchableNativeFeedback.ts
|
|
243
75
|
function createTouchableNativeFeedbackMock() {
|
|
244
76
|
const TouchableNativeFeedback = react.default.forwardRef((props, ref) => {
|
|
@@ -382,46 +214,6 @@ function createImageBackgroundMock() {
|
|
|
382
214
|
return ImageBackground;
|
|
383
215
|
}
|
|
384
216
|
//#endregion
|
|
385
|
-
//#region src/mocks/components/VirtualizedList.ts
|
|
386
|
-
function createVirtualizedListMock() {
|
|
387
|
-
const VirtualizedList = react.default.forwardRef((props, ref) => {
|
|
388
|
-
const { data, renderItem, keyExtractor, getItemCount, getItem, ListHeaderComponent, ListFooterComponent, ListEmptyComponent, ...rest } = props;
|
|
389
|
-
const instanceMethods = {
|
|
390
|
-
scrollToEnd: vitest.vi.fn(),
|
|
391
|
-
scrollToIndex: vitest.vi.fn(),
|
|
392
|
-
scrollToItem: vitest.vi.fn(),
|
|
393
|
-
scrollToOffset: vitest.vi.fn(),
|
|
394
|
-
recordInteraction: vitest.vi.fn(),
|
|
395
|
-
flashScrollIndicators: vitest.vi.fn(),
|
|
396
|
-
getScrollResponder: vitest.vi.fn(() => ({})),
|
|
397
|
-
getNativeScrollRef: vitest.vi.fn(),
|
|
398
|
-
getScrollableNode: vitest.vi.fn(),
|
|
399
|
-
setNativeProps: vitest.vi.fn()
|
|
400
|
-
};
|
|
401
|
-
react.default.useImperativeHandle(ref, () => instanceMethods);
|
|
402
|
-
const children = [];
|
|
403
|
-
if (ListHeaderComponent) children.push(react.default.createElement("VirtualizedList-Header", { key: "__header" }, typeof ListHeaderComponent === "function" ? react.default.createElement(ListHeaderComponent) : ListHeaderComponent));
|
|
404
|
-
const itemCount = getItemCount ? getItemCount(data) : data ? data.length : 0;
|
|
405
|
-
if (itemCount > 0) for (let index = 0; index < itemCount; index++) {
|
|
406
|
-
const item = getItem ? getItem(data, index) : data[index];
|
|
407
|
-
const key = keyExtractor ? keyExtractor(item, index) : String(index);
|
|
408
|
-
children.push(react.default.createElement(react.default.Fragment, { key }, renderItem({
|
|
409
|
-
item,
|
|
410
|
-
index,
|
|
411
|
-
separators: {}
|
|
412
|
-
})));
|
|
413
|
-
}
|
|
414
|
-
else if (ListEmptyComponent) children.push(react.default.createElement("VirtualizedList-Empty", { key: "__empty" }, typeof ListEmptyComponent === "function" ? react.default.createElement(ListEmptyComponent) : ListEmptyComponent));
|
|
415
|
-
if (ListFooterComponent) children.push(react.default.createElement("VirtualizedList-Footer", { key: "__footer" }, typeof ListFooterComponent === "function" ? react.default.createElement(ListFooterComponent) : ListFooterComponent));
|
|
416
|
-
return react.default.createElement("VirtualizedList", {
|
|
417
|
-
...rest,
|
|
418
|
-
ref
|
|
419
|
-
}, ...children);
|
|
420
|
-
});
|
|
421
|
-
VirtualizedList.displayName = "VirtualizedList";
|
|
422
|
-
return VirtualizedList;
|
|
423
|
-
}
|
|
424
|
-
//#endregion
|
|
425
217
|
//#region src/mocks/components/InputAccessoryView.ts
|
|
426
218
|
function createInputAccessoryViewMock() {
|
|
427
219
|
const InputAccessoryView = react.default.forwardRef((props, ref) => {
|
|
@@ -2313,20 +2105,30 @@ function createUseAnimatedValueMock() {
|
|
|
2313
2105
|
return new (createAnimatedMock()).Value(initialValue);
|
|
2314
2106
|
});
|
|
2315
2107
|
}
|
|
2108
|
+
function createUseAnimatedValueXYMock() {
|
|
2109
|
+
return vitest.vi.fn((initialValue) => {
|
|
2110
|
+
return new (createAnimatedMock()).ValueXY(initialValue);
|
|
2111
|
+
});
|
|
2112
|
+
}
|
|
2113
|
+
function createUseAnimatedColorMock() {
|
|
2114
|
+
return vitest.vi.fn((initialValue) => {
|
|
2115
|
+
return new (createAnimatedMock()).Color(initialValue);
|
|
2116
|
+
});
|
|
2117
|
+
}
|
|
2316
2118
|
function buildReactNativeMock(platform = "ios") {
|
|
2317
2119
|
const mock = {
|
|
2318
|
-
View: createViewMock(),
|
|
2120
|
+
View: require_presets.createViewMock(),
|
|
2319
2121
|
Text: createTextMock(),
|
|
2320
2122
|
Image: createImageMock(),
|
|
2321
|
-
TextInput: createTextInputMock(),
|
|
2322
|
-
ScrollView: createScrollViewMock(),
|
|
2323
|
-
FlatList: createFlatListMock(),
|
|
2324
|
-
SectionList: createSectionListMock(),
|
|
2123
|
+
TextInput: require_presets.createTextInputMock(),
|
|
2124
|
+
ScrollView: require_presets.createScrollViewMock(),
|
|
2125
|
+
FlatList: require_presets.createFlatListMock(),
|
|
2126
|
+
SectionList: require_presets.createSectionListMock(),
|
|
2325
2127
|
Modal: createModalMock(),
|
|
2326
2128
|
Pressable: require_presets.createPressableMock(),
|
|
2327
|
-
TouchableOpacity: createTouchableOpacityMock(),
|
|
2328
|
-
TouchableHighlight: createTouchableHighlightMock(),
|
|
2329
|
-
TouchableWithoutFeedback: createTouchableWithoutFeedbackMock(),
|
|
2129
|
+
TouchableOpacity: require_presets.createTouchableOpacityMock(),
|
|
2130
|
+
TouchableHighlight: require_presets.createTouchableHighlightMock(),
|
|
2131
|
+
TouchableWithoutFeedback: require_presets.createTouchableWithoutFeedbackMock(),
|
|
2330
2132
|
TouchableNativeFeedback: createTouchableNativeFeedbackMock(),
|
|
2331
2133
|
ActivityIndicator: createActivityIndicatorMock(),
|
|
2332
2134
|
Button: createButtonMock(),
|
|
@@ -2336,7 +2138,7 @@ function buildReactNativeMock(platform = "ios") {
|
|
|
2336
2138
|
SafeAreaView: createSafeAreaViewMock(),
|
|
2337
2139
|
KeyboardAvoidingView: createKeyboardAvoidingViewMock(),
|
|
2338
2140
|
ImageBackground: createImageBackgroundMock(),
|
|
2339
|
-
VirtualizedList: createVirtualizedListMock(),
|
|
2141
|
+
VirtualizedList: require_presets.createVirtualizedListMock(),
|
|
2340
2142
|
InputAccessoryView: createInputAccessoryViewMock(),
|
|
2341
2143
|
DrawerLayoutAndroid: createDrawerLayoutAndroidMock(),
|
|
2342
2144
|
Platform: createPlatformMock(platform),
|
|
@@ -2371,6 +2173,7 @@ function buildReactNativeMock(platform = "ios") {
|
|
|
2371
2173
|
UIManager: createUIManagerMock(),
|
|
2372
2174
|
NativeEventEmitter: createNativeEventEmitterMock(),
|
|
2373
2175
|
NativeAppEventEmitter: createDeviceEventEmitterMock(),
|
|
2176
|
+
EventEmitter: createNativeEventEmitterMock(),
|
|
2374
2177
|
NativeComponentRegistry: createNativeComponentRegistryMock(),
|
|
2375
2178
|
requireNativeComponent: createRequireNativeComponentMock(),
|
|
2376
2179
|
AppRegistry: createAppRegistryMock(),
|
|
@@ -2383,6 +2186,8 @@ function buildReactNativeMock(platform = "ios") {
|
|
|
2383
2186
|
Settings: createSettingsMock(),
|
|
2384
2187
|
DeviceInfo: createDeviceInfoMock(),
|
|
2385
2188
|
useAnimatedValue: createUseAnimatedValueMock(),
|
|
2189
|
+
useAnimatedValueXY: createUseAnimatedValueXYMock(),
|
|
2190
|
+
useAnimatedColor: createUseAnimatedColorMock(),
|
|
2386
2191
|
RootTagContext: react.default.createContext(null),
|
|
2387
2192
|
ReactNativeVersion: {
|
|
2388
2193
|
major: 0,
|
package/dist/setup.mjs
CHANGED
|
@@ -1,24 +1,12 @@
|
|
|
1
1
|
import { n as __require } from "./chunk-CjcI7cDX.mjs";
|
|
2
|
-
import { t as AUTO_DETECT_PRESETS } from "./preset-map-
|
|
3
|
-
import {
|
|
2
|
+
import { t as AUTO_DETECT_PRESETS } from "./preset-map-DCWaM08s.mjs";
|
|
3
|
+
import { E as buildPressableHostProps, T as createPressableMock, a as createTouchableWithoutFeedbackMock, c as createVirtualizedListMock, d as createScrollViewMock, f as createTextInputMock, l as createSectionListMock, o as createTouchableHighlightMock, r as createViewMock, s as createTouchableOpacityMock, t as presets_exports, u as createFlatListMock } from "./presets-23FJ76O4.mjs";
|
|
4
4
|
import { serializer } from "./serializer.mjs";
|
|
5
5
|
import { animatedMatchers } from "./matchers.mjs";
|
|
6
6
|
import { createRequire } from "node:module";
|
|
7
7
|
import path from "node:path";
|
|
8
8
|
import { afterAll, expect, vi } from "vitest";
|
|
9
9
|
import React from "react";
|
|
10
|
-
//#region src/mocks/components/View.ts
|
|
11
|
-
function createViewMock() {
|
|
12
|
-
const View = React.forwardRef((props, ref) => {
|
|
13
|
-
return React.createElement("View", {
|
|
14
|
-
...props,
|
|
15
|
-
ref
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
View.displayName = "View";
|
|
19
|
-
return View;
|
|
20
|
-
}
|
|
21
|
-
//#endregion
|
|
22
10
|
//#region src/mocks/components/Text.ts
|
|
23
11
|
function createTextMock() {
|
|
24
12
|
const Text = React.forwardRef((props, ref) => {
|
|
@@ -66,141 +54,6 @@ function createImageMock() {
|
|
|
66
54
|
return Image;
|
|
67
55
|
}
|
|
68
56
|
//#endregion
|
|
69
|
-
//#region src/mocks/components/TextInput.ts
|
|
70
|
-
function createTextInputMock() {
|
|
71
|
-
const TextInput = React.forwardRef((props, ref) => {
|
|
72
|
-
const instanceMethods = {
|
|
73
|
-
focus: vi.fn(),
|
|
74
|
-
blur: vi.fn(),
|
|
75
|
-
clear: vi.fn(),
|
|
76
|
-
isFocused: vi.fn(() => false),
|
|
77
|
-
setNativeProps: vi.fn()
|
|
78
|
-
};
|
|
79
|
-
React.useImperativeHandle(ref, () => instanceMethods);
|
|
80
|
-
return React.createElement("TextInput", {
|
|
81
|
-
...props,
|
|
82
|
-
ref
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
TextInput.displayName = "TextInput";
|
|
86
|
-
return TextInput;
|
|
87
|
-
}
|
|
88
|
-
//#endregion
|
|
89
|
-
//#region src/mocks/components/ScrollView.ts
|
|
90
|
-
function createScrollViewMock() {
|
|
91
|
-
const ScrollView = React.forwardRef((props, ref) => {
|
|
92
|
-
const { children, refreshControl, ...rest } = props;
|
|
93
|
-
const instanceMethods = {
|
|
94
|
-
scrollTo: vi.fn(),
|
|
95
|
-
scrollToEnd: vi.fn(),
|
|
96
|
-
flashScrollIndicators: vi.fn(),
|
|
97
|
-
getScrollResponder: vi.fn(() => ({})),
|
|
98
|
-
getInnerViewNode: vi.fn(),
|
|
99
|
-
setNativeProps: vi.fn()
|
|
100
|
-
};
|
|
101
|
-
React.useImperativeHandle(ref, () => instanceMethods);
|
|
102
|
-
return React.createElement("RCTScrollView", {
|
|
103
|
-
...rest,
|
|
104
|
-
ref
|
|
105
|
-
}, refreshControl, React.createElement("View", null, children));
|
|
106
|
-
});
|
|
107
|
-
ScrollView.displayName = "ScrollView";
|
|
108
|
-
return ScrollView;
|
|
109
|
-
}
|
|
110
|
-
//#endregion
|
|
111
|
-
//#region src/mocks/components/FlatList.ts
|
|
112
|
-
function createFlatListMock() {
|
|
113
|
-
const FlatList = React.forwardRef((props, ref) => {
|
|
114
|
-
const { data, renderItem, keyExtractor, ListHeaderComponent, ListFooterComponent, ListEmptyComponent, ItemSeparatorComponent, refreshControl, ...rest } = props;
|
|
115
|
-
const instanceMethods = {
|
|
116
|
-
scrollToEnd: vi.fn(),
|
|
117
|
-
scrollToIndex: vi.fn(),
|
|
118
|
-
scrollToItem: vi.fn(),
|
|
119
|
-
scrollToOffset: vi.fn(),
|
|
120
|
-
recordInteraction: vi.fn(),
|
|
121
|
-
flashScrollIndicators: vi.fn(),
|
|
122
|
-
getScrollResponder: vi.fn(() => ({})),
|
|
123
|
-
getNativeScrollRef: vi.fn(),
|
|
124
|
-
getScrollableNode: vi.fn(),
|
|
125
|
-
setNativeProps: vi.fn()
|
|
126
|
-
};
|
|
127
|
-
React.useImperativeHandle(ref, () => instanceMethods);
|
|
128
|
-
const children = [];
|
|
129
|
-
if (ListHeaderComponent) children.push(React.createElement("FlatList-Header", { key: "__header" }, typeof ListHeaderComponent === "function" ? React.createElement(ListHeaderComponent) : ListHeaderComponent));
|
|
130
|
-
if (data && data.length > 0) data.forEach((item, index) => {
|
|
131
|
-
const key = keyExtractor ? keyExtractor(item, index) : String(index);
|
|
132
|
-
children.push(React.createElement(React.Fragment, { key }, renderItem({
|
|
133
|
-
item,
|
|
134
|
-
index,
|
|
135
|
-
separators: {
|
|
136
|
-
highlight: vi.fn(),
|
|
137
|
-
unhighlight: vi.fn(),
|
|
138
|
-
updateProps: vi.fn()
|
|
139
|
-
}
|
|
140
|
-
})));
|
|
141
|
-
if (ItemSeparatorComponent && index < data.length - 1) children.push(React.createElement(React.Fragment, { key: `separator-${index}` }, typeof ItemSeparatorComponent === "function" ? React.createElement(ItemSeparatorComponent) : ItemSeparatorComponent));
|
|
142
|
-
});
|
|
143
|
-
else if (ListEmptyComponent) children.push(React.createElement("FlatList-Empty", { key: "__empty" }, typeof ListEmptyComponent === "function" ? React.createElement(ListEmptyComponent) : ListEmptyComponent));
|
|
144
|
-
if (ListFooterComponent) children.push(React.createElement("FlatList-Footer", { key: "__footer" }, typeof ListFooterComponent === "function" ? React.createElement(ListFooterComponent) : ListFooterComponent));
|
|
145
|
-
if (refreshControl) children.unshift(refreshControl);
|
|
146
|
-
return React.createElement("FlatList", {
|
|
147
|
-
...rest,
|
|
148
|
-
ref
|
|
149
|
-
}, ...children);
|
|
150
|
-
});
|
|
151
|
-
FlatList.displayName = "FlatList";
|
|
152
|
-
return FlatList;
|
|
153
|
-
}
|
|
154
|
-
//#endregion
|
|
155
|
-
//#region src/mocks/components/SectionList.ts
|
|
156
|
-
function createSectionListMock() {
|
|
157
|
-
const SectionList = React.forwardRef((props, ref) => {
|
|
158
|
-
const { sections, renderItem, renderSectionHeader, renderSectionFooter, keyExtractor, refreshControl, ListEmptyComponent, ListHeaderComponent, ListFooterComponent, ItemSeparatorComponent, SectionSeparatorComponent, ...rest } = props;
|
|
159
|
-
const instanceMethods = {
|
|
160
|
-
scrollToEnd: vi.fn(),
|
|
161
|
-
scrollToIndex: vi.fn(),
|
|
162
|
-
scrollToLocation: vi.fn(),
|
|
163
|
-
recordInteraction: vi.fn(),
|
|
164
|
-
flashScrollIndicators: vi.fn(),
|
|
165
|
-
getScrollResponder: vi.fn(() => ({})),
|
|
166
|
-
getNativeScrollRef: vi.fn(),
|
|
167
|
-
getScrollableNode: vi.fn(),
|
|
168
|
-
setNativeProps: vi.fn()
|
|
169
|
-
};
|
|
170
|
-
React.useImperativeHandle(ref, () => instanceMethods);
|
|
171
|
-
const children = [];
|
|
172
|
-
if (ListHeaderComponent) children.push(React.createElement("SectionList-Header", { key: "__header" }, typeof ListHeaderComponent === "function" ? React.createElement(ListHeaderComponent) : ListHeaderComponent));
|
|
173
|
-
if (sections) sections.forEach((section, sectionIndex) => {
|
|
174
|
-
if (renderSectionHeader) children.push(React.createElement(React.Fragment, { key: `header-${sectionIndex}` }, renderSectionHeader({ section })));
|
|
175
|
-
if (SectionSeparatorComponent && sectionIndex > 0) children.push(React.createElement(React.Fragment, { key: `section-sep-${sectionIndex}` }, typeof SectionSeparatorComponent === "function" ? React.createElement(SectionSeparatorComponent) : SectionSeparatorComponent));
|
|
176
|
-
if (section.data) section.data.forEach((item, index) => {
|
|
177
|
-
const key = keyExtractor ? keyExtractor(item, index) : `${sectionIndex}-${index}`;
|
|
178
|
-
children.push(React.createElement(React.Fragment, { key }, renderItem({
|
|
179
|
-
item,
|
|
180
|
-
index,
|
|
181
|
-
section,
|
|
182
|
-
separators: {
|
|
183
|
-
highlight: vi.fn(),
|
|
184
|
-
unhighlight: vi.fn(),
|
|
185
|
-
updateProps: vi.fn()
|
|
186
|
-
}
|
|
187
|
-
})));
|
|
188
|
-
if (ItemSeparatorComponent && index < section.data.length - 1) children.push(React.createElement(React.Fragment, { key: `sep-${sectionIndex}-${index}` }, typeof ItemSeparatorComponent === "function" ? React.createElement(ItemSeparatorComponent) : ItemSeparatorComponent));
|
|
189
|
-
});
|
|
190
|
-
if (renderSectionFooter) children.push(React.createElement(React.Fragment, { key: `footer-${sectionIndex}` }, renderSectionFooter({ section })));
|
|
191
|
-
});
|
|
192
|
-
if (ListFooterComponent) children.push(React.createElement("SectionList-Footer", { key: "__footer" }, typeof ListFooterComponent === "function" ? React.createElement(ListFooterComponent) : ListFooterComponent));
|
|
193
|
-
if (refreshControl) children.unshift(refreshControl);
|
|
194
|
-
if ((!sections || sections.length === 0) && ListEmptyComponent) children.push(React.createElement("SectionList-Empty", { key: "__empty" }, typeof ListEmptyComponent === "function" ? React.createElement(ListEmptyComponent) : ListEmptyComponent));
|
|
195
|
-
return React.createElement("SectionList", {
|
|
196
|
-
...rest,
|
|
197
|
-
ref
|
|
198
|
-
}, ...children);
|
|
199
|
-
});
|
|
200
|
-
SectionList.displayName = "SectionList";
|
|
201
|
-
return SectionList;
|
|
202
|
-
}
|
|
203
|
-
//#endregion
|
|
204
57
|
//#region src/mocks/components/Modal.ts
|
|
205
58
|
function createModalMock() {
|
|
206
59
|
const Modal = React.forwardRef((props, ref) => {
|
|
@@ -216,27 +69,6 @@ function createModalMock() {
|
|
|
216
69
|
return Modal;
|
|
217
70
|
}
|
|
218
71
|
//#endregion
|
|
219
|
-
//#region src/mocks/components/TouchableOpacity.ts
|
|
220
|
-
function createTouchableOpacityMock() {
|
|
221
|
-
const TouchableOpacity = React.forwardRef((props, ref) => React.createElement("TouchableOpacity", buildPressableHostProps(props, ref)));
|
|
222
|
-
TouchableOpacity.displayName = "TouchableOpacity";
|
|
223
|
-
return TouchableOpacity;
|
|
224
|
-
}
|
|
225
|
-
//#endregion
|
|
226
|
-
//#region src/mocks/components/TouchableHighlight.ts
|
|
227
|
-
function createTouchableHighlightMock() {
|
|
228
|
-
const TouchableHighlight = React.forwardRef((props, ref) => React.createElement("TouchableHighlight", buildPressableHostProps(props, ref)));
|
|
229
|
-
TouchableHighlight.displayName = "TouchableHighlight";
|
|
230
|
-
return TouchableHighlight;
|
|
231
|
-
}
|
|
232
|
-
//#endregion
|
|
233
|
-
//#region src/mocks/components/TouchableWithoutFeedback.ts
|
|
234
|
-
function createTouchableWithoutFeedbackMock() {
|
|
235
|
-
const TouchableWithoutFeedback = React.forwardRef((props, ref) => React.createElement("TouchableWithoutFeedback", buildPressableHostProps(props, ref)));
|
|
236
|
-
TouchableWithoutFeedback.displayName = "TouchableWithoutFeedback";
|
|
237
|
-
return TouchableWithoutFeedback;
|
|
238
|
-
}
|
|
239
|
-
//#endregion
|
|
240
72
|
//#region src/mocks/components/TouchableNativeFeedback.ts
|
|
241
73
|
function createTouchableNativeFeedbackMock() {
|
|
242
74
|
const TouchableNativeFeedback = React.forwardRef((props, ref) => {
|
|
@@ -380,46 +212,6 @@ function createImageBackgroundMock() {
|
|
|
380
212
|
return ImageBackground;
|
|
381
213
|
}
|
|
382
214
|
//#endregion
|
|
383
|
-
//#region src/mocks/components/VirtualizedList.ts
|
|
384
|
-
function createVirtualizedListMock() {
|
|
385
|
-
const VirtualizedList = React.forwardRef((props, ref) => {
|
|
386
|
-
const { data, renderItem, keyExtractor, getItemCount, getItem, ListHeaderComponent, ListFooterComponent, ListEmptyComponent, ...rest } = props;
|
|
387
|
-
const instanceMethods = {
|
|
388
|
-
scrollToEnd: vi.fn(),
|
|
389
|
-
scrollToIndex: vi.fn(),
|
|
390
|
-
scrollToItem: vi.fn(),
|
|
391
|
-
scrollToOffset: vi.fn(),
|
|
392
|
-
recordInteraction: vi.fn(),
|
|
393
|
-
flashScrollIndicators: vi.fn(),
|
|
394
|
-
getScrollResponder: vi.fn(() => ({})),
|
|
395
|
-
getNativeScrollRef: vi.fn(),
|
|
396
|
-
getScrollableNode: vi.fn(),
|
|
397
|
-
setNativeProps: vi.fn()
|
|
398
|
-
};
|
|
399
|
-
React.useImperativeHandle(ref, () => instanceMethods);
|
|
400
|
-
const children = [];
|
|
401
|
-
if (ListHeaderComponent) children.push(React.createElement("VirtualizedList-Header", { key: "__header" }, typeof ListHeaderComponent === "function" ? React.createElement(ListHeaderComponent) : ListHeaderComponent));
|
|
402
|
-
const itemCount = getItemCount ? getItemCount(data) : data ? data.length : 0;
|
|
403
|
-
if (itemCount > 0) for (let index = 0; index < itemCount; index++) {
|
|
404
|
-
const item = getItem ? getItem(data, index) : data[index];
|
|
405
|
-
const key = keyExtractor ? keyExtractor(item, index) : String(index);
|
|
406
|
-
children.push(React.createElement(React.Fragment, { key }, renderItem({
|
|
407
|
-
item,
|
|
408
|
-
index,
|
|
409
|
-
separators: {}
|
|
410
|
-
})));
|
|
411
|
-
}
|
|
412
|
-
else if (ListEmptyComponent) children.push(React.createElement("VirtualizedList-Empty", { key: "__empty" }, typeof ListEmptyComponent === "function" ? React.createElement(ListEmptyComponent) : ListEmptyComponent));
|
|
413
|
-
if (ListFooterComponent) children.push(React.createElement("VirtualizedList-Footer", { key: "__footer" }, typeof ListFooterComponent === "function" ? React.createElement(ListFooterComponent) : ListFooterComponent));
|
|
414
|
-
return React.createElement("VirtualizedList", {
|
|
415
|
-
...rest,
|
|
416
|
-
ref
|
|
417
|
-
}, ...children);
|
|
418
|
-
});
|
|
419
|
-
VirtualizedList.displayName = "VirtualizedList";
|
|
420
|
-
return VirtualizedList;
|
|
421
|
-
}
|
|
422
|
-
//#endregion
|
|
423
215
|
//#region src/mocks/components/InputAccessoryView.ts
|
|
424
216
|
function createInputAccessoryViewMock() {
|
|
425
217
|
const InputAccessoryView = React.forwardRef((props, ref) => {
|
|
@@ -2311,6 +2103,16 @@ function createUseAnimatedValueMock() {
|
|
|
2311
2103
|
return new (createAnimatedMock()).Value(initialValue);
|
|
2312
2104
|
});
|
|
2313
2105
|
}
|
|
2106
|
+
function createUseAnimatedValueXYMock() {
|
|
2107
|
+
return vi.fn((initialValue) => {
|
|
2108
|
+
return new (createAnimatedMock()).ValueXY(initialValue);
|
|
2109
|
+
});
|
|
2110
|
+
}
|
|
2111
|
+
function createUseAnimatedColorMock() {
|
|
2112
|
+
return vi.fn((initialValue) => {
|
|
2113
|
+
return new (createAnimatedMock()).Color(initialValue);
|
|
2114
|
+
});
|
|
2115
|
+
}
|
|
2314
2116
|
function buildReactNativeMock(platform = "ios") {
|
|
2315
2117
|
const mock = {
|
|
2316
2118
|
View: createViewMock(),
|
|
@@ -2369,6 +2171,7 @@ function buildReactNativeMock(platform = "ios") {
|
|
|
2369
2171
|
UIManager: createUIManagerMock(),
|
|
2370
2172
|
NativeEventEmitter: createNativeEventEmitterMock(),
|
|
2371
2173
|
NativeAppEventEmitter: createDeviceEventEmitterMock(),
|
|
2174
|
+
EventEmitter: createNativeEventEmitterMock(),
|
|
2372
2175
|
NativeComponentRegistry: createNativeComponentRegistryMock(),
|
|
2373
2176
|
requireNativeComponent: createRequireNativeComponentMock(),
|
|
2374
2177
|
AppRegistry: createAppRegistryMock(),
|
|
@@ -2381,6 +2184,8 @@ function buildReactNativeMock(platform = "ios") {
|
|
|
2381
2184
|
Settings: createSettingsMock(),
|
|
2382
2185
|
DeviceInfo: createDeviceInfoMock(),
|
|
2383
2186
|
useAnimatedValue: createUseAnimatedValueMock(),
|
|
2187
|
+
useAnimatedValueXY: createUseAnimatedValueXYMock(),
|
|
2188
|
+
useAnimatedColor: createUseAnimatedColorMock(),
|
|
2384
2189
|
RootTagContext: React.createContext(null),
|
|
2385
2190
|
ReactNativeVersion: {
|
|
2386
2191
|
major: 0,
|
|
@@ -114,7 +114,9 @@ no-op under the shim (use `test.testTimeout` in config or per-test `{ timeout }`
|
|
|
114
114
|
2. Delete manual third-party native-lib mocks and `@react-native/jest-preset` (2c, 2e).
|
|
115
115
|
3. Convert any **top-level** `jest.mock(...)` to `vi.mock(...)`; leave runtime `jest.*` as-is (2a).
|
|
116
116
|
4. Run `vitest run -u` once to re-record snapshots (2d), then `vitest run` to confirm green.
|
|
117
|
-
5. Triage remaining failures — usually a missing query update or a suite-specific mock.
|
|
117
|
+
5. Triage remaining failures — usually a missing query update or a suite-specific mock. For runtime
|
|
118
|
+
issues (large-suite memory limits, error-boundary console noise, overriding a preset's mock), see
|
|
119
|
+
the [Troubleshooting](../README.md#troubleshooting) section.
|
|
118
120
|
|
|
119
121
|
## 4. What "done" looks like
|
|
120
122
|
|