jest-fetch-mock
jest-fetch-mock copied to clipboard
Support "ok" in mockResponse
from typescrpit types, MockParams does not support response properties of "ok"
It would be good to support "ok" since fetch implementation does have "ok" in the properties.
https://github.github.io/fetch/#Response
Hi, you cannot explicitely set it, but it works ;)
Simple example:
fetchMock.mockResponseOnce(JSON.stringify({ a: 1 }), { status: 200 });
and after debugging my response, you can see, variable exists.
And on the other hand, ok == false when I set status to 400.
I think what @Magnielcz makes sense. Internally jest fetch mock uses the Response object which automatically sets the ok property.
Hello !
I have the same problem as @superoo7
I set the status
to 400
but still get a ok: true
response.
Console.log of the mocked response
Code of the mock
You can see that the arguments in the body and the status are the good one, however, still an ok: true
.
Hello !
I have the same problem as @superoo7
I set the
status
to400
but still get aok: true
response.Console.log of the mocked response
Code of the mock
You can see that the arguments in the body and the status are the good one, however, still an
ok: true
.
I'm having the same issue