forked from zed-io/kolektivo-wallet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jest_setup.ts
40 lines (32 loc) · 1.29 KB
/
jest_setup.ts
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
import '@testing-library/jest-native/extend-expect'
import 'react-native-svg-mock'
jest.useFakeTimers()
if (typeof window !== 'object') {
// @ts-ignore
global.window = global
// @ts-ignore
global.window.navigator = {}
}
// @ts-ignore
global.fetch = require('jest-fetch-mock')
// Mock LayoutAnimation as it's done not automatically
jest.mock('react-native/Libraries/LayoutAnimation/LayoutAnimation.js')
// Mock Animated Views this way otherwise we get a
// `JavaScript heap out of memory` error when a ref is set (?!)
// See https://github.com/callstack/react-native-testing-library/issues/539
jest.mock('react-native/Libraries/Animated/components/AnimatedView.js', () => 'View')
jest.mock('react-native/Libraries/Animated/components/AnimatedScrollView.js', () => 'RCTScrollView')
// Mock ToastAndroid as it's not done automatically
jest.mock('react-native/Libraries/Components/ToastAndroid/ToastAndroid.android.js', () => ({
show: jest.fn(),
showWithGravity: jest.fn(),
showWithGravityAndOffset: jest.fn(),
}))
// Mock Pixel Ratio to always return 1
jest.mock('react-native/Libraries/Utilities/PixelRatio.js', () => ({
roundToNearestPixel: jest.fn(() => 1),
getPixelSizeForLayoutSize: jest.fn(() => 1),
getFontScale: jest.fn(() => 1),
}))
// @ts-ignore
global.__reanimatedWorkletInit = jest.fn()