-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsetupJest.ts
33 lines (30 loc) · 1.12 KB
/
setupJest.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
import '@testing-library/jest-native/extend-expect';
jest.mock('react-native/Libraries/Animated/src/NativeAnimatedHelper');
/**
* Fix RN 0.63.2 issue related to 'ExceptionsManager.handleException...'
* Related issue: https://github.com/facebook/react-native/issues/29849
* Related PR: https://github.com/facebook/react-native/pull/30027
* */
jest.mock('react-native/Libraries/LogBox/LogBox');
jest.mock('react-native/Libraries/LogBox/Data/LogBoxData', () => {
return {
withSubscription: () => {},
isLogBoxErrorMessage: () => true,
ExceptionsManager: {
handleException: (e: any) => {
console.error(e);
},
},
};
});
const FRAME_TIME = 10;
global.requestAnimationFrame = (cb) => {
// Default implementation of requestAnimationFrame calls setTimeout(cb, 0),
// which will result in a cascade of timers - this generally pisses off test runners
// like Jest who watch the number of timers created and assume an infinite recursion situation
// if the number gets too large.
//
// Setting the timeout simulates a frame every 1/100th of a second
setTimeout(cb, FRAME_TIME);
return 0;
};