-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
feat(coverage): v8 experimental AST-aware remapping #7736
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(coverage): v8 experimental AST-aware remapping #7736
Conversation
✅ Deploy Preview for vitest-dev ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
44d9a4b to
b5f7d06
Compare
b1e8c9f to
edf0b10
Compare
addd2df to
47a3e21
Compare
@vitest/browser
@vitest/coverage-istanbul
@vitest/expect
@vitest/coverage-v8
@vitest/mocker
@vitest/pretty-format
@vitest/runner
@vitest/snapshot
@vitest/spy
@vitest/ui
@vitest/utils
vite-node
vitest
@vitest/web-worker
@vitest/ws-client
commit: |
| ignoreNode: (node, type) => { | ||
| // SSR transformed imports | ||
| if ( | ||
| type === 'statement' | ||
| && node.type === 'AwaitExpression' | ||
| && node.argument.type === 'CallExpression' | ||
| && node.argument.callee.type === 'Identifier' | ||
| && node.argument.callee.name === '__vite_ssr_import__' | ||
| ) { | ||
| return true | ||
| } | ||
|
|
||
| // SSR transformed exports | ||
| if ( | ||
| type === 'statement' | ||
| && node.type === 'ExpressionStatement' | ||
| && node.expression.type === 'AssignmentExpression' | ||
| && node.expression.left.type === 'MemberExpression' | ||
| && node.expression.left.object.type === 'Identifier' | ||
| && node.expression.left.object.name === '__vite_ssr_exports__' | ||
| ) { | ||
| return true | ||
| } | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hi-ogawa this approach should provide us an easier way to control how Vite's generated code is excluded from coverage reports. We no longer need to modify source maps - instead we ignore the nodes while remapping coverage.
3bef604 to
ec9dfe8
Compare
79d1852 to
add0a2d
Compare
add0a2d to
4c28b62
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked ast-v8-to-istanbul too and it looks all good to me. Awesome stuff!
Report generation is slightly slower than with previous @vitest/coverage-v8, but faster than overall istanbul provider run.
I'm curious how you understand the performance characteristic leading to this result.
I think ast-v8-to-istanbul being slower than v8-to-istanbul is probably obvious since it now parses and traverse AST and remap node by node while v8-to-istanbul just goes through v8 coverage once.
What about @vitest/coverage-istanbul? I guess istanbul's instrumentation transform can be slower than ast-v8-to-istanbul's ast manipulation? Also do you take into account instrumented code being running slower? Or maybe other aspect of coverage processing logic?
Yes, exactly. It is expected that AST based remapping is slower than the original
This speed difference reproduces on When comparing AST parsing, visiting and analysing of
I've been comparing
In these tests I've checked overall speed with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks incredible! Thank you for working on it 🙏🏻
4c28b62 to
4070914
Compare
Description
v8-to-istanbul, but switches toast-v8-to-istanbulwhenexperimentalAstAwareRemapping: trueis set.v8-to-istanbulin Vitest v4 (Enable V8 coverage'sexperimentalAstAwareRemappingby default and remove old remapping mode #7928)provider.tsis a bit of mess as it supports both remappers. Oncev8-to-istanbulcan be dropped, it will simplify quite much@vitest/coverage-v8. Report accuracy is as good as with@vitest/coverage-istanbul. Report generation is slightly slower than with previous@vitest/coverage-v8, but faster than overall istanbul provider run.Testing:
vuejs/core: 100% match with@vitest/coverage-istanbul, except branch coverage is87.69% 12059/13751vs87.46% 12047/13773. There are couple of uncovered function default arguments that are not reported by V8 at all. These are marked as covered.vitejs/vite: Close to 100% match with@vitest/coverage-istanbul. Differences coming from V8 limitations, e.g. uncovered default parameters.Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
pnpm-lock.yamlunless you introduce a new test example.Tests
pnpm test:ci.Documentation
pnpm run docscommand.Changesets
feat:,fix:,perf:,docs:, orchore:.