You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to combine coverage results from vitest with coverage results from cypress (bundled with vite, instrumented with vite-plugin-istanbul). Merging coverage files does not work correctly because vitest instrumentation skips comments, types etc as requested and implemented in #5423, and vite-plugin-istanbul does not skip coverage of these (and also does not allow overriding this behaviour).
Without control over instrumentation for at least one of these (vitest OR vite-plugin-istanbul) there is no way for me to resolve the conflict.
Suggested solution
Provide some extra options in the coverage block that will override default instrumentation, such as
I am also going to raise a ticket for vite-plugin-istanbul to make a similar change, but ideally both packages would implement this change for maximum compatibility.
As far as I know, preserveComments just removes comments during the transform. Source maps are still pointing correctly, so it should work when you are merging the results with other tools.
because vitest instrumentation skips comments, types etc as requested and implemented in #5423
The #5423 is about V8 provider, not Istanbul. Istanbul already excludes lines that don't contain runtime code.
vite-plugin-istanbul does not skip coverage of these
Could you clarify what you mean by this? Coverage of comments?
If this is something that would help end-users, we can expose this option in public API. But I'm not sure this option is exactly doing what you expect here. Setting up a minimal reproduction that highlights the issue would help. 👍
When I say "skip coverage of comments", I really mean skipping instrumentation. I don't know enough about the internals to say for sure, but I do know that the statement maps output in each case do not line up. The repro has more detail in the README but I'm thinking it might have something to do with the following block in the JSON output of cypress + vite-istanbul-plugin:
I don't understand how this format works and can't find any good reference material anywhere, but this block doesn't appear in vitest output so it's possible the difference in statement maps is due to this. Grateful for any further insight you might provide.
Clear and concise description of the problem
I am trying to combine coverage results from vitest with coverage results from cypress (bundled with vite, instrumented with vite-plugin-istanbul). Merging coverage files does not work correctly because vitest instrumentation skips comments, types etc as requested and implemented in #5423, and vite-plugin-istanbul does not skip coverage of these (and also does not allow overriding this behaviour).
Without control over instrumentation for at least one of these (vitest OR vite-plugin-istanbul) there is no way for me to resolve the conflict.
Suggested solution
Provide some extra options in the
coverage
block that will override default instrumentation, such asAlternative
I am also going to raise a ticket for
vite-plugin-istanbul
to make a similar change, but ideally both packages would implement this change for maximum compatibility.Additional context
Istanbul instrumentation is configured here:
vitest/packages/coverage-istanbul/src/provider.ts
Lines 40 to 56 in 01a0552
For comparison, the equivalent in
vite-plugin-istanbul
is here. https://github.com/iFaxity/vite-plugin-istanbul/blob/44f780a997cb53956298b39faf6cd2284ea0a151/src/index.ts#L112-L120Validations
The text was updated successfully, but these errors were encountered: