Closed quoininc-huudatran closed 2 years ago
same issue with me
Are you using express
or some other framework?
@eugef expressJS, as specified in my initial report.
This is the behavior in ExpressJS
It is indeed an issue in this lib that res.send()
functionality doesn't match Express.js 100%
https://github.com/howardabrams/node-mocks-http/blob/master/test/lib/mockResponse.spec.js#L639
Unfortunately the fix would break the backwards compatibility and would require a major release.
Meanwhile, as a work-around i suggest to use res._getData()
in your tests.
@eugef Yes, I understand this, and that's what I'm using in my tests to work around, but wanted to raise/document that difference, because it took me a little time to figure it out. Maybe it can just be added to the documentation.
@quoininc-huudatran use this for handle res.send,
and this work for me res._getData()
Stale issue message
When calling the following in my code:
will break the code:
as the data is kept as JSON instead of converting it to string. This is the behavior in ExpressJS (I'm not calling
JSON.stringify()
in my long-time running code.