1

How do I check for the body property using chai-as-promised? I'm trying to access the body of the response as highlighted in the SuperAgent docs, but the assertion for .should.have.property('res') fails. I console.log(res) in a separate test and these got these results. Checking for properties such as domain and _events will satisfy the test.

The specific assertion error is: AssertionError: expected { Object (domain, _events, ...) } to have property 'res'.

it('should return a response message with success:true and a token', () => {
    return request(app).post('/auth').type('form')
        .set('Content-Type', 'application/x-www-form-urlencoded')
        .send({username: 'jbiden', password: 'password'}).end()
        .should.have.property('res') //'domain','_events' satisfy the test
});

EDIT: Answer in comments by Bergi.

Extreme112
  • 95
  • 1
  • 2
  • 9

0 Answers0