Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
const jsdom = require("jsdom").jsdom;
const doc = jsdom(undefined, { url: "http://localhost" });
const jsdomWindow = doc.defaultView;
global.document = doc;
global.window = new Proxy(jsdomWindow, {
set(target, property, value) {
global[property] = value;
return value;
}
});
Object.keys(window).forEach(key => {
if (!global[key]) {
global[key] = window[key];
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.