-
Notifications
You must be signed in to change notification settings - Fork 2
/
jestSetup.js
51 lines (43 loc) · 1.66 KB
/
jestSetup.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
/* globals jest, NativeModules */
/**
* Set up of the testing environment
*/
import nodeFetch from "node-fetch";
import { NativeModules } from "react-native";
// eslint-disable-next-line functional/immutable-data
NativeModules.RNGestureHandlerModule = {
attachGestureHandler: jest.fn(),
createGestureHandler: jest.fn(),
dropGestureHandler: jest.fn(),
updateGestureHandler: jest.fn(),
forceTouchAvailable: jest.fn(),
State: {},
Directions: {}
};
/**
* adds as for documentation suggestion
* https://docs.swmansion.com/react-native-reanimated/docs/1.x.x/getting_started/#testing
*/
jest.mock("react-native-reanimated", () => {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const Reanimated = require("react-native-reanimated/mock");
// The mock misses the `addWhitelistedUIProps` implementation
// So we override it with a no-op
// eslint-disable-next-line functional/immutable-data,@typescript-eslint/no-empty-function
Reanimated.default.addWhitelistedUIProps = () => {};
return Reanimated;
});
// eslint-disable-next-line functional/immutable-data
NativeModules.PlatformConstants = NativeModules.PlatformConstants || {
forceTouchAvailable: false
};
// eslint-disable-next-line @typescript-eslint/no-explicit-any,functional/immutable-data
global.fetch = nodeFetch;
// eslint-disable-next-line @typescript-eslint/no-explicit-any,functional/immutable-data
global.AbortController = AbortController;
// eslint-disable-next-line functional/immutable-data, no-underscore-dangle
global.__reanimatedWorkletInit = jest.fn();
jest.mock("./src/utils/accessibility", () => ({
useBoldTextEnabled: () => false,
getAccessibleAmountText: t => t
}));