Fix race condition in error handler test
This commit is contained in:
parent
7ed5cf88ca
commit
e7f49af7f4
|
@ -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();
|
||||||
}
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue