mswjs / msw

Industry standard API mocking for JavaScript.
https://mswjs.io
MIT License
15.94k stars 518 forks source link

post request results in timeout when providing body, header, or both #1182

Closed mbastian93 closed 2 years ago

mbastian93 commented 2 years ago

Prerequisites

Environment check

Node.js version

14 / 16

Reproduction repository

https://codesandbox.io/s/laughing-ully-x4wt2w

Reproduction steps

open provided CodeSandbox and run npm test; only the test case executing a POST request with neither body nor header provided succeeds, the others fail

Current behavior

When providing data (i.e. body) to a POST request, the test ends in a timeout. A breakpoint within the request handler of the 'mocked server' is not even reached.

The exact same request when used against a 'real' nodeJS server (express)

Expected behavior

The tests should not result in a timeout and instead get processed by the handler.

I can not rule out, that my set up is wrong, however i followed the instructions to the best of my knowledge and understanding

mbastian93 commented 2 years ago

Okay i just noticed: when using jest/babel-jest v^26.0.0 it works as expect. Therefore there must be an issue with v27 of those libaries

kettanaito commented 2 years ago

Hey, @mbastian93. Thanks for reporting this.

I'm not sure how Jest 26 resolves this, afaik the only relevant change in 27 was the removal of setImmediate and some internal work on timers.

I can confirm that the sandbox above has its tests passing if I use node-fetch and not axios. The latest MSW has an issue with how Axios works (see #1169). I'm closing this as a duplicate.

dlvhdr commented 2 years ago

I'm facing the same issue :(

josuevalrob commented 2 years ago

oh fck, same issue for me

pqkluan commented 2 years ago

Related to https://github.com/mswjs/msw/issues/1125