Skip to content

Instantly share code, notes, and snippets.

@sseletskyy
Created September 1, 2021 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sseletskyy/b3f791dcbb69300354e8e9e9a235c85a to your computer and use it in GitHub Desktop.
Save sseletskyy/b3f791dcbb69300354e8e9e9a235c85a to your computer and use it in GitHub Desktop.
export function mockFetchSuccess(data) {
return jest.fn().mockImplementation(() =>
Promise.resolve({
ok: true,
json: () => data,
})
);
}
export function mockFetchFail(reason) {
return jest.fn().mockImplementation(() => Promise.reject(reason));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment