I am struggling to find a way to silence winston during my test execution.
It keeps logging all my caught exceptions even when i am testing for errors.
The silent flag does not seem to work at all.
Could you help me please?
As temporary solution its possible to add empty array of levels. Smth like this
winston.createLogger({
...
level: []
...
});
With Mocha and NODE_ENV:
package.json
...
"test": "NODE_ENV=test mocha test"
...
level: process.env.NODE_ENV === 'test' ? [] : process.env.LOGGER_LEVEL,
@gigi it helped! Nice tip, thanks.
@bertolo1988 @gigi this will be fixed as https://github.com/winstonjs/winston/issues/1245. Re-adding the silent
option from winston@2
because it is a cross-cutting concern that relates to the objectMode stream mechanics and not specific formatting.
Most helpful comment
As temporary solution its possible to add empty array of levels. Smth like this
With Mocha and NODE_ENV: