|
| 1 | +// eslint-disable-next-line @typescript-eslint/ban-ts-comment |
| 2 | +// @ts-ignore |
| 3 | +import mockSafeAreaContext from "react-native-safe-area-context/jest/mock"; |
| 4 | + |
| 5 | +// SOURCE: https://stackoverflow.com/questions/66652403/jest-config-is-throwing-type-errorhandler-error-mixed-isfatal-boolean |
| 6 | + |
| 7 | +beforeAll(() => { |
| 8 | + // SOURCE: https://stackoverflow.com/questions/50793885/referenceerror-you-are-trying-to-import-a-file-after-the-jest-environment-has#50793993 |
| 9 | + jest.useFakeTimers(); |
| 10 | +}); |
| 11 | + |
| 12 | +// SOURCE: https://stackoverflow.com/questions/59587799/how-to-resolve-animated-usenativedriver-is-not-supported-because-the-native#59593847 |
| 13 | +jest.mock("react-native/Libraries/Animated/NativeAnimatedHelper"); |
| 14 | + |
| 15 | +jest.mock("react-native-reanimated", () => { |
| 16 | + const Reanimated = require("react-native-reanimated/mock"); |
| 17 | + |
| 18 | + Reanimated.default.call = () => null; |
| 19 | + |
| 20 | + Reanimated.useSharedValue = jest.fn; |
| 21 | + Reanimated.useAnimatedStyle = jest.fn; |
| 22 | + return Reanimated; |
| 23 | +}); |
| 24 | + |
| 25 | +jest.mock("react-native-gesture-handler", () => |
| 26 | + jest.requireActual("react-native-gesture-handler/jestSetup") |
| 27 | +); |
| 28 | + |
| 29 | +// jest.mock("@react-native-async-storage/async-storage", () => |
| 30 | +// require("@react-native-async-storage/async-storage/jest/async-storage-mock") |
| 31 | +// ); |
| 32 | + |
| 33 | +jest.mock("@react-navigation/native", () => ({ |
| 34 | + ...jest.requireActual("@react-navigation/native"), |
| 35 | + useNavigation: () => ({ |
| 36 | + navigate: jest.fn(), |
| 37 | + goBack: jest.fn(), |
| 38 | + }), |
| 39 | + useRoute: () => ({ |
| 40 | + params: { |
| 41 | + publicToken: "testToken", |
| 42 | + }, |
| 43 | + }), |
| 44 | +})); |
| 45 | + |
| 46 | +// SOURCE: https://github.com/th3rdwave/react-native-safe-area-context#testing |
| 47 | +jest.mock("react-native-safe-area-context", () => mockSafeAreaContext); |
0 commit comments