-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathsetupTests.js
More file actions
38 lines (35 loc) · 1.07 KB
/
setupTests.js
File metadata and controls
38 lines (35 loc) · 1.07 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
// setupTests.js
import '@testing-library/jest-native/extend-expect'; // Provides useful matchers like toBeInTheDocument for React Native components
// Mock Firebase Auth globally for all tests
jest.mock('firebase/auth', () => ({
initializeAuth: jest.fn(),
getReactNativePersistence: jest.fn(() => jest.fn()),
}));
// Mock Expo Router globally for all tests
const mockRouter = {
push: jest.fn(),
replace: jest.fn(),
back: jest.fn(),
canGoBack: () => true,
};
jest.mock('expo-router', () => ({
useRouter: () => mockRouter,
useLocalSearchParams: () => ({}),
usePathname: () => '/',
useSegments: () => [],
useFocusEffect: jest.fn(),
useNavigation: () => ({
addListener: jest.fn(() => jest.fn()),
}),
Link: 'Link',
Redirect: 'Redirect',
Stack: { Screen: 'Screen', Protected: 'Protected' },
Tabs: { Screen: 'Screen' },
}));
// Mock @react-navigation/native (used by some screen components for useFocusEffect)
jest.mock('@react-navigation/native', () => ({
useFocusEffect: jest.fn(),
useNavigation: () => ({
addListener: jest.fn(() => jest.fn()),
}),
}));