Skip to content

Commit

Permalink
tests: add test for error middleware ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
dougwilson committed Sep 9, 2016
1 parent d6ac073 commit 69a12f8
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions test/mounting.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,24 @@ describe('app.use()', function(){
.expect(200, 'msg', done);
})

it('should start at error middleware declared after error', function(done){
var invoked = false;

app.use(function(err, req, res, next){
res.end('fail: ' + err.message);
});
app.use(function(req, res, next){
next(new Error('boom!'));
});
app.use(function(err, req, res, next){
res.end('pass: ' + err.message);
});

request(app)
.get('/')
.expect(200, 'pass: boom!', done);
})

it('should stack error fns', function(done){
app.use(function(req, res, next){
next(new Error('msg'));
Expand Down

0 comments on commit 69a12f8

Please sign in to comment.