This repository has been archived by the owner on Jun 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjestSetupFile.ts
151 lines (133 loc) · 3.62 KB
/
jestSetupFile.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
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
import { NativeModules } from "react-native";
import "@testing-library/jest-dom";
import mockRNDeviceInfo from "react-native-device-info/jest/react-native-device-info-mock";
/**
* Mock react-native-config (ENVS)
*/
jest.mock("react-native-config", () => ({
// ...jest.requireActual('react-native-config-node'),
// Override env variables for testing below
// No base URL to prevent actual API calls
// Targeting axios calls when mocking only requires endpoint
FAKE_PERSONAL_NUMBER: "201111111111",
FAKE_TOKEN:
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",
MITTHELSINGBORG_IO: "https://example.com",
MITTHELSINGBORG_IO_APIKEY: "12345",
}));
/**
* Async Storage
*/
jest.mock("@react-native-community/async-storage", () =>
jest.requireActual(
"@react-native-community/async-storage/jest/async-storage-mock"
)
);
/**
* Mock NativeAnimatedHelper
*/
jest.mock("react-native/Libraries/Animated/NativeAnimatedHelper");
/**
* Mock rn-fetch-blob
*/
jest.mock("react-native-blob-util", () => ({
DocumentDir: () => true,
}));
/*
* Added to make jest run because of the following issue:
* https://github.com/callstack/react-native-testing-library/issues/658
*/
jest.mock("react-native/Libraries/LogBox/LogBox");
/**
* Mock react-native-fs
*/
jest.mock("react-native-fs", () => ({
mkdir: jest.fn(),
moveFile: jest.fn(),
copyFile: jest.fn(),
pathForBundle: jest.fn(),
pathForGroup: jest.fn(),
getFSInfo: jest.fn(),
getAllExternalFilesDirs: jest.fn(),
unlink: jest.fn(),
exists: jest.fn(),
stopDownload: jest.fn(),
resumeDownload: jest.fn(),
isResumable: jest.fn(),
stopUpload: jest.fn(),
completeHandlerIOS: jest.fn(),
readDir: jest.fn(),
readDirAssets: jest.fn(),
existsAssets: jest.fn(),
readdir: jest.fn(),
setReadable: jest.fn(),
stat: jest.fn(),
readFile: jest.fn(),
read: jest.fn(),
readFileAssets: jest.fn(),
hash: jest.fn(),
copyFileAssets: jest.fn(),
copyFileAssetsIOS: jest.fn(),
copyAssetsVideoIOS: jest.fn(),
writeFile: jest.fn(),
appendFile: jest.fn(),
write: jest.fn(),
downloadFile: jest.fn(),
uploadFiles: jest.fn(),
touch: jest.fn(),
MainBundlePath: jest.fn(),
CachesDirectoryPath: jest.fn(),
DocumentDirectoryPath: jest.fn(),
ExternalDirectoryPath: jest.fn(),
ExternalStorageDirectoryPath: jest.fn(),
TemporaryDirectoryPath: jest.fn(),
LibraryDirectoryPath: jest.fn(),
PicturesDirectoryPath: jest.fn(),
}));
/**
* Mock storybook
*/
jest.mock("@storybook/react-native", () => ({
getStorybookUI: jest.fn(),
addDecorator: jest.fn(),
configure: jest.fn(),
}));
/**
* Mock react-native-background-timer
*/
jest.mock("react-native-background-timer", () => true);
/**
* Mock react-native-document-picker
*/
jest.mock("react-native-document-picker", () => ({ default: jest.fn() }));
/**
* Mock react-native-image-crop-picker
*/
jest.mock("react-native-image-crop-picker", () => ({
openPicker: jest.fn(),
openCamera: jest.fn(),
}));
/**
* Mock react-native datetimepicker
*/
NativeModules.RNDateTimePickerManager = {};
NativeModules.RNDateTimePickerManager.getDefaultDisplayValue = jest.fn(() =>
Promise.resolve({
determinedDisplayValue: "spinner",
})
);
/**
* Mock @notifee/react-native native module
*/
NativeModules.NotifeeApiModule = {
addListener: jest.fn(),
};
jest.mock("react-native-device-info", () => ({
...mockRNDeviceInfo,
getVersion: () => "1.2.3",
getBuildNumber: () => "1337",
}));
jest.mock("@sentry/react-native");
jest.mock("@react-native-clipboard/clipboard", () => ({
setString: jest.fn(),
}));