Created
September 22, 2021 07:52
-
-
Save sabesansathananthan/e2c65d63ab338ae8e32dcc48af942e7d 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"; | |
import { init } from "../../src/index"; | |
import axios from "axios"; | |
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; | |
init(axios); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment