Skip to content

Instantly share code, notes, and snippets.

@sabesansathananthan
Created September 14, 2021 15:41
Show Gist options
  • Save sabesansathananthan/26ae2f36b927e2ac20988d281650a823 to your computer and use it in GitHub Desktop.
Save sabesansathananthan/26ae2f36b927e2ac20988d281650a823 to your computer and use it in GitHub Desktop.
mock network request in Jest
import { JSDOM } from "jsdom";
const config = {
url: "https://www.example.com/",
domain: "example.com",
};
const dom = new JSDOM("", config);
global.document = dom.window.document;
global.document.domain = config.domain;
global.window = dom.window;
global.location = dom.window.location;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment