chai-http
chai-http copied to clipboard
How to get req object?
In the documentation you show how it's possible to access cookies:
But where do you actually get the req
object from? This isn't explained anywhere in the documentation.
I'm curious as well. please if anyone found out please leave a note.
I believe the response object (res
) should have the request object (req
) attached to it:
app.get('/').then(res => res.req).then(req => expect(req.to.have.cookie('session_id');
If someone would like to confirm this and send a PR updating the docs, that'd be great!
I tried res.req.body
and it returns undefined
, wonder if the body-parser
would work in the test.
@yipcma what are you expecting res.req.body
to be? Do you have a reduced test case I could look at?
it's a text, and i have body-parser.text() as middle-ware in my express server. I'm expecting text.