Merge pull request #2034 from strongloop/fix/ci

Fix race condition in error handler test
This commit is contained in:
Miroslav Bajtoš 2016-02-04 17:48:52 +01:00
commit 7d3d4f1cee
1 changed files with 15 additions and 7 deletions

View File

@ -41,15 +41,23 @@ describe('loopback.errorHandler(options)', function() {
//arrange
var app = loopback();
app.use(loopback.urlNotFound());
app.use(loopback.errorHandler({ includeStack: false, log: customLogger }));
var errorLogged;
app.use(loopback.errorHandler({
includeStack: false,
log: function customLogger(err, str, req) {
errorLogged = err;
}
}));
//act
request(app).get('/url-does-not-exist').end();
//assert
function customLogger(err, str, req) {
assert.ok(err.message === 'Cannot GET /url-does-not-exist');
request(app).get('/url-does-not-exist').end(function(err) {
if (err) return done(err);
//assert
expect(errorLogged)
.to.have.property('message', 'Cannot GET /url-does-not-exist');
done();
}
});
});
});