-
-
Notifications
You must be signed in to change notification settings - Fork 40
feat: exclude lines that are missing from source maps #244
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
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 |
|
Closing in favor of https://github.com/AriPerkkio/ast-v8-to-istanbul. I ended up rewriting |
|
@AriPerkkio cool, I'd be curious to see how much breaks in |
|
Here's example of the Vitest integration. At the moment it's supporting both Though I don't know how you would get contents of the executed Javascript file in |
|
@AriPerkkio one major problem for Node's use of c8 is, if I recall, we don't always have the source code so it did something interesting and popualted: I don't fully recollect how it was that I have the line length but not the actual source, but I'm pretty sure I'm remembering correctly. tldr; an AST wouldn't work on it. |
feat: exclude lines that are missing from source maps@jridgewell/trace-mappingto 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?excludeEmptyLinesargument. No breaking changes.Examples:
Vitest
Jest
Playwright
c8, test code transpiled with tsc. (
tsconfig.json'sremoveCommentswas disabled when taking the picture)fix: ignore hint to exclude lines/* v8 ignore ... */should exclude the lines from coverage, not mark them as covered.