Closed SpeCT closed 3 months ago
You can only clear mocks once. Every "mocked" request after that will use real fetch.
describe('Auth API', () => { afterEach(() => { clearMocks() }) test('GET foo', async () => { mock('https://example.com/', { data: { name: 'Foo' } }) await fetch('https://example.com/') expect(res.status).toBe(200) // <<- OK }) test('GET foo', async () => { mock('https://example.com/', { data: { name: 'Bar' } }) await fetch('https://example.com/') expect(res.status).toBe(200) // <<- INTERNET }) })
Thanks for the contribution @SpeCT 🚀 Your PRs has been merged and are included in the 1.0.9 release.
You can only clear mocks once. Every "mocked" request after that will use real fetch.