From 0991405072d4d6b5123546434295ed98b27cf7dc Mon Sep 17 00:00:00 2001 From: Mark Moffat Date: Sat, 9 Nov 2019 10:57:20 +1030 Subject: [PATCH] Suppress logging when running tests --- app.js | 4 +++- lib/indexing.js | 16 ++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/app.js b/app.js index d1aa5c5..f6eb088 100644 --- a/app.js +++ b/app.js @@ -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); diff --git a/lib/indexing.js b/lib/indexing.js index 0d6de1f..36cf092 100644 --- a/lib/indexing.js +++ b/lib/indexing.js @@ -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),