Skip to content

Instantly share code, notes, and snippets.

@Dromediansk
Last active June 13, 2020 13:54
Show Gist options
  • Save Dromediansk/9646399ba12f809c73031515bb032895 to your computer and use it in GitHub Desktop.
Save Dromediansk/9646399ba12f809c73031515bb032895 to your computer and use it in GitHub Desktop.
Setting up testing file useFetch.test.js
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