Suppress logging when running tests

master
Mark Moffat 2019-11-09 10:57:20 +10:30
parent a7e09f3d56
commit 0991405072
2 changed files with 15 additions and 5 deletions

4
app.js
View File

@ -419,7 +419,9 @@ initDb(config.databaseConnectionString, async (err, db) => {
try{
await app.listen(app.get('port'));
app.emit('appStarted');
console.log(colors.green('expressCart running on host: http://localhost:' + app.get('port')));
if(process.env.NODE_ENV !== 'test'){
console.log(colors.green('expressCart running on host: http://localhost:' + app.get('port')));
}
}catch(ex){
console.error(colors.red('Error starting expressCart app:' + err));
process.exit(2);

View File

@ -31,7 +31,9 @@ const indexProducts = (app) => {
});
app.productsIndex = productsIndex;
console.log(colors.cyan('- Product indexing complete'));
if(process.env.NODE_ENV !== 'test'){
console.log(colors.cyan('- Product indexing complete'));
}
resolve();
});
});
@ -67,7 +69,9 @@ const indexCustomers = (app) => {
});
app.customersIndex = customersIndex;
console.log(colors.cyan('- Customer indexing complete'));
if(process.env.NODE_ENV !== 'test'){
console.log(colors.cyan('- Customer indexing complete'));
}
resolve();
});
});
@ -103,7 +107,9 @@ const indexOrders = (app, cb) => {
});
app.ordersIndex = ordersIndex;
console.log(colors.cyan('- Order indexing complete'));
if(process.env.NODE_ENV !== 'test'){
console.log(colors.cyan('- Order indexing complete'));
}
resolve();
});
});
@ -120,7 +126,9 @@ const fixProductDates = (products) => {
// start indexing products and orders
const runIndexing = (app) => {
console.info(colors.yellow('Setting up indexes..'));
if(process.env.NODE_ENV !== 'test'){
console.info(colors.yellow('Setting up indexes..'));
}
return Promise.all([
indexProducts(app),