vitest-native 0.7.0 → 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 +41 -0
- package/README.md +17 -13
- package/dist/{index-DbfKy_bm.d.mts → index-YjjYELG7.d.cts} +13 -2
- package/dist/{index-BgzErxHj.d.cts → index-vlK4zxuK.d.mts} +11 -4
- package/dist/index.cjs +4 -4
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +4 -4
- package/dist/native/compile-cache.mjs +40 -0
- package/dist/native/hooks.mjs +1 -1
- package/dist/native/loader.mjs +1 -1
- package/dist/native/setup.mjs +30 -0
- 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-BFuAMwYQ.mjs → presets-23FJ76O4.mjs} +634 -1
- package/dist/{presets-BTG8fiNF.cjs → presets-7eMfp7o2.cjs} +705 -0
- 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 +11 -219
- package/dist/setup.mjs +2 -210
- package/package.json +8 -4
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) => {
|
|
@@ -2325,18 +2117,18 @@ function createUseAnimatedColorMock() {
|
|
|
2325
2117
|
}
|
|
2326
2118
|
function buildReactNativeMock(platform = "ios") {
|
|
2327
2119
|
const mock = {
|
|
2328
|
-
View: createViewMock(),
|
|
2120
|
+
View: require_presets.createViewMock(),
|
|
2329
2121
|
Text: createTextMock(),
|
|
2330
2122
|
Image: createImageMock(),
|
|
2331
|
-
TextInput: createTextInputMock(),
|
|
2332
|
-
ScrollView: createScrollViewMock(),
|
|
2333
|
-
FlatList: createFlatListMock(),
|
|
2334
|
-
SectionList: createSectionListMock(),
|
|
2123
|
+
TextInput: require_presets.createTextInputMock(),
|
|
2124
|
+
ScrollView: require_presets.createScrollViewMock(),
|
|
2125
|
+
FlatList: require_presets.createFlatListMock(),
|
|
2126
|
+
SectionList: require_presets.createSectionListMock(),
|
|
2335
2127
|
Modal: createModalMock(),
|
|
2336
2128
|
Pressable: require_presets.createPressableMock(),
|
|
2337
|
-
TouchableOpacity: createTouchableOpacityMock(),
|
|
2338
|
-
TouchableHighlight: createTouchableHighlightMock(),
|
|
2339
|
-
TouchableWithoutFeedback: createTouchableWithoutFeedbackMock(),
|
|
2129
|
+
TouchableOpacity: require_presets.createTouchableOpacityMock(),
|
|
2130
|
+
TouchableHighlight: require_presets.createTouchableHighlightMock(),
|
|
2131
|
+
TouchableWithoutFeedback: require_presets.createTouchableWithoutFeedbackMock(),
|
|
2340
2132
|
TouchableNativeFeedback: createTouchableNativeFeedbackMock(),
|
|
2341
2133
|
ActivityIndicator: createActivityIndicatorMock(),
|
|
2342
2134
|
Button: createButtonMock(),
|
|
@@ -2346,7 +2138,7 @@ function buildReactNativeMock(platform = "ios") {
|
|
|
2346
2138
|
SafeAreaView: createSafeAreaViewMock(),
|
|
2347
2139
|
KeyboardAvoidingView: createKeyboardAvoidingViewMock(),
|
|
2348
2140
|
ImageBackground: createImageBackgroundMock(),
|
|
2349
|
-
VirtualizedList: createVirtualizedListMock(),
|
|
2141
|
+
VirtualizedList: require_presets.createVirtualizedListMock(),
|
|
2350
2142
|
InputAccessoryView: createInputAccessoryViewMock(),
|
|
2351
2143
|
DrawerLayoutAndroid: createDrawerLayoutAndroidMock(),
|
|
2352
2144
|
Platform: createPlatformMock(platform),
|
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) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitest-native",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Run real React Native tests under Vitest. One install, zero config.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -150,12 +150,14 @@
|
|
|
150
150
|
},
|
|
151
151
|
"devDependencies": {
|
|
152
152
|
"@babel/core": "^7.29.7",
|
|
153
|
+
"@gorhom/bottom-sheet": "5.2.14",
|
|
153
154
|
"@react-native-vector-icons/common": "13.0.1",
|
|
154
155
|
"@react-native-vector-icons/material-icons": "13.1.2",
|
|
155
156
|
"@react-native/babel-preset": "^0.85.3",
|
|
156
157
|
"@react-navigation/native": "7.2.5",
|
|
157
158
|
"@react-navigation/native-stack": "7.16.0",
|
|
158
|
-
"@
|
|
159
|
+
"@shopify/flash-list": "2.3.2",
|
|
160
|
+
"@testing-library/react-native": "14.0.0",
|
|
159
161
|
"@types/node": "25.3.5",
|
|
160
162
|
"@types/react": "19.2.14",
|
|
161
163
|
"@vitest/coverage-v8": "4.1.8",
|
|
@@ -164,12 +166,14 @@
|
|
|
164
166
|
"ext-platform-lib": "file:./tests-native/fixtures/ext-platform-lib",
|
|
165
167
|
"ext-rn-named-lib": "file:./tests-native/fixtures/ext-rn-named-lib",
|
|
166
168
|
"react": "^19.2.3",
|
|
167
|
-
"react-native": "^0.
|
|
169
|
+
"react-native": "^0.86.0",
|
|
168
170
|
"react-native-gesture-handler": "3.0.0",
|
|
171
|
+
"react-native-keyboard-controller": "1.21.11",
|
|
169
172
|
"react-native-reanimated": "4.3.1",
|
|
170
173
|
"react-native-safe-area-context": "5.8.0",
|
|
171
174
|
"react-native-worklets": "0.9.1",
|
|
172
175
|
"react-test-renderer": "^19.2.3",
|
|
176
|
+
"test-renderer": "^1.2.0",
|
|
173
177
|
"tsdown": "0.21.10",
|
|
174
178
|
"typescript": "6.0.3",
|
|
175
179
|
"vite": "^8.0.5",
|
|
@@ -195,7 +199,7 @@
|
|
|
195
199
|
"crosscheck": "node scripts/crosscheck.mjs"
|
|
196
200
|
},
|
|
197
201
|
"dependencies": {
|
|
198
|
-
"flow-remove-types": "^2.
|
|
202
|
+
"flow-remove-types": "^2.318.0",
|
|
199
203
|
"magic-string": "^0.30.21"
|
|
200
204
|
}
|
|
201
205
|
}
|