-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathjest.setup.js
45 lines (35 loc) · 1.29 KB
/
jest.setup.js
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
import { NativeModules } from 'react-native';
import mockClipboard from '@react-native-clipboard/clipboard/jest/clipboard-mock.js';
jest.useFakeTimers({
legacyFakeTimers: true,
});
NativeModules.RNCNetInfo = {
getCurrentState: jest.fn(() => Promise.resolve()),
addListener: jest.fn(),
removeListeners: jest.fn(),
};
jest.mock('react-native-gesture-handler', () => ({
TouchableOpacity: jest.fn().mockImplementation(({ children }) => children),
Switch: jest.fn().mockImplementation(() => null),
}));
jest.mock('react-native/Libraries/Components/Touchable/TouchableOpacity', () => 'TouchableOpacity');
jest.mock('@react-navigation/stack', () => ({
useHeaderHeight: jest.fn(),
createStackNavigator: () => ({
Navigator: jest.fn(),
Screen: jest.fn(),
}),
}));
jest.mock('@react-navigation/compat', () => ({ withNavigation: (component) => component }));
jest.mock('react-native-keyboard-aware-scroll-view', () => ({
KeyboardAwareScrollView: jest.fn().mockImplementation(({ children }) => children),
}));
jest.mock('react-native-keychain', () => ({
setGenericPassword: jest.fn(),
getGenericPassword: jest.fn(),
resetGenericPassword: jest.fn(),
}));
jest.mock('@react-native-clipboard/clipboard', () => mockClipboard);
if (!global.setImmediate) {
global.setImmediate = setTimeout;
}