Open johanbook opened 3 years ago
This is the same as issue https://github.com/jefflau/jest-fetch-mock/issues/105.
The Blob returned from the blob function of a mocked response is not a proper blob.
Blob
blob
Here is a test that showcases the problem:
beforeEach(() => { fetchMock.mockResponse("some-data"); }); test("jest-fetch-mock can return blob", async () => { const res = await fetch("url"); const blob = await res.blob(); expect(blob).toBeInstanceOf(Blob); });
which yields the error
expect(received).toBeInstanceOf(expected) Expected constructor: Blob Received constructor: Blob 16 | const res = await fetch("url"); 17 | const blob = await res.blob(); > 18 | expect(blob).toBeInstanceOf(Blob); | ^ 19 | }); at Object.<anonymous> (src/App.test.tsx:18:16)
This means in-code typechecks such as blob instanceOf Blob fails in tests.
blob instanceOf Blob
jest-fetch-mock version: v3.0.3 Node version: v16.4.1
This is the same as issue https://github.com/jefflau/jest-fetch-mock/issues/105.
The
Blob
returned from theblob
function of a mocked response is not a proper blob.Here is a test that showcases the problem:
which yields the error
This means in-code typechecks such as
blob instanceOf Blob
fails in tests.jest-fetch-mock version: v3.0.3 Node version: v16.4.1