Skip to content

Instantly share code, notes, and snippets.

@ivan-ha
Created June 1, 2019 10:00
react-hooks-test-failed-unit-test
jest.mock("axios");
describe("useRandomUsers", () => {
it("call API and return results", async () => {
axios.mockImplementation(() => Promise.resolve({ data: mockResponse }));
const users = useRandomUsers();
expect(users.current).toStrictEqual(mockResponse);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment