mocha.jssupertestshould.js

Suppress REST Logging Calls from Supertest


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


Solution

  • 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'));