-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjest.setup.js
More file actions
103 lines (94 loc) · 2.41 KB
/
Copy pathjest.setup.js
File metadata and controls
103 lines (94 loc) · 2.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
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
94
95
96
97
98
99
100
101
102
103
// Mock expo modules
jest.mock("expo-router", () => ({
Stack: {
Screen: () => null,
},
useRouter: () => ({
push: jest.fn(),
replace: jest.fn(),
back: jest.fn(),
}),
useLocalSearchParams: () => ({}),
Link: ({ children }) => children,
}));
jest.mock("expo-status-bar", () => ({
StatusBar: () => null,
}));
jest.mock("@react-native-async-storage/async-storage", () =>
require("@react-native-async-storage/async-storage/jest/async-storage-mock")
);
// Mock wagmi
jest.mock("wagmi", () => ({
createConfig: jest.fn((config) => config),
http: jest.fn(() => ({})),
useAccount: () => ({
address: undefined,
isConnected: false,
}),
useBalance: () => ({
data: undefined,
}),
useChainId: () => 84532, // Base Sepolia
useConnect: () => ({
connectors: [],
connect: jest.fn(),
isPending: false,
}),
useDisconnect: () => ({
disconnect: jest.fn(),
}),
useSignMessage: () => ({
signMessage: jest.fn(),
isPending: false,
data: undefined,
reset: jest.fn(),
}),
useSendTransaction: () => ({
sendTransaction: jest.fn(),
isPending: false,
data: undefined,
reset: jest.fn(),
}),
useSwitchChain: () => ({
switchChain: jest.fn(),
isPending: false,
}),
WagmiProvider: ({ children }) => children,
}));
jest.mock("wagmi/chains", () => ({
baseSepolia: { id: 84532, name: "Base Sepolia" },
optimismSepolia: { id: 11155420, name: "OP Sepolia" },
}));
jest.mock("wagmi/connectors", () => ({
walletConnect: jest.fn(() => ({})),
}));
// Mock @tanstack/react-query
jest.mock("@tanstack/react-query", () => ({
QueryClient: jest.fn(() => ({})),
QueryClientProvider: ({ children }) => children,
}));
// Mock @formo/react-native-analytics
jest.mock("@formo/react-native-analytics", () => ({
FormoAnalyticsProvider: ({ children }) => children,
useFormo: () => ({
track: jest.fn(),
screen: jest.fn(),
identify: jest.fn(),
reset: jest.fn(),
hasOptedOutTracking: jest.fn(() => false),
optOutTracking: jest.fn(),
optInTracking: jest.fn(),
}),
}));
// Mock react-native-safe-area-context
jest.mock("react-native-safe-area-context", () => ({
SafeAreaProvider: ({ children }) => children,
SafeAreaView: ({ children }) => children,
useSafeAreaInsets: () => ({ top: 0, bottom: 0, left: 0, right: 0 }),
}));
// Silence console warnings in tests
global.console = {
...console,
warn: jest.fn(),
error: jest.fn(),
};