c8 icon indicating copy to clipboard operation
c8 copied to clipboard

Why are reports generated when tests fail?

Open olafurw opened this issue 2 years ago • 2 comments

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.

olafurw avatar Feb 24 '23 11:02 olafurw

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! 😃

celiavelmar avatar May 29 '23 12:05 celiavelmar

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.

raihle avatar Feb 08 '24 14:02 raihle