-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjest.setup.js
More file actions
91 lines (76 loc) · 2.22 KB
/
Copy pathjest.setup.js
File metadata and controls
91 lines (76 loc) · 2.22 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// Jest setup file
// Note: @testing-library/react-native v12.4+ includes built-in matchers
// No need to import extend-expect separately
// Mock react-native-config
jest.mock('react-native-config', () => ({
default: {
TMDB_API_KEY: 'mock-api-key',
TMDB_BASE_URL: 'https://api.themoviedb.org/3',
TMDB_IMAGE_BASE_URL: 'https://image.tmdb.org/t/p',
ENV: 'test',
},
}));
// Mock react-native-fast-image
jest.mock('react-native-fast-image', () => {
const React = require('react');
const { Image } = require('react-native');
const FastImage = (props) => React.createElement(Image, props);
FastImage.resizeMode = {
contain: 'contain',
cover: 'cover',
stretch: 'stretch',
center: 'center',
};
FastImage.priority = {
low: 'low',
normal: 'normal',
high: 'high',
};
return FastImage;
});
// Mock @react-navigation/native
jest.mock('@react-navigation/native', () => {
const actualNav = jest.requireActual('@react-navigation/native');
return {
...actualNav,
useNavigation: () => ({
navigate: jest.fn(),
goBack: jest.fn(),
dispatch: jest.fn(),
}),
useRoute: () => ({
params: {},
}),
};
});
// Silence the warning: Animated: `useNativeDriver` is not supported
jest.mock('react-native/Libraries/Animated/NativeAnimatedHelper');
// Selectively silence known benign warnings to reduce test output noise
// Allow other console.error and console.warn to surface real issues
const originalError = console.error;
const originalWarn = console.warn;
console.error = (...args) => {
// Silence specific known benign errors
const message = args[0]?.toString() || '';
// Add patterns for known benign errors here
const benignPatterns = [
'Warning: ReactDOM.render',
'Warning: useLayoutEffect',
];
if (benignPatterns.some(pattern => message.includes(pattern))) {
return;
}
originalError(...args);
};
console.warn = (...args) => {
// Silence specific known benign warnings
const message = args[0]?.toString() || '';
// Add patterns for known benign warnings here
const benignPatterns = [
'Animated: `useNativeDriver`',
];
if (benignPatterns.some(pattern => message.includes(pattern))) {
return;
}
originalWarn(...args);
};