Hi as of title of question I was wondering how one can check if loopback boot scripts have finished before launching tests. In a example project:
https://github.com/strongloop/loopback-example-relations
there is a file in the test folder that seems to do the job but unfortunately it does not solve it.
start-server.js:
var app = require('../server/server');
module.exports = function(done) {
if (app.loaded) {
app.once('started', done);
app.start();
} else {
app.once('loaded', function() {
app.once('started', done);
app.start();
});
}
};
This script is loaded in the rest test api as follows:
before(function(done) {
require('./start-server');
done();
});
but the function is never invoked. Is this the correct way it was meant to use that script?
I ended with the following implementation:
before(function (done) {
if (app.booting) {
console.log('Waiting for app boot...');
app.on('booted', done);
} else {
done();
}
});
which works, but I was puzzled by that start-server script.
EDIT
following the @stalin advice I modified the before
function as follows:
before(function(done) {
require('./start-server')(done);
});
and the execution goes in the else
branch but done
is never called.