-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjest.setup.js
More file actions
71 lines (64 loc) · 1.71 KB
/
Copy pathjest.setup.js
File metadata and controls
71 lines (64 loc) · 1.71 KB
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
64
65
66
67
68
69
70
71
/* global jest */
import { mockAsyncStorage } from '@react-native-async-storage/async-storage/jest/async-storage-mock';
jest.mock('@react-native-async-storage/async-storage', () => mockAsyncStorage);
jest.mock('expo-font', () => ({
useFonts: () => [true, null],
isLoaded: jest.fn(() => true),
}));
jest.mock('expo-constants', () => ({
Constants: {
manifest: {
extra: {
apiUrl: 'https://mock-api-url.com',
},
},
},
}));
jest.mock('expo-router', () => ({
useRouter: () => ({
push: jest.fn(),
replace: jest.fn(),
back: jest.fn(),
}),
useLocalSearchParams: jest.fn().mockReturnValue({}),
Stack: {
Screen: jest.fn(),
},
useSegments: jest.fn().mockReturnValue([]),
}));
jest.mock('@tanstack/react-query', () => ({
...jest.requireActual('@tanstack/react-query'),
useQueryClient: jest.fn().mockReturnValue({
setQueryData: jest.fn(),
invalidateQueries: jest.fn(),
}),
useQuery: jest.fn().mockReturnValue({
data: undefined,
isLoading: false,
error: null,
refetch: jest.fn(),
}),
useMutation: jest.fn().mockReturnValue({
mutate: jest.fn(),
isPending: false,
error: null,
}),
}));
global.__reanimatedWorkletInit = jest.fn();
jest.mock('react-native-reanimated', () =>
require('react-native-reanimated/mock')
);
const originalConsoleError = console.error;
console.error = (...args) => {
if (
typeof args[0] === 'string' &&
(args[0].includes(
'Warning: The current testing environment is not configured to support act'
) ||
args[0].includes('Warning: You are importing createBottomTabNavigator') ||
args[0].includes('Warning: React.createFactory()'))
) {
return;
}
originalConsoleError(...args);
};