-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjest.setup.js
More file actions
51 lines (48 loc) · 1.31 KB
/
jest.setup.js
File metadata and controls
51 lines (48 loc) · 1.31 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
// for async + await
jest.useFakeTimers({ advanceTimers: true });
jest.mock('react-native', () => ({
AppState: {
currentState: 'active',
addEventListener: jest.fn(),
removeEventListener: jest.fn(),
},
Platform: {
OS: 'ios',
select: jest.fn((obj) => obj.ios || obj.default),
},
NativeModules: {
MetaRouterQueueStorage: {
exists: jest.fn(() => Promise.resolve(false)),
readSnapshot: jest.fn(() => Promise.resolve(null)),
writeSnapshot: jest.fn(() => Promise.resolve()),
deleteSnapshot: jest.fn(() => Promise.resolve()),
},
},
NativeEventEmitter: jest.fn().mockImplementation(() => ({
addListener: jest.fn(),
removeListener: jest.fn(),
})),
Dimensions: {
get: jest.fn().mockImplementation(() => ({
width: 390,
height: 844,
scale: 3,
fontScale: 1,
})),
},
PixelRatio: {
get: jest.fn(() => 3),
},
}));
jest.mock('@react-native-async-storage/async-storage', () => ({
__esModule: true,
default: {
getItem: jest.fn(() => Promise.resolve(null)),
setItem: jest.fn(() => Promise.resolve()),
removeItem: jest.fn(() => Promise.resolve()),
clear: jest.fn(() => Promise.resolve()),
},
}));
// Suppress console.warn and console.error in tests to keep output clean
console.warn = jest.fn();
console.error = jest.fn();