-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathjest.setup.js
More file actions
93 lines (86 loc) · 2.12 KB
/
Copy pathjest.setup.js
File metadata and controls
93 lines (86 loc) · 2.12 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
92
93
try {
require("react-native-gesture-handler/jestSetup");
} catch (e) {
}
jest.mock("react-native-reanimated", () => {
const View = require("react-native").View;
return {
default: {
Value: jest.fn(() => ({ setValue: jest.fn() })),
event: jest.fn(),
add: jest.fn(),
eq: jest.fn(),
set: jest.fn(),
cond: jest.fn(),
interpolate: jest.fn(),
View: View,
Extrapolate: { EXTEND: "extend" },
Transition: {
Together: "Together",
OutIn: "OutIn",
InOut: "InOut",
},
},
};
});
jest.mock("expo-router", () => ({
router: {
replace: jest.fn(),
push: jest.fn(),
back: jest.fn(),
},
useRouter: () => ({
replace: jest.fn(),
push: jest.fn(),
back: jest.fn(),
}),
useLocalSearchParams: jest.fn(() => ({})),
usePathname: jest.fn(() => "/"),
Link: ({ children, href, ...props }) => {
const React = require("react");
const { TouchableOpacity, Text } = require("react-native");
return React.createElement(
TouchableOpacity,
{ ...props, testID: `link-${href}` },
children
);
},
}));
jest.mock("expo-secure-store", () => ({
getItemAsync: jest.fn(),
setItemAsync: jest.fn(),
deleteItemAsync: jest.fn(),
}));
jest.mock("@/components/Icon", () => {
const React = require("react");
const { View } = require("react-native");
return {
Icon: ({ name, size, color, style, ...props }) =>
React.createElement(View, {
...props,
style,
testID: `icon-${name}`
}),
};
});
jest.mock("@/components/SpinLoading", () => {
const React = require("react");
const { Text, View } = require("react-native");
return {
SpinLoading: ({ message = "Carregando..." }) =>
React.createElement(View, { testID: "spin-loading" },
React.createElement(Text, {}, message)
),
};
});
const originalError = console.error;
global.console.error = (...args) => {
if (
typeof args[0] === 'string' &&
(args[0].includes('Warning: An update to') ||
args[0].includes('not wrapped in act'))
) {
return;
}
originalError.call(console, ...args);
};