Repository navigation
Expand file tree
/
Copy pathjest.setup.js
More file actions
79 lines (74 loc) · 1.77 KB
/
Copy pathjest.setup.js
File metadata and controls
79 lines (74 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/**
* Jest setup file
* Runs before all tests
*/
// Mock Sentry
jest.mock('@sentry/react-native', () => ({
init: jest.fn(),
captureException: jest.fn(),
captureMessage: jest.fn(),
addBreadcrumb: jest.fn(),
setUser: jest.fn(),
setTag: jest.fn(),
}));
// Mock expo-haptics
jest.mock('expo-haptics', () => ({
impactAsync: jest.fn(),
notificationAsync: jest.fn(),
selectionAsync: jest.fn(),
ImpactFeedbackStyle: {
Light: 'light',
Medium: 'medium',
Heavy: 'heavy',
},
NotificationFeedbackType: {
Success: 'success',
Warning: 'warning',
Error: 'error',
},
}));
// Mock react-native-reanimated
jest.mock('react-native-reanimated', () => {
const Reanimated = require('react-native-reanimated/mock');
Reanimated.default.call = () => {};
return Reanimated;
});
// Mock react-native-gesture-handler
jest.mock('react-native-gesture-handler', () => {
const View = require('react-native/Libraries/Components/View/View');
return {
Swipeable: View,
DrawerLayout: View,
State: {},
ScrollView: View,
Slider: View,
Switch: View,
TextInput: View,
ToolbarAndroid: View,
ViewPagerAndroid: View,
DrawerLayoutAndroid: View,
WebView: View,
NativeViewGestureHandler: View,
TapGestureHandler: View,
FlingGestureHandler: View,
ForceTouchGestureHandler: View,
LongPressGestureHandler: View,
PanGestureHandler: View,
PinchGestureHandler: View,
RotationGestureHandler: View,
RawButton: View,
BaseButton: View,
RectButton: View,
BorderlessButton: View,
FlatList: View,
gestureHandlerRootHOC: jest.fn(),
Directions: {},
GestureHandlerRootView: View,
};
});
// Silence console warnings in tests
global.console = {
...console,
warn: jest.fn(),
error: jest.fn(),
};