add app start on unit test exec
parent
a375124074
commit
eda2389eda
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue