Repository navigation
Expand file tree
/
Copy pathjest.setup.js
More file actions
63 lines (56 loc) · 1.7 KB
/
Copy pathjest.setup.js
File metadata and controls
63 lines (56 loc) · 1.7 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
// Mock Expo modules
jest.mock('expo-router', () => ({
useRouter: () => ({
push: jest.fn(),
replace: jest.fn(),
back: jest.fn(),
}),
useLocalSearchParams: () => ({}),
}));
jest.mock('expo-crypto', () => ({
randomUUID: jest.fn(() => 'test-uuid-1234'),
}));
jest.mock('expo-haptics', () => ({
ImpactFeedbackStyle: {},
NotificationFeedbackType: {},
impactAsync: jest.fn(),
notificationAsync: jest.fn(),
selectionAsync: jest.fn(),
}));
jest.mock('expo-file-system', () => ({
documentDirectory: 'file:///test-directory/',
readAsStringAsync: jest.fn(() => Promise.resolve('base64-content')),
writeAsStringAsync: jest.fn(),
deleteAsync: jest.fn(),
getInfoAsync: jest.fn(() => Promise.resolve({ exists: true })),
makeDirectoryAsync: jest.fn(),
}));
jest.mock('expo-camera', () => ({
Camera: {
Constants: {
Type: { back: 'back', front: 'front' },
},
},
}));
jest.mock('@react-native-async-storage/async-storage', () =>
require('@react-native-async-storage/async-storage/jest/async-storage-mock')
);
// Mock Supabase if used directly (though we are testing offline-first mostly)
jest.mock('@supabase/supabase-js', () => ({
createClient: jest.fn(() => ({
auth: {
getSession: jest.fn(() => Promise.resolve({ data: { session: null }, error: null })),
onAuthStateChange: jest.fn(() => ({ data: { subscription: { unsubscribe: jest.fn() } } })),
},
from: jest.fn(() => ({
select: jest.fn(() => ({
eq: jest.fn(() => ({
single: jest.fn(),
order: jest.fn(),
})),
})),
})),
})),
}));
// Mock global useStore to avoid persistent state issues if needed
// But usually we mock it per test file if we want to isolate