forwardemail / forwardemail/supertest
[fix] Do no replace invalid body with an empty JSON object
- Dominant language
- JavaScript
- Stars
- 14.4k
- Forks
- 782
- PR merge metrics
- No merged PRs in 30d
Description
## Describe the bug
**Node.js version:** v18.8.0
**OS version:**
**Description:** SuperTest doesn't seem to pass the body as is. In particular, if it is invalid, it sends an empty JSON object to the endpoint.
Is this intended? It seems like it would be useful to accept invalid bodies to test the behaviour in those cases.
## Actual behavior
ie.
`let res = await request.post('/hello/').send('bye');`
Endpoint receives a request that has a body of `{}`
## Expected behavior
`let res = await request.post('/hello/').send('bye');`
Endpoint receives a request that has a body of `'bye'`, even if it is technically invalid.
## Code to reproduce
Behaviour seems similar to what was reported here too: https://github.com/ladjs/supertest/issues/189#issuecomment-826861224
It may be of note that the endpoint receives an empty JSON object when the request body is being parsed by a middleware (both `body-parser` or `express`' parser).
## Checklist
- [x] I have searched through GitHub issues for similar issues.
- [x] I have completely read through the README and documentation.
- [x] I have tested my code with the latest version of Node.js and this package and confirmed it is still not working.
Contributor guide
Assessment
This issue has not been assessed yet.