-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathsetup-jest.ts
More file actions
57 lines (48 loc) · 1.69 KB
/
setup-jest.ts
File metadata and controls
57 lines (48 loc) · 1.69 KB
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
51
52
53
54
55
56
57
import { setupZoneTestEnv } from 'jest-preset-angular/setup-env/zone';
import '@angular/localize/init';
import './projects/app/src/polyfills';
import '@testing-library/jest-dom';
import { TextEncoder, TextDecoder } from 'util';
import failOnConsole from 'jest-fail-on-console';
setupZoneTestEnv();
// Error is thrown because the JSDOM version Jest uses does not support @layer css construct, ignore for now
const allowedErrors = ['Could not parse CSS stylesheet'];
failOnConsole({
silenceMessage: (msg) => allowedErrors.some(err => msg.includes(err)),
});
global.TextEncoder = TextEncoder;
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
global.TextDecoder = TextDecoder;
window.ResizeObserver =
window.ResizeObserver ||
jest.fn().mockImplementation(() => ({
disconnect: jest.fn(),
observe: jest.fn(),
unobserve: jest.fn(),
}));
window.IntersectionObserver =
window.IntersectionObserver ||
jest.fn().mockImplementation(() => ({
disconnect: jest.fn(),
observe: jest.fn(),
unobserve: jest.fn(),
}));
window.EventSource = window.EventSource || jest.fn().mockImplementation(() => ({
close: jest.fn(),
}));
Element.prototype.scrollTo = Element.prototype.scrollTo || (() => {});
jest.mock('jsts/org/locationtech/jts/io', () => ({
// eslint-disable-next-line @typescript-eslint/naming-convention
OL3Parser: class MockedParser {
public inject() {/*empty*/}
public read(input: any) { return input; }
public write(input: any) { return input; }
},
}));
jest.mock('jsts/org/locationtech/jts/operation/buffer', () => ({
// eslint-disable-next-line @typescript-eslint/naming-convention
BufferOp: {
bufferOp: (input: any) => input,
},
}));