I'm using supertest and mocha testing my express rest api. there's this test case I want to check the returned response body with a method of supertest:expect(function(res){ } ). But I'm facing an error that I can't figure out why:
Error: expected [Function] response body, got '{"name":"Aaron Shen","_id":"
530ed1ce92788ed031022d8c","__v":0,"active":true}'
Does anybody know how to fix? below is my testing code:
it('should return correct player',function(done){
var url = '/api/players/' + pid;
request(app)
.get(url)
.expect(200)
.expect(function(res){
res.body.should.have.property('name');
})
.end(done);
});