Skip to content

Instantly share code, notes, and snippets.

@cvan
Created April 7, 2020 01:47
Show Gist options
  • Save cvan/cbbd64fe90200d1dbe3761d7a705689c to your computer and use it in GitHub Desktop.
Save cvan/cbbd64fe90200d1dbe3761d7a705689c to your computer and use it in GitHub Desktop.
describe('test', () => {
const mockFetchPromise = () =>
Promise.resolve({
ok: true,
json: () => Promise.resolve({}),
status: 200,
statusText: 'OK'
});
beforeEach(() => {
// global.fetch = jest.fn().mockImplementation(() => mockFetchPromise());
jest.spyOn(global, 'fetch').mockImplementation((url, options) => {
console.log({ url, options });
return mockFetchPromise();
});
});
it('…', async () => {
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment