-
Notifications
You must be signed in to change notification settings - Fork 11
/
setup-jest.ts
39 lines (35 loc) · 939 Bytes
/
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
import 'jest-preset-angular/setup-jest';
// Fail tests when console throws an error
// https://github.com/facebook/jest/issues/6121#issuecomment-529591574
const error = global.console.error;
global.console.error = function (...args) {
error(...args);
throw new Error(...args);
};
Object.defineProperty(window, 'CSS', { value: null });
Object.defineProperty(window, 'getComputedStyle', {
value: () => {
return {
display: 'none',
appearance: ['-webkit-appearance'],
};
},
});
Object.defineProperty(document, 'doctype', {
value: '<!DOCTYPE html>',
});
Object.defineProperty(document.body.style, 'transform', {
value: () => {
return {
enumerable: true,
configurable: true,
};
},
});
export const localStorageMock = {
getItem: jest.fn(),
setItem: jest.fn(),
removeItem: jest.fn(),
clear: jest.fn(),
};
Object.defineProperty(window, 'localStorage', { value: localStorageMock });