-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjest.setup.js
More file actions
54 lines (46 loc) · 1.15 KB
/
Copy pathjest.setup.js
File metadata and controls
54 lines (46 loc) · 1.15 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
// Mock global variables that might be needed
global.__DEV__ = true;
// Skip mocking native module that might not be available
// jest.mock('react-native/Libraries/Animated/NativeAnimatedHelper');
// Setting longer timeout for CI environments
jest.setTimeout(15000);
// Make console output less noisy in tests
global.console = {
...console,
// Uncomment to silence certain console methods during tests
// log: jest.fn(),
// info: jest.fn(),
warn: jest.fn(),
error: jest.fn(),
};
// Mock fetch globally
global.fetch = jest.fn();
// Mock necessary modules
// These mocks are configured in package.json with moduleNameMapper
// Mock the expo-router navigation
jest.mock('expo-router', () => ({
router: {
push: jest.fn(),
replace: jest.fn(),
back: jest.fn(),
canGoBack: jest.fn(() => true),
},
useRouter: jest.fn(() => ({
push: jest.fn(),
replace: jest.fn(),
back: jest.fn(),
})),
}));
// Mock Expo Constants
jest.mock('expo-constants', () => ({
expoConfig: {
extra: {
buildNumber: "1",
},
sdkVersion: "52.0.37",
},
}));
// Reset all mocks after each test
afterEach(() => {
jest.clearAllMocks();
});