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

feat: exclude lines that are missing from source maps #244

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

AriPerkkio
Copy link
Contributor

@AriPerkkio AriPerkkio commented Mar 23, 2024

feat: exclude lines that are missing from source maps

  • When source maps are available, use @jridgewell/trace-mapping to figure out which lines contain runtime code. If a line is not present in source maps, consider it as empty line. This will exclude Typescript typings, comments, empty lines and any other special syntax that transpiled languages exclude from source maps.
  • Should this be considered as breaking change or be a configurable option? ⚠️
    • This is now opt-in and configurable via excludeEmptyLines argument. No breaking changes.

Examples:

  • Vitest

  • Jest

  • Playwright

  • c8, test code transpiled with tsc. It seems to leave comments in source maps - esbuild doesn't.

fix: ignore hint to exclude lines

  • /* v8 ignore ... */ should exclude the lines from coverage, not mark them as covered.

@AriPerkkio
Copy link
Contributor Author

AriPerkkio commented Mar 23, 2024

Any thoughts about this approach @SimenB and @bcoe?

In Vitest we will always have source maps available so we can utilize those for analysing the source file. I believe Jest has them too? I'm not that sure about c8 though.

When source maps are not passed, the empty lines should be marked as covered as before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Comments are reported as not covered
1 participant