'Mocha with Node: Only show logging for tests that fail
I'm using node with mocha and winston. Is there a way to set it up so it only shows logs for failing tests?
Solution 1:[1]
As of writing (in 2022), there's now an npm package that does exactly this:
https://www.npmjs.com/package/mocha-suppress-logs
I like it because I like the output from the default mocha reporter. It keeps all that, but hides console output for succeeding tests.
Solution 2:[2]
Possible to use
if (!expect(next.called).to.be.true) {
console.log("... further information")
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | verespej |
| Solution 2 | DaveX |
