Mock Fetch in a Jest Test
afterAll(() => {
global.fetch.mockClear()
delete global.fetch
})
global.fetch = jest.fn(() =>
Promise.resolve({
json: () => Promise.resolve({ test: 100 }),
}),
) as jest.Mock;
afterAll(() => {
global.fetch.mockClear()
delete global.fetch
})
global.fetch = jest.fn(() =>
Promise.resolve({
json: () => Promise.resolve({ test: 100 }),
}),
) as jest.Mock;