You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was trying to test some handler using fetch() and noticed that when I set the body in the handler with HttpResponse.text() or HttpResponse.json() didn't get any body in response I thought fetch() was the cause and tested fetch() with setupWorker(). response.body is undefined and response.text() in fetch callback only prints "" (empty string) in jest code.
The only thing which is missed was response body. The other response property I had configured like statusText existed well.
I am using
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I was trying to test some handler using fetch() and noticed that when I set the body in the handler with HttpResponse.text() or HttpResponse.json() didn't get any body in response I thought fetch() was the cause and tested fetch() with setupWorker(). response.body is undefined and response.text() in fetch callback only prints "" (empty string) in jest code.
The only thing which is missed was response body. The other response property I had configured like statusText existed well.
I am using
I've created an repository which reproduces this problem
You can find test code in App.test.tsx and msw handler in handler.ts.
So, my question is: Where does the body disappear to and how to preserve it?
Beta Was this translation helpful? Give feedback.
All reactions