-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathjest.base.setup.ts
43 lines (36 loc) · 1.05 KB
/
jest.base.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
import "jest-preset-angular/setup-jest"; // commented out due to issue in latest jest-preset-angular
Error.stackTraceLimit = 2;
const CI = process.env["CI"] === "true";
/**
* GLOBAL MOCKS
*/
Object.defineProperty(window, "CSS", { value: null });
Object.defineProperty(document, "doctype", {
value: "<!DOCTYPE html>",
});
Object.defineProperty(window, "getComputedStyle", {
value: () => ({
display: "none",
appearance: ["-webkit-appearance"],
}),
});
Object.defineProperty(
window.navigator,
"userAgent",
((value) => ({
get() {
return value;
},
set(v: string) {
value = v;
},
}))(window.navigator["userAgent"]),
);
if (CI) {
const consoleMethods: string[] = ["trace", "debug", "warn", "log", "group", "groupCollapsed"];
consoleMethods.forEach((methodName: string) => {
jest.spyOn(global.console, methodName as any).mockImplementation(() => jest.fn());
});
}
// https://github.com/angular/angular/issues/20827#issuecomment-394487432
(window as any)["__zone_symbol__supportWaitUnResolvedChainedPromise"] = true;