forked from GetStream/stream-chat-react-native
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjest-setup.js
41 lines (38 loc) · 1.31 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
import { registerNativeHandlers } from './src/native';
// eslint-disable-next-line no-underscore-dangle
const _consoleE = console.error;
console.error = (e) => {
// For some reason following error gets rased from waitFor function.
// Source of the error is in react-test-renderer, although cause of the
// issue is unknown. Until we figure out the proper way to fix this issue,
// following hack should work. We just suppress this particular error.
// It should be safe since the error is only raised in dev environment
// https://github.com/facebook/react/blob/b683c07ccce340b9d687683d5dd7347a4c866787/packages/react-dom/src/test-utils/ReactTestUtilsAct.js#L121
if (e.indexOf('You called act(async () => ...) without await') === -1) {
_consoleE(e);
}
};
console.warn = () => {};
registerNativeHandlers({
BlurView: () => null,
compressImage: () => null,
deleteFile: () => null,
FlatList: () => null,
getLocalAssetUri: () => null,
getPhotos: () => null,
NetInfo: {
addEventListener: () => {},
fetch: () =>
new Promise((resolve) => {
resolve();
}),
},
pickDocument: () => null,
saveFile: () => null,
shareImage: () => null,
takePhoto: () => null,
triggerHaptic: () => null,
});
jest.mock('react-native-reanimated', () =>
require('react-native-reanimated/mock'),
);