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

Suppress intentionally thrown errors #2217

Closed
teckays opened this issue Apr 20, 2016 · 1 comment
Closed

Suppress intentionally thrown errors #2217

teckays opened this issue Apr 20, 2016 · 1 comment

Comments

@teckays
Copy link

teckays commented Apr 20, 2016

I'm building a module that handles Express error logging and I have an endpoint where I intentionally throw an error. I do this because I want the error to pass through the error handling Express middleware and log it with a specific winston transport. However I would like to suppress the error so it's stack is not printed when I run my tests with mocha. Any way to do this?

@danielstjules
Copy link
Contributor

Hi @teckays I'd disable console output in the winston transport, perhaps by directing the output to a different stream of your choice so you can still add some assertions. If the stacktrace is being logged by a different function, then again, I'd either disable/redirect it, or just overwrite console.log/process.stdout.write for that spec.

There's a pretty long issue on the topic here that includes an example: #1582 (comment)

Hope that helps!

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

2 participants