Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not returning proper blob #209

Open
johanbook opened this issue Aug 6, 2021 · 0 comments
Open

Not returning proper blob #209

johanbook opened this issue Aug 6, 2021 · 0 comments

Comments

@johanbook
Copy link

johanbook commented Aug 6, 2021

This is the same as issue #105.

The Blob returned from the blob function of a mocked response is not a proper 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.

jest-fetch-mock version: v3.0.3
Node version: v16.4.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant