-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathsetup.jest.ts
50 lines (39 loc) · 1.25 KB
/
setup.jest.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
48
49
50
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/
import '@testing-library/jest-dom/extend-expect';
import { configure } from '@testing-library/react';
import { setOSDHttp, setOSDSavedObjectsClient } from '../common/utils';
import { coreRefs } from '../public/framework/core_refs';
import { coreStartMock } from './__mocks__/coreMocks';
configure({ testIdAttribute: 'data-test-subj' });
window.URL.createObjectURL = () => '';
HTMLCanvasElement.prototype.getContext = () => '' as any;
window.IntersectionObserver = class IntersectionObserver {
constructor() {}
disconnect() {
return null;
}
observe() {
return null;
}
takeRecords() {
return null;
}
unobserve() {
return null;
}
} as any;
jest.mock('@elastic/eui/lib/components/form/form_row/make_id', () => () => 'random-id');
jest.mock('@elastic/eui/lib/services/accessibility/html_id_generator', () => ({
htmlIdGenerator: () => {
return () => 'random_html_id';
},
}));
jest.setTimeout(30000);
setOSDHttp(coreStartMock.http);
setOSDSavedObjectsClient(coreStartMock.savedObjects.client);
coreRefs.http = coreStartMock.http;
coreRefs.savedObjectsClient = coreStartMock.savedObjects.client;
coreRefs.toasts = coreStartMock.notifications.toasts;