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

Don't generate coverage reports when tests fail. #2908

Closed
4 tasks done
olafurw opened this issue Feb 23, 2023 · 2 comments · Fixed by #3453
Closed
4 tasks done

Don't generate coverage reports when tests fail. #2908

olafurw opened this issue Feb 23, 2023 · 2 comments · Fixed by #3453
Labels
feat: coverage Issues and PRs related to the coverage feature

Comments

@olafurw
Copy link
Contributor

olafurw commented Feb 23, 2023

Clear and concise description of the problem

A test coverage report (either text or generated html/json) does not have a lot of value if the test run itself has failed. The text output (if large enough) can cover the entire screen and hide the fact that the test has failed.

Suggested solution

If the test failed, don't show or generate any coverage report.

Alternative

A configuration flag could be useful as well, for those that want the older behavior (or the other way around).

test: {
  coverage: {
    generateOnFailure: true
  }
}

Additional context

No response

Validations

@sheremet-va sheremet-va added the feat: coverage Issues and PRs related to the coverage feature label Feb 23, 2023
@AriPerkkio
Copy link
Member

Personally I agree that coverage should not be reported at all when tests fail. There should be no use for coverage report when tests fail, as the test execution stops where ever the error happens. Even if someone is posting the results to some 3rd party coverage service, the overall coverage is not likely to meet the thresholds when tests fail.

The text output (if large enough) can cover the entire screen and hide the fact that the test has failed.

Especially in watch-mode this must be frustrating as users have to scroll up past the coverage report to see the actual error.

But it seems that Jest, NYC and c8 report the coverage even when test execution fails. We might want to keep same behaviour as default, and introduce a new configuration flag for this. Instead of generateOnFailure, maybe name it reportOnFailure?

@olafurw
Copy link
Contributor Author

olafurw commented Feb 24, 2023

If it's the standard across other tools to generate then that's fine and a reportOnFailure would be very helpful.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feat: coverage Issues and PRs related to the coverage feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants