-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjest.setup.js
63 lines (49 loc) · 1.7 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/* eslint-disable no-undef -- jest is not defined and cannot be */
import * as ReactNative from 'react-native';
import mockAsyncStorage from '@react-native-async-storage/async-storage/jest/async-storage-mock';
import mockRNDeviceInfo from 'react-native-device-info/jest/react-native-device-info-mock';
afterEach(() => {
jest.clearAllMocks();
});
jest.useFakeTimers();
jest.doMock('react-native', () => Object.setPrototypeOf(
{
NativeModules: {
...ReactNative.NativeModules,
RNAppModule: {
addListener: jest.fn(),
removeListeners: jest.fn(),
eventsAddListener: jest.fn(),
eventsNotifyReady: jest.fn(),
},
},
TurboModuleRegistry: {
getEnforcing: () => ({
initialize: jest.fn(),
setRequestConfiguration: jest.fn(),
openAdInspector: jest.fn(),
openDebugMenu: jest.fn(),
}),
},
},
ReactNative,
));
jest.mock('react-native/Libraries/EventEmitter/NativeEventEmitter');
jest.mock('react-native/Libraries/Animated/NativeAnimatedHelper');
jest.mock('react-native-device-info', () => mockRNDeviceInfo);
jest.mock('@react-native-async-storage/async-storage', () => mockAsyncStorage);
jest.mock('react-native-linear-gradient', () => 'LinearGradient');
jest.mock('react-native-in-app-review', () => ({
RequestInAppReview: jest.fn(),
isAvailable: jest.fn(),
}));
jest.mock('react-native-sound', () => {
class SoundMock {}
SoundMock.prototype.setVolume = jest.fn();
SoundMock.prototype.setNumberOfLoops = jest.fn();
SoundMock.prototype.play = jest.fn();
SoundMock.prototype.stop = jest.fn();
SoundMock.setCategory = jest.fn();
return SoundMock;
});
jest.mock('react-native-json-tree', () => 'JSONTree');