-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjest.setup.js
37 lines (29 loc) · 1.27 KB
/
jest.setup.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
import '@testing-library/jest-native/extend-expect';
import { jest, beforeAll, afterEach, afterAll } from '@jest/globals';
import { server } from './src/api/mocks/server';
// surpressing warning resulted by useLinking due to usage of NavigationContainer
jest.mock('@react-navigation/native/lib/commonjs/useLinking.native', () => ({
default: () => ({ getInitialState: { then: () => null } }),
__esModule: true,
}));
global.fetch = require('node-fetch');
// Establish API mocking before all tests.
beforeAll(() => {
server.listen();
jest.useFakeTimers();
});
// Reset any request handlers that we may add during the tests,
// so they don't affect other tests.
afterEach(() => server.resetHandlers());
// Clean up after the tests are finished.
afterAll(() => server.close());
// surpressing Animated: `useNativeDriver` is not supported warning
jest.mock('react-native/Libraries/Animated/NativeAnimatedHelper');
// 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;
});