-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathtest-setup.ts
More file actions
27 lines (24 loc) · 857 Bytes
/
Copy pathtest-setup.ts
File metadata and controls
27 lines (24 loc) · 857 Bytes
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
import { Window } from "happy-dom";
const w = new Window();
function defineGlobal(name: string, value: unknown) {
Object.defineProperty(globalThis, name, {
value,
writable: true,
configurable: true,
});
}
defineGlobal("window", w);
defineGlobal("document", w.document);
defineGlobal("navigator", w.navigator);
defineGlobal("HTMLElement", w.HTMLElement);
defineGlobal("SVGElement", w.SVGElement);
defineGlobal("Node", w.Node);
defineGlobal("Text", w.Text);
defineGlobal("Comment", w.Comment);
defineGlobal("DocumentFragment", w.DocumentFragment);
defineGlobal("Element", w.Element);
defineGlobal("Event", w.Event);
defineGlobal("CustomEvent", w.CustomEvent);
defineGlobal("MutationObserver", w.MutationObserver);
defineGlobal("requestAnimationFrame", w.requestAnimationFrame);
defineGlobal("cancelAnimationFrame", w.cancelAnimationFrame);