Closed Sec-ant closed 9 months ago
As I only do testing in dev mode and use this conditional compile plugin in build mode, I find a workaround to force this plugin to only work at build process:
In my vite.config.ts
, I extended the plugin return object with apply: "build"
and it solves my problem
plugins: [{ ...ConditionalCompile(), apply: "build" }]
When using this plugin and adding
// #v-ifdef DEV
and// #v-endif
comments in my code, vitest marks all code as 100% covered (istanbul).If I remove the directives, the coverage works again:
Similar issues can be found at:
This should be easily reproducible.Here is a minimal reproduction: https://stackblitz.com/edit/vitest-dev-vitest-4tlh7n?file=src%2Findex.ts
Is there a workaround to solve this problem?