-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathjest.setup.js
51 lines (37 loc) · 1.6 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
require('jest-fetch-mock').enableMocks()
const mockRNGestureHandlerModule =
'react-native-gesture-handler/dist/src/__mocks__/RNGestureHandlerModule.js'
const mockRNCNetInfo = '@react-native-community/netinfo/jest/netinfo-mock.js'
jest.mock('react-native-gesture-handler', () => mockRNGestureHandlerModule)
jest.mock('@react-native-community/netinfo', () => mockRNCNetInfo)
jest.mock('react-native-webview', () => 'react-native-webview')
// Testing react-native-bootsplash requires mocking the native methods
jest.mock('react-native-bootsplash', () => ({
show: jest.fn().mockResolvedValueOnce(),
getVisibilityStatus: jest.fn().mockResolvedValue('hidden'),
}))
jest.mock('react-native-simple-toast', () => ({
LONG: jest.fn(),
SHORT: jest.fn(),
}))
jest.mock('react-native-reanimated', () => {
const Reanimated = require('react-native-reanimated/mock')
// The mock for `call` immediately calls the callback which is incorrect
// So we override it with a no-op
Reanimated.default.call = () => {}
return Reanimated
})
// Silence the warning:
// Animated: `useNativeDriver` is not supported because the native animated
// module is missing
jest.mock('react-native/Libraries/Animated/NativeAnimatedHelper')
// Fixes the warning:
// ref: https://github.com/callstack/react-native-testing-library/issues/329
jest.mock('react-native/Libraries/Components/Switch/Switch', () => {
const mockComponent = require('react-native/jest/mockComponent')
return {
default: mockComponent('react-native/Libraries/Components/Switch/Switch'),
}
})
// Silence console.log during tests
global.console.log = jest.fn()