Skip to content

Commit

Permalink
test: catch stray error
Browse files Browse the repository at this point in the history
  • Loading branch information
wheresrhys committed Jul 26, 2024
1 parent 3915bfd commit 11fca22
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/core/src/__tests__/FetchMock/mock-and-spy.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ describe('mock and spy', () => {
testChainableMethod('mockGlobal');
testChainableMethod('unmockGlobal');

it('replaces global fetch with fetchMock.fetchHandler', () => {
it('replaces global fetch with fetchMock.fetchHandler', async () => {
vi.spyOn(fm, 'fetchHandler');
fm.mockGlobal();
fetch('http://a.com', { method: 'post' });
try {
await fetch('http://a.com', { method: 'post' });
} catch (err) {}
// cannot just check globalThis.fetch === fm.fetchHandler because we apply .bind() to fetchHandler
expect(fm.fetchHandler).toHaveBeenCalledWith('http://a.com', {
method: 'post',
Expand Down

0 comments on commit 11fca22

Please sign in to comment.