Winston: How do i prevent winston from polluting my Mocha test report?

Created on 28 Feb 2018  路  3Comments  路  Source: winstonjs/winston

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?

Most helpful comment

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,

All 3 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JaehyunLee-B2LiNK picture JaehyunLee-B2LiNK  路  3Comments

jlank picture jlank  路  4Comments

sinai-doron picture sinai-doron  路  3Comments

kjin picture kjin  路  3Comments

tagyoureit picture tagyoureit  路  4Comments