Created
September 14, 2021 15:41
-
-
Save sabesansathananthan/26ae2f36b927e2ac20988d281650a823 to your computer and use it in GitHub Desktop.
mock network request in Jest
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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