Mocha: hide all console log during tests

Created on 15 May 2014  路  1Comment  路  Source: mochajs/mocha

I'd like to turn off all console.log used in the tested code using a flag.
Is there a easy way to do this?
I have already tried to override console.log in a beforeEach function but it seems doesn't work.
But if I sostitute the console.log in the test, it's work.

>All comments

you could use an env variable to do it conditionally, but usually you have some kind of logging lib/object passed which you can noop in NODE_ENV=test

Was this page helpful?
0 / 5 - 0 ratings