-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjest.setup.js
More file actions
58 lines (51 loc) · 1.36 KB
/
jest.setup.js
File metadata and controls
58 lines (51 loc) · 1.36 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
// Jest setup file
// Mock Expo's import meta registry
global.__ExpoImportMetaRegistry = {
register: jest.fn(),
get: jest.fn(),
};
// Mock structuredClone if not available
if (typeof global.structuredClone === 'undefined') {
global.structuredClone = (obj) => JSON.parse(JSON.stringify(obj));
}
// Mock AsyncStorage
jest.mock('@react-native-async-storage/async-storage', () => ({
setItem: jest.fn(),
getItem: jest.fn(),
removeItem: jest.fn(),
clear: jest.fn(),
}));
// Mock Firebase
jest.mock('firebase/app', () => ({
initializeApp: jest.fn(),
}));
jest.mock('firebase/auth', () => ({
getAuth: jest.fn(),
signInWithEmailAndPassword: jest.fn(),
createUserWithEmailAndPassword: jest.fn(),
signOut: jest.fn(),
onAuthStateChanged: jest.fn(),
}));
jest.mock('firebase/firestore', () => ({
getFirestore: jest.fn(),
collection: jest.fn(),
doc: jest.fn(),
getDoc: jest.fn(),
getDocs: jest.fn(),
setDoc: jest.fn(),
updateDoc: jest.fn(),
deleteDoc: jest.fn(),
query: jest.fn(),
where: jest.fn(),
orderBy: jest.fn(),
onSnapshot: jest.fn(),
Timestamp: {
now: jest.fn(() => ({ seconds: Date.now() / 1000, nanoseconds: 0 })),
fromDate: jest.fn((date) => ({ seconds: date.getTime() / 1000, nanoseconds: 0 })),
},
}));
jest.mock('firebase/messaging', () => ({
getMessaging: jest.fn(),
getToken: jest.fn(),
onMessage: jest.fn(),
}));