-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjest.setup.js
More file actions
47 lines (43 loc) · 1.41 KB
/
jest.setup.js
File metadata and controls
47 lines (43 loc) · 1.41 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
// Suppress console warnings for icon libraries in tests
const originalWarn = console.warn;
beforeAll(() => {
console.warn = (...args) => {
const message = args[0];
if (
typeof message === 'string' &&
(message.includes('Tried to use the icon') ||
message.includes('react-native-paper') ||
message.includes('icon libraries are installed'))
) {
return; // Suppress icon-related warnings
}
originalWarn(...args);
};
});
afterAll(() => {
console.warn = originalWarn;
});
// Mock AsyncStorage
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()),
getAllKeys: jest.fn(() => Promise.resolve([])),
multiGet: jest.fn(() => Promise.resolve([])),
multiSet: jest.fn(() => Promise.resolve()),
multiRemove: jest.fn(() => Promise.resolve()),
},
}));
// Mock react-native-safe-area-context
jest.mock('react-native-safe-area-context', () => {
const React = require('react');
const { View } = require('react-native');
return {
SafeAreaProvider: ({ children }) => children,
SafeAreaView: ({ children, ...props }) => <View {...props}>{children}</View>,
useSafeAreaInsets: () => ({ top: 0, bottom: 0, left: 0, right: 0 }),
};
});