-
-
Notifications
You must be signed in to change notification settings - Fork 41
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
base: master
Are you sure you want to change the base?
Conversation
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 When source maps are not passed, the empty lines should be marked as covered as before. |
0cff4f5
to
7396cc5
Compare
7396cc5
to
fe075af
Compare
fe075af
to
e3c4935
Compare
Possible to get this merged? We're currently forking this commit so we can get proper coverage numbers in our repo. Def not ideal. |
@joshuanathanson - just curious, what test runner and coverage tool are you using this commit with? |
We have our own wrappers, but under the hood we're using Selenium to run the tests, along with grabbing the coverage from Chrome on the fly with Selenium CDP DevTools. |
This is one of those I'd love to hear @bcoe's thoughts 👀 |
I think this would also fix the related issue in |
Bump on this? Revisiting our work in this area and would be nice to get this merged. |
This feature has been included in Vitest v1.6 and enabled by default in Vitest v2 for ~2 weeks now. We haven't (yet) heard any issues about this change. @bcoe there are many issues in
|
Isn't there a risk that lines removed by treeshaking are marked as empty? This is maybe not an issue (after all if they are not in the built artifact, it means that they are not relevant) but it may look strange in reports that they are marked as empty. |
@ericmorand yup, those lines cannot be covered so I would expect them to be excluded from report. This is similar how |
Looks like |
feat: exclude lines that are missing from source maps
@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?excludeEmptyLines
argument. No breaking changes.Examples:
Vitest
Jest
Playwright
c8, test code transpiled with tsc. (
tsconfig.json
'sremoveComments
was disabled when taking the picture)fix: ignore hint to exclude lines
/* v8 ignore ... */
should exclude the lines from coverage, not mark them as covered.