test: make status test more robust
Rework assertions to report helpful messages on failure. Increase the "elapsed" limit from 100ms to 300ms to support our slow CI machines.
This commit is contained in:
parent
48205fb2bd
commit
caaa296a82
|
@ -12,6 +12,7 @@ var loopback = require('../');
|
||||||
var PersistedModel = loopback.PersistedModel;
|
var PersistedModel = loopback.PersistedModel;
|
||||||
|
|
||||||
var describe = require('./util/describe');
|
var describe = require('./util/describe');
|
||||||
|
var expect = require('chai').expect;
|
||||||
var it = require('./util/it');
|
var it = require('./util/it');
|
||||||
|
|
||||||
describe('app', function() {
|
describe('app', function() {
|
||||||
|
@ -937,18 +938,14 @@ describe('app', function() {
|
||||||
.end(function(err, res) {
|
.end(function(err, res) {
|
||||||
if (err) return done(err);
|
if (err) return done(err);
|
||||||
|
|
||||||
assert.equal(typeof res.body, 'object');
|
expect(res.body).to.be.an('object');
|
||||||
assert(res.body.started);
|
expect(res.body).to.have.property('started');
|
||||||
// The number can be 0
|
expect(res.body.uptime, 'uptime').to.be.gte(0);
|
||||||
assert(res.body.uptime !== undefined);
|
|
||||||
|
|
||||||
var elapsed = Date.now() - Number(new Date(res.body.started));
|
var elapsed = Date.now() - Number(new Date(res.body.started));
|
||||||
|
|
||||||
// elapsed should be a positive number...
|
// elapsed should be a small positive number...
|
||||||
assert(elapsed >= 0);
|
expect(elapsed, 'elapsed').to.be.within(0, 300);
|
||||||
|
|
||||||
// less than 100 milliseconds
|
|
||||||
assert(elapsed < 100);
|
|
||||||
|
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue