jellyfin-expo/jest.setup.js

46 lines
1.6 KiB
JavaScript
Raw Normal View History

2021-02-23 05:32:47 +00:00
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
2021-10-07 05:06:01 +00:00
/* Fetch and AbortController Mocks */
2021-10-07 05:06:01 +00:00
import { enableFetchMocks } from 'jest-fetch-mock';
2021-10-08 04:51:51 +00:00
import { AbortController } from 'node-abort-controller';
2021-10-07 05:06:01 +00:00
2022-03-23 15:54:02 +00:00
// DOMException is not polyfilled in released version of jest-fetch-mock
// refs: https://github.com/jefflau/jest-fetch-mock/pull/160
if (typeof DOMException === 'undefined') {
global.DOMException = require('domexception');
}
2021-02-23 05:32:47 +00:00
global.AbortController = AbortController;
enableFetchMocks();
/* React Navigation Mocks */
import 'react-native-gesture-handler/jestSetup';
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
2021-11-22 14:56:33 +00:00
Reanimated.default.call = () => { /* no-op */ };
return Reanimated;
});
// Silence the warning: Animated: `useNativeDriver` is not supported because the native animated module is missing
jest.mock('react-native/Libraries/Animated/NativeAnimatedHelper');
// Workaround for process failing: https://github.com/react-navigation/react-navigation/issues/9568
jest.mock('@react-navigation/native/lib/commonjs/useLinking.native', () => ({
default: () => ({ getInitialState: { then: jest.fn() } }),
__esModule: true
}));
2022-03-28 15:26:10 +00:00
/* Safe Area Context Mocks */
import mockSafeAreaContext from 'react-native-safe-area-context/jest/mock';
jest.mock('react-native-safe-area-context', () => mockSafeAreaContext);