I'm confused, so if I use SuperTest which apparently looks like it has its own expect assertion, then I don't need to worry about using Chai? Or when I require Chai, Supertest knows about it and is using it as the expect mechanism?
SuperTest extends SuperAgent's request
object to include an expect
function. It doesn't work quite like Chai's expect
assertion, but can be used to assert the http response status and headers, and can be mixed with Chai's expect
.
request(app).
get('/').
expect(200). // request.expect, is status code 200?
expect('Content-Type', /json/). // request.expect, does content-type match regex /json/?
expect(function(res){ // request.expect, does this user-provided function throw?
// user-provided function can include Chai assertions
expect(res.body).to.exist;
expect(res.body).to.have.property('status');
}).
end(done);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With