-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjest.setup.ts
38 lines (33 loc) · 1.27 KB
/
jest.setup.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
import 'core-js/features/array/flat-map';
import 'core-js/features/object/from-entries';
import 'reflect-metadata';
import '@testing-library/jest-native/extend-expect';
import './test-utils/extend-expect';
import { createConnection, getConnection } from 'typeorm';
import { config } from './src/database/config/config';
jest.mock('react-native/Libraries/Components/ScrollResponder');
jest.mock('react-native/Libraries/LayoutAnimation/LayoutAnimation');
jest.mock('react-native/Libraries/EventEmitter/NativeEventEmitter');
jest.mock('react-native/Libraries/Components/ToastAndroid/NativeToastAndroid');
jest.mock('react-native-gesture-handler/RNGestureHandlerModule');
const globalObject: any = global;
globalObject.__DEV__ = false;
globalObject.requestIdleCallback = jest.fn((callback: any) => callback());
globalObject.cancelIdleCallback = jest.fn();
globalObject.AbortController = jest.fn(() => ({
abort() {},
signal: {
addEventListener: jest.fn(),
removeEventListener: jest.fn()
},
}));
globalObject.fetch = jest.genMockFromModule('node-fetch');
beforeEach(async () => {
const connection = await createConnection(config.test);
await connection.runMigrations();
});
afterEach(async () => {
await getConnection().close();
jest.clearAllTimers();
jest.clearAllMocks();
});