jefflau / jest-fetch-mock

Jest mock for fetch
MIT License
881 stars 116 forks source link

Response should allow for passing more than just a string #236

Open taschmidt opened 1 year ago

taschmidt commented 1 year ago

I have a unit test I'm converting over to use this library. Since the method I'm testing reads from Response.body like a stream (which follows the fetch API docs), the previous version of the unit test passed a Readable.from(... abitrary data ...). However, this lib only will allow me to pass a string.

I was able to work around it by calling fetchMock.mockResponse(Readable.from( ... ) as any) but it would be nice if I didn't have to cast.