-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjest.setup.js
40 lines (37 loc) · 1017 Bytes
/
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
// Mock navigation
jest.mock("@react-navigation/native", () => {
const actualNav = jest.requireActual("@react-navigation/native");
return {
...actualNav,
useNavigation: () => ({
navigate: jest.fn(),
replace: jest.fn(),
}),
};
});
// Mock NetInfo
jest.mock("@react-native-community/netinfo", () => ({
addEventListener: jest.fn(() => jest.fn()),
fetch: jest.fn(() =>
Promise.resolve({ isConnected: true, isInternetReachable: true }),
),
}));
// Mock safe area context
jest.mock("react-native-safe-area-context", () => {
const inset = {
top: 0,
right: 0,
bottom: 0,
left: 0,
};
return {
SafeAreaProvider: jest.fn(({ children }) => children),
SafeAreaView: jest.fn(({ children }) => children),
useSafeAreaInsets: jest.fn(() => inset),
};
});
// Mock react-native-responsive-screen
jest.mock("react-native-responsive-screen", () => ({
widthPercentageToDP: jest.fn((width) => width),
heightPercentageToDP: jest.fn((height) => height),
}));