Here's what a request looks like when I set the status to 400 with msw vs a real server sending a 400:

I'm not sure what could be causing this.
My guess is that since MSW constructs a new Response it has statusText: 'OK' by default. I presume you set the status code alone (i.e. via ctx.status(400)), so it doesn't map it to any status text associated with that status code.
One way to solve it for now could be to provide an explicit status text alongside the status code:
ctx.status(400, 'Bad request')
I value the validity of requests and responses, but I wonder whether it's the library's responsibility to map status codes to texts implicitly. I'd expect this to be done by Request constructor. Would have to look into this in more detail.
That's fine. Thank you for helping me know what to do there.
I think that having a default statusText that's the same as what the statusText would be for a given status code would be useful. I could always override it if I want to, but having a default to what the browser does would be sensible IMO.
I was thinking of keeping a status code-status text map internally in MSW and mapping it by default, as you described. I guess there's little harm in that, but a big gain in developer experience.
I went with the solution that reuses the statuses package thats's used in Express to map status codes to status texts.
Starting from 0.9.3 MSW now implicitly maps given status codes to the associated status text, if such is present, and if no custom status text is provided.
@kentcdodds, could you please update to 0.9.3 and let me know it produced correct status texts for you? Thanks.
Confirmed. This worked. Thanks!
Sorry for bumping that old issue, but when I using setup server with such handler:
rest.post('http://127.0.0.1:3000/getUserPoints', (req, res, ctx) => res(ctx.status(401))),
I receiving response with status text OK. Its not only for 401, but for other statuses too.

Hey, @pandrodo. That's perfectly fine.
Can you clarify a few things:
msw are you using?msv is 0.21.3.jest tests (version 24.9.0 shipped with react-scripts 3.4.3).
@pandrodo, thanks for including that. The issue confirmed as reproducible, the fix pull request is issued. Regression test was added, so we don't miss it occurring again. Will be released in the next minor version of msw.
@kettanaito, thanks for so fast fix.