-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathjest.setup.js
More file actions
65 lines (58 loc) · 1.53 KB
/
jest.setup.js
File metadata and controls
65 lines (58 loc) · 1.53 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
/**
* written by: Team QuickPay
* tested by: Team QuickPay
* debugged by: Team QuickPay
* Notes: Contributions were shared, see GitHub history for commit details.
* Unit Tests for UserSyncService
*/
/**
* Jest Setup File
*
* This file runs before all tests to set up the testing environment,
* mock dependencies, and configure global test utilities.
*/
// Mock Expo modules
jest.mock('expo-secure-store', () => ({
getItemAsync: jest.fn(),
setItemAsync: jest.fn(),
deleteItemAsync: jest.fn(),
}));
jest.mock('expo-linking', () => ({
createURL: jest.fn(),
addEventListener: jest.fn(),
removeEventListener: jest.fn(),
}));
jest.mock('expo-router', () => ({
useRouter: jest.fn(),
useSegments: jest.fn(),
router: {
push: jest.fn(),
replace: jest.fn(),
back: jest.fn(),
},
}));
// Mock Clerk authentication
jest.mock('@clerk/clerk-expo', () => ({
useUser: jest.fn(),
useAuth: jest.fn(),
useSignIn: jest.fn(),
useSignUp: jest.fn(),
ClerkProvider: ({ children }) => children,
}));
// Mock AsyncStorage
jest.mock('@react-native-async-storage/async-storage', () => ({
getItem: jest.fn(),
setItem: jest.fn(),
removeItem: jest.fn(),
clear: jest.fn(),
}));
// Silence console warnings during tests
global.console = {
...console,
warn: jest.fn(),
error: jest.fn(),
};
// Set up environment variables for tests
process.env.EXPO_PUBLIC_SUPABASE_URL = 'https://test.supabase.co';
process.env.EXPO_PUBLIC_SUPABASE_ANON_KEY = 'test-anon-key';
process.env.EXPO_PUBLIC_CLERK_PUBLISHABLE_KEY = 'test-clerk-key';