I am trying code coverage for my vue3 vite application. Here are Vue3 vite app creation instructions. I am using vite-plugin-istanbul lib to instrument the code, but it is still not showing anything in window.__coverage__ variable after configuration. My configurations are given below:
// vite.config.ts
import istanbul from "vite-plugin-istanbul"
export default defineConfig({
envPrefix: "FRONTEND_",
plugins: [
vue({
template: { transformAssetUrls },
}),
istanbul({
include: "src/*",
exclude: ["node_modules", "test/"],
extension: [".js", ".ts", ".vue"],
requireEnv: true
}),
],
build: {
sourcemap: true,
},
})
# .env
VITE_COVERAGE=true
After this I run app npm run dev(i.e. npx vite) and trying window.__coverage__ in browser console but getting undefined. I have set/export VITE_COVERAGE=true but still it is not working.