c8
c8 copied to clipboard
Why are reports generated when tests fail?
I was submitting a feature request for the vitest project, regarding that generating coverage reports when unit tests fail does not make a lot of sense.
It was noted that tools like c8 do generate reports on failure (https://github.com/vitest-dev/vitest/issues/2908#issuecomment-1442890311) and I was wondering if there was a reason for this.
I was searching whether any option exists to stop coverage from running if tests fail and I ran into this issue, so I'm co-opting it if you don't mind.
Sometimes coverage report is quite long and scrolling is necessary to know if any tests failed. Is there a way to configure c8
so that coverage does not run if a test did not pass? If not, could I feature-request it?
Thanks! 😃
I'd also like to see built-in support for this, but it's not that hard to do yourself:
c8 --reporter none -- <test command> && c8 report
The initial run will not print a report, and will fail (as usual) if the test command fails. The second run will print the report, but doesn't run if the first fails.