add app start on unit test exec
							parent
							
								
									a375124074
								
							
						
					
					
						commit
						eda2389eda
					
				| 
						 | 
					@ -117,25 +117,20 @@ switch (process.env.NODE_ENV) {
 | 
				
			||||||
    const mongoServer = new MongodbMemoryServer();
 | 
					    const mongoServer = new MongodbMemoryServer();
 | 
				
			||||||
    mongoose.Promise = Promise;
 | 
					    mongoose.Promise = Promise;
 | 
				
			||||||
    mongoServer.getConnectionString().then((mongoUri) => {
 | 
					    mongoServer.getConnectionString().then((mongoUri) => {
 | 
				
			||||||
      const mongooseOpts = { // options for mongoose 4.11.3 and above
 | 
					      mongoose.connect(mongoUri);
 | 
				
			||||||
        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.connection.on('error', (e) => {
 | 
					      mongoose.connection.on('error', (e) => {
 | 
				
			||||||
        if (e.message.code === 'ETIMEDOUT') {
 | 
					        if (e.message.code === 'ETIMEDOUT') {
 | 
				
			||||||
          console.log(e);
 | 
					          error(e);
 | 
				
			||||||
          mongoose.connect(mongoUri, mongooseOpts);
 | 
					          mongoose.connect(mongoUri, mongooseOpts);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        console.log(e);
 | 
					        error(e);
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      mongoose.connection.once('open', () => {
 | 
					      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;
 | 
					    break;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue