-
Notifications
You must be signed in to change notification settings - Fork 0
/
jest_test_setup.tsx
68 lines (57 loc) · 1.76 KB
/
jest_test_setup.tsx
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
/* eslint-disable no-undef */
/* eslint-disable import/order */
// @ts-nocheck
import 'react-native';
// Ignore React Web errors when using React Native
const originalConsoleError = console.error;
console.error = (message: string) => {
if (message.startsWith('Warning:')) {
return;
}
originalConsoleError(message);
};
import {NativeModules} from 'react-native';
NativeModules.ImageCropPicker = {
openPicker: jest.fn(),
openCamera: jest.fn(),
openCropper: jest.fn(),
clean: jest.fn(),
cleanSingle: jest.fn(),
};
import mockAsyncStorage from '@react-native-community/async-storage/jest/async-storage-mock';
import {
resetMockNavigation,
setupMockNavigation,
} from './__tests__/utils/NavigationMocking';
jest.mock('@react-native-community/async-storage', () => mockAsyncStorage);
// https://github.com/facebook/react-native/issues/27721
jest.mock(
'react-native/Libraries/Components/Touchable/TouchableOpacity',
() => 'TouchableOpacity',
);
jest.mock(
'react-native/Libraries/Components/TextInput/TextInput',
() => 'TextInput',
);
// https://github.com/software-mansion/react-native-reanimated/issues/205#issuecomment-596119975
jest.mock('react-native-reanimated', () =>
jest.requireActual('./node_modules/react-native-reanimated/mock'),
);
jest.mock('react-native/Libraries/EventEmitter/NativeEventEmitter');
jest.mock('react-native-fs', () => {
return {
stat: jest.fn(),
readFile: jest.fn(),
read: jest.fn(),
TemporaryDirectoryPath: jest.fn(),
};
});
global.__reanimatedWorkletInit = jest.fn();
jest.mock('react-native-keyboard-aware-scroll-view', () => {
const KeyboardAwareScrollView = ({children}) => children;
return {KeyboardAwareScrollView};
});
setupMockNavigation();
global.beforeEach(() => {
resetMockNavigation();
});