-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathjest-setup.ts
47 lines (43 loc) · 1.18 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
39
40
41
42
43
44
45
46
47
import '@testing-library/jest-dom';
import i18n from 'i18next';
import { initReactI18next } from 'react-i18next';
import baseZhCN from './packages/base/src/locale/zh-CN';
import sqleZhCN from './packages/sqle/src/locale/zh-CN';
import commonZhCN from './packages/shared/lib/locale/zh-CN';
import Adapter from '@cfaester/enzyme-adapter-react-18';
import * as Enzyme from 'enzyme';
import 'jest-canvas-mock';
jest.mock('rehype-sanitize', () => () => jest.fn());
Enzyme.configure({ adapter: new Adapter() });
Object.defineProperty(global, 'matchMedia', {
writable: true,
value: (query: any) => {
return {
matches: false,
media: query,
onchange: null,
addListener: jest.fn(), // deprecated
removeListener: jest.fn(), // deprecated
addEventListener: jest.fn(),
removeEventListener: jest.fn(),
dispatchEvent: jest.fn()
};
}
});
i18n.use(initReactI18next).init({
resources: {
'zh-CN': {
translation: {
...baseZhCN.translation,
...sqleZhCN.translation,
...commonZhCN.translation
}
}
},
lng: 'zh-CN',
fallbackLng: 'zh-CN',
interpolation: {
escapeValue: false
}
});
jest.setTimeout(60 * 1000);