-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
/* istanbul ignore if */ does not change coverage reporting for if condition #2021
Comments
As a work-around for now you can use -/* istanbul ignore if */
+/* istanbul ignore if -- @preserve */
if (condition) { The root cause seems to be terser or esbuild removing the comments. This vitest/packages/vitest/src/node/plugins/coverageTransform.ts Lines 8 to 10 in f1cdfb6
|
@AriPerkkio That works for now, thanks! Will this need to be fixed in esbuild/terser? |
If this is indeed coming from But I'm still not sure, as I thought Vite was supposed to use I've tried to change the Vite's minifier but none of these have any effect: build: {
minify: 'terser',
terserOptions: { format: { comments: 'all' } },
}, |
TypeScript is processed by esbuild. JavaScript is left untouched.
These are placed under |
Thanks for the clarification @sheremet-va, that makes sense.
Yes, it seems that in Javascript sources the comments are preserved. For Typescript I don't think there is anything we can do here on vitest's side. evanw/esbuild#516 (comment) The only work-around is to use the |
Related PR from This won't solve everything but at least it extends the supported comment formats. |
* refactor: react jsx runtime respect tsconfig.json * chore: update pnpm-lock.yaml * style: update istanbul comment * test: workaround use istanbul ignore with esbuild ref: vitest-dev/vitest#2021 (comment) * chore: update
Describe the bug
/* istanbul ignore if */
should ignore anif
path from being considered for code coverage, but it doesn't with vitest. See the stackblitz for a reproducable example.Reproduction
https://stackblitz.com/edit/vitest-dev-vitest-ogxiag?file=util.ts
System Info
Used Package Manager
npm
Validations
The text was updated successfully, but these errors were encountered: