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

V8 Coverage: Exclude empty lines, comments, TS types #5423

Closed
4 tasks done
AriPerkkio opened this issue Mar 24, 2024 · 0 comments · Fixed by #5457
Closed
4 tasks done

V8 Coverage: Exclude empty lines, comments, TS types #5423

AriPerkkio opened this issue Mar 24, 2024 · 0 comments · Fixed by #5457
Labels
feat: coverage Issues and PRs related to the coverage feature p3-significant High priority enhancement (priority)

Comments

@AriPerkkio
Copy link
Member

AriPerkkio commented Mar 24, 2024

Clear and concise description of the problem

There's now a PR for improved v8 coverage remapping in v8-to-istanbul:

There are some coverage reports in the linked PR that show what kind of changes it would cause.

  • Comments are excluded (esbuild doesn't add comments in source maps, tsc does though)
  • Empty lines are excluded
  • Typescript typings are excluded (except enums that compile to actual runtime code)
  • HTML-like templates from transpiled languages like Svelte and Vue are excluded, as long as they don't contain code that those compilers consider (user's) runtime code.
  • Ignore hints (/* v8 ignore ... */) exclude the lines instead of marking them as covered. Exactly as istanbul-lib-instrument does.

Related issues:

Suggested solution

Typically PRs in istanbuljs organization take long time to land so we could apply the changes as pnpm patch and bundle v8-to-istanbul into @vitest/coverage-v8 package.

At first we might want to introduce this as opt-in coverage option and enable it by default in V2. The changes that this introduces can affect line coverage in such ways that projects using coverage.thresholds may now fail in CI - exactly as they should do. Line coverage is now more accurate as comments don't increase it.

Alternative

No response

Additional context

No response

Validations

@AriPerkkio AriPerkkio added feat: coverage Issues and PRs related to the coverage feature p3-significant High priority enhancement (priority) labels Mar 24, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Apr 22, 2024
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 p3-significant High priority enhancement (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant