-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathjest.setup.ts
More file actions
30 lines (27 loc) · 969 Bytes
/
jest.setup.ts
File metadata and controls
30 lines (27 loc) · 969 Bytes
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
import { jest } from '@jest/globals';
import { createMockFetch } from './__mocks__/MockNetworkResponses';
jest.mock('react-native-gesture-handler', () => {
const View = require('react-native').View;
return {
Gesture: {
Pan: jest.fn().mockReturnValue({
onStart: jest.fn().mockReturnThis(),
onUpdate: jest.fn().mockReturnThis(),
onEnd: jest.fn().mockReturnThis(),
runOnJS: jest.fn().mockReturnThis(),
}),
},
GestureDetector: ({ children }: { children: React.ReactNode }) =>
children || View,
GestureHandlerRootView: ({ children }: { children: React.ReactNode }) =>
children || View,
};
});
// Silence debug logs
jest.mock('./src/utils/Debug.ts', () => ({
debugLog: jest.fn(),
debugError: jest.fn(),
}));
// Mock fetch at the network boundary instead of mocking services
// This allows real service code to run in tests
jest.spyOn(global, 'fetch').mockImplementation(createMockFetch());