This repository has been archived by the owner on Dec 21, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsetup-tests.js
63 lines (49 loc) · 1.67 KB
/
setup-tests.js
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
import "@testing-library/jest-native/extend-expect";
import MockAsyncStorage from "mock-async-storage";
const mockImpl = new MockAsyncStorage();
jest.mock("@react-native-async-storage/async-storage", () => mockImpl);
// include this line for mocking react-native-gesture-handler
import "react-native-gesture-handler/jestSetup";
// include this section and the NativeAnimatedHelper section for mocking react-native-reanimated
jest.mock("react-native-reanimated", () => {
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
Reanimated.default.call = () => {};
return Reanimated;
});
// Silence the warning: Animated: `useNativeDriver` is not supported because the native animated module is missing
jest.mock("react-native/Libraries/Animated/NativeAnimatedHelper");
// useNavigation mock
const mockedNavigate = jest.fn();
const mockedGoBack = jest.fn();
jest.mock("@react-navigation/native", () => {
const actualNav = jest.requireActual("@react-navigation/native");
return {
...actualNav,
useNavigation: () => ({
navigate: mockedNavigate,
goBack: mockedGoBack,
}),
};
});
require("@shopify/flash-list/jestSetup");
// i18n setup
import i18n from "i18next";
import { initReactI18next } from "react-i18next";
i18n.use(initReactI18next).init({
resources: {},
lng: "en",
fallbackLng: "en",
interpolation: {
escapeValue: false,
},
});
// React native firebase
jest.mock('@react-native-firebase/crashlytics', () => {
return () => ({
log: jest.fn(),
recordError: jest.fn(),
// Any function you want to use or mock
});
});