examples/errors/test.js
Kevin Rambaud fc7f25a73f Fix mocha version and unit tests (#117)
* Remove duplicate supertest dependency

* Fix mocha version

* Add an after statement to close koa app instance after running tests
2018-01-24 19:10:06 +08:00

30 lines
608 B
JavaScript

require('should');
const app = require('./app');
const server = app.listen();
const request = require('supertest').agent(server);
describe('Errors', function() {
after(function() {
server.close();
});
it('should catch the error', function(done) {
request
.get('/')
.expect(500)
.expect('Content-Type', /text\/html/, done);
});
it('should emit the error on app', function(done) {
app.once('error', function(err, ctx) {
err.message.should.equal('boom boom');
ctx.should.be.ok;
done();
});
request
.get('/')
.end(function() {});
});
});