-
-
Notifications
You must be signed in to change notification settings - Fork 116
Expand file tree
/
Copy pathsetupTests.js
More file actions
24 lines (22 loc) · 871 Bytes
/
Copy pathsetupTests.js
File metadata and controls
24 lines (22 loc) · 871 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
global.__DEV__ = true;
// useMemo requires a React renderer to be active. Tests call hooks bare (not
// inside a component), so replace useMemo with a simple synchronous factory
// call — memoization behaviour is irrelevant for unit tests.
jest.mock("react", () => ({
...jest.requireActual("react"),
useMemo: (fn) => fn(),
// Return the callback directly so hooks work when components are called as plain functions in tests
useCallback: (fn) => fn,
}));
jest.mock("react-native/Libraries/BatchedBridge/NativeModules", () => ({
RNHapticFeedback: {
trigger: jest.fn(),
stop: jest.fn(),
isSupported: jest.fn().mockReturnValue(true),
triggerPattern: jest.fn(),
playAHAP: jest.fn().mockResolvedValue(undefined),
getSystemHapticStatus: jest
.fn()
.mockResolvedValue({ vibrationEnabled: true, ringerMode: "normal" }),
},
}));