// create jsdom environment
const { JSDOM } = require("jsdom");
const dom = new JSDOM(`<!DOCTYPE html>`, {
  url: "http://localhost",
});
const window = dom.window;

global.URLSearchParams = window.URLSearchParams;

// Copy over all properties from window that do not yet exist on nodes global
// over to the global object.
// Later we might want to filter some of them, but for now it seems to work just
// fine when copying everything over like this.
Object.keys(window).forEach((key) => {
  if (typeof global[key] === "undefined") {
    global[key] = window[key];
  }
});

// Setup fetch polyfill and copy the references the polyfill installs into the
// window over into the global object.
require("whatwg-fetch");
global.fetch = window.fetch;
global.Headers = window.Headers;
global.Request = window.Request;
global.Response = window.Response;

@@ -687,16 +687,33 @@
 object.%0A
+const wwgFetch = 
 require(
@@ -729,16 +729,17 @@
 etch%22);%0A
+%0A
 global.f
@@ -746,21 +746,23 @@
 etch = w
-indow
+wgFetch
 .fetch;%0A
@@ -779,21 +779,23 @@
 ders = w
-indow
+wgFetch
 .Headers
@@ -814,21 +814,23 @@
 uest = w
-indow
+wgFetch
 .Request
@@ -850,21 +850,23 @@
 onse = w
-indow
+wgFetch
 .Respons

Fix test setup