Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do i prevent winston from polluting my Mocha test report? #1221

Closed
bertolo1988 opened this issue Feb 28, 2018 · 3 comments
Closed

How do i prevent winston from polluting my Mocha test report? #1221

bertolo1988 opened this issue Feb 28, 2018 · 3 comments

Comments

@bertolo1988
Copy link

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?

@gigi
Copy link

gigi commented Mar 21, 2018

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,

@bertolo1988
Copy link
Author

@gigi it helped! Nice tip, thanks.

@indexzero
Copy link
Member

@bertolo1988 @gigi this will be fixed as #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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants