How to test PUT method specifying a body?
Solved, using .send() method
Can you post an example of the solution for the PUT method? Thank you!
Try with following using put method instead of post
request(app)
.post('/login')
.send({
username: '[email protected]',
password: 'password'
})
.expect(200)
.end(function(err, res) {
expect(res.body.token).to.be.not.undefined;
expect(res.body.user).to.be.not.undefined;
expect(res.body.user.username).to.be.eql('[email protected]');
done();
})
Thank you for your response!
I had a problem with put and also trying a file upload, so there was a little problem :)
Hi, for general questions like this, let's try to use StackOverflow with questions tagged supertest
this https://github.com/visionmedia/supertest/issues/246#issuecomment-121542653 works great with POST too :) thanks for sharing code sample
Most helpful comment
Try with following using put method instead of post