I have a test that looks like this:
it('should fail to get deleted customer', function(done) {
request(app)
.get('/customers/'+newCustomerId)
.set('Authorization', 'Bearer ' + token)
.set('Accept', 'application/json')
.expect('Content-Type', /json/)
.expect(404, done)
});
I've read the documentation here:
https://github.com/visionmedia/supertest
It says this:
note how you can pass done straight to any of the .expect() calls
The line of code that isn't working is .expect(404, done)
if I change this to be .expect(200, done)
then the test doesn't fail.
However, if I add an end like this:
it('should fail to get deleted customer', function(done) {
request(app)
.get('/customers/'+newCustomerId)
.set('Authorization', 'Bearer ' + token)
.set('Accept', 'application/json')
.expect('Content-Type', /json/)
.expect(200)
.end(function(err, res) {
if (err) console.log(err);
done();
});
});
Then the test fails. Why is .expect(200, done)
not failing also?