7

I have started using MEAN stack and currently writing REST unit tests using Super Test

I want to have a little bit more clarity in my log file so that I can easily see my successful and failed tests.

I wish to suppress the console output for the actual rest API call which I think are coming out of SuperTest.

This image shows the logs I want to suppress.

Suppress Super Test Logging

David Cruwys
  • 6,262
  • 12
  • 45
  • 91

2 Answers2

9

I think it's actually coming from expressjs/morgan. I've gotten around it by setting the env to test and disabling morgan for the test env.

In my test files:

process.env.NODE_ENV = 'test';

In app.js:

if(app.get('env') !== 'test') app.use(logger('dev'));

scottmizo
  • 146
  • 2
  • 5
0

You can setup morgan to accept a skip function.

Then, you can, say, toggle an env variable on/off - or define skipping logic of your own to temporarily mute the logging.

app.use(
  logger('dev', {
    skip: function(req, res) {
      return process.env.MUTE_LOGGER === 'on';
    },
  }),
);
Mauro Colella
  • 446
  • 6
  • 12