forked from aruzikulov/platform-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjest-setup-file.specUtils.ts
28 lines (22 loc) · 1.31 KB
/
jest-setup-file.specUtils.ts
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
// eslint-disable-next-line import/no-unassigned-import
import "./app/polyfills";
// eslint-disable-next-line import/no-unassigned-import
import "react-native-gesture-handler/jestSetup.js";
jest.mock("react-native-reanimated", () => {
// eslint-disable-next-line @typescript-eslint/no-require-imports,@typescript-eslint/no-var-requires,@typescript-eslint/no-unsafe-assignment
const Reanimated = require("react-native-reanimated/mock");
// The mock for `call` immediately calls the callback which is incorrect
// So we override it with a no-op
// eslint-disable-next-line @typescript-eslint/no-empty-function,@typescript-eslint/no-unsafe-member-access
Reanimated.default.call = () => {};
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return Reanimated;
});
// Silence the warning: Animated: `useNativeDriver` is not supported because the native animated module is missing
jest.mock("react-native/Libraries/Animated/src/NativeAnimatedHelper");
// Provide a custom request animation frame that's pushing callback with some small delay
// see https://www.benjaminjohnson.me/blog/testing-animations-in-react-native/
// eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/no-unsafe-member-access
(global as any).requestAnimationFrame = (cb: () => void) => {
setTimeout(cb, 1);
};