Fix race condition in error handler test

This commit is contained in:
Miroslav Bajtoš 2016-02-04 16:52:50 +01:00
parent 7ed5cf88ca
commit e7f49af7f4
1 changed files with 15 additions and 7 deletions

View File

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