No responses with await response.json() when using Jest & undici polyfill #1829
-
The same code worked in version 1.3.2 but not working after changed to 2 So I simulate the case out with simple code The fetch response is able to print out (added below). However, my code stopped around await resp.json() Could anyone told me what's wrong with my case ? My case
The libraries I used
jest.config
Polyfill
Response Result
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
I found I should be in the same situation as #1830 |
Beta Was this translation helpful? Give feedback.
-
@jeffwong14 - I believe the issue stems from an implementation of fake timers in jest combined with the way node's fetch implementation, unidici works. this doesn't seem to be something we can fix directly in MSW as far as I can tell, but instead we would need changes in undici. I have more discovery as well as 2 workarounds here: #1830 (comment) And the relevant workarounds copied here:
jest.useFakeTimers({
now: hardCodeNow,
legacyFakeTimers: true,
});
jest.useFakeTimers({
now: hardCodeNow,
doNotFake: ["queueMicrotask"],
}); |
Beta Was this translation helpful? Give feedback.
@jeffwong14 - I believe the issue stems from an implementation of fake timers in jest combined with the way node's fetch implementation, unidici works.
this doesn't seem to be something we can fix directly in MSW as far as I can tell, but instead we would need changes in undici.
I have more discovery as well as 2 workarounds here: #1830 (comment)
And the relevant workarounds copied here: