-
Notifications
You must be signed in to change notification settings - Fork 250
Expand file tree
/
Copy pathjest.setup.js
More file actions
58 lines (52 loc) · 1.7 KB
/
Copy pathjest.setup.js
File metadata and controls
58 lines (52 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
// Mock MMKV storage for tests
const mockStorageData = new Map()
global.__mockStorageData = mockStorageData // Expose for test manipulation
// Generate mock UUIDs
let uuidCounter = 0
const generateMockUuid = () => `mock-uuid-${++uuidCounter}`
jest.mock('./src/utils', () => {
return {
...jest.requireActual('./src/utils'),
uuid: () => generateMockUuid(),
storage: {
getString: jest.fn(key => global.__mockStorageData?.get(key)),
set: jest.fn((key, value) => global.__mockStorageData?.set(key, value)),
delete: jest.fn(key => global.__mockStorageData?.delete(key)),
contains: jest.fn(key => global.__mockStorageData?.has(key)),
getAllKeys: jest.fn(() => Array.from(global.__mockStorageData?.keys() || []))
}
}
})
// Mock LoggerService to avoid file system access in tests
jest.mock('./src/services/LoggerService', () => ({
loggerService: {
withContext: jest.fn(() => ({
info: jest.fn(),
error: jest.fn(),
warn: jest.fn(),
debug: jest.fn(),
verbose: jest.fn(),
silly: jest.fn()
})),
info: jest.fn(),
error: jest.fn(),
warn: jest.fn(),
debug: jest.fn(),
verbose: jest.fn(),
silly: jest.fn()
}
}))
// Mock React Native modules that might not be available in test environment
jest.mock('react-native/Libraries/EventEmitter/NativeEventEmitter')
// Mock expo modules that require native dependencies
jest.mock('expo-file-system', () => ({
documentDirectory: 'file:///mock/documents/',
cacheDirectory: 'file:///mock/cache/',
readAsStringAsync: jest.fn(),
writeAsStringAsync: jest.fn(),
deleteAsync: jest.fn(),
moveAsync: jest.fn(),
copyAsync: jest.fn()
}))
// Set up global test timeout
jest.setTimeout(10000)