Created
June 11, 2020 05:14
-
-
Save Dromediansk/772c4a388433154173ee0a7c57b83c93 to your computer and use it in GitHub Desktop.
Fetching data error
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
it("should catch error", async () => { | |
// Mock API | |
jest.spyOn(global, "fetch").mockImplementation(() => | |
Promise.resolve({ | |
json: () => | |
Promise.resolve({ | |
status: 500, | |
}), | |
}) | |
); | |
const result = await getAllCountries(); | |
expect(result.status).toBe(500); | |
expect(result.data).not.toBeDefined(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment