Last active
June 13, 2020 13:54
-
-
Save Dromediansk/9646399ba12f809c73031515bb032895 to your computer and use it in GitHub Desktop.
Setting up testing file useFetch.test.js
This file contains 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 { renderHook } from "@testing-library/react-hooks"; | |
import { useFetch } from "./customHooks"; | |
const stubbedCountries = [ | |
{ name: "Slovakia", capital: "Bratislava" }, | |
{ name: "Germany", capital: "Berlin" }, | |
]; | |
const stubbedFetchUrl = "api/countriesUrl-mocked"; | |
afterEach(() => { | |
global.fetch.mockClear(); | |
}); | |
afterAll(() => { | |
global.fetch.mockRestore(); | |
}); | |
describe("useFetch", () => { | |
// writing tests here | |
]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment