chai http code example
Example: get chai.request()
it('fails, as expected', function(done) { // <= Pass in done callback
chai.request('http://localhost:8080')
.get('/')
.end(function(err, res) {
expect(res).to.have.status(123);
done(); // <= Call done to signal callback end
});
});
it('succeeds silently!', function() { // <= No done callback
chai.request('http://localhost:8080')
.get('/')
.end(function(err, res) {
expect(res).to.have.status(123); // <= Test completes before this runs
});
});