add app start on unit test exec

pull/32/head
HardiReady 2018-03-30 18:16:52 +02:00
parent a375124074
commit eda2389eda
1 changed files with 6 additions and 11 deletions

View File

@ -117,25 +117,20 @@ switch (process.env.NODE_ENV) {
const mongoServer = new MongodbMemoryServer();
mongoose.Promise = Promise;
mongoServer.getConnectionString().then((mongoUri) => {
const mongooseOpts = { // options for mongoose 4.11.3 and above
autoReconnect: true,
reconnectTries: Number.MAX_VALUE,
reconnectInterval: 1000,
useMongoClient: true, // remove this line if you use mongoose 5 and above
};
mongoose.connect(mongoUri, mongooseOpts);
mongoose.connect(mongoUri);
mongoose.connection.on('error', (e) => {
if (e.message.code === 'ETIMEDOUT') {
console.log(e);
error(e);
mongoose.connect(mongoUri, mongooseOpts);
}
console.log(e);
error(e);
});
mongoose.connection.once('open', () => {
console.log(`MongoDB successfully connected to ${mongoUri}`);
logger(`MongoDB successfully connected to ${mongoUri}`);
app.listen(config.test.unit.port);
logger('Listening on port ' + config.test.unit.port);
});
});
break;