窗口.__ coverage__ __不显示Vue3 vitejs vite-plugin-istanbul配置之后的任何内容

发布于 2025-01-31 20:07:16 字数 967 浏览 4 评论 0原文

我正在尝试用于VUE3 VITE应用程序的代码覆盖范围。 这是Vue3 Vite App Creation Creation指令。我正在使用vite-plugin-istanbul lib来仪器代码,但是在配置后,它仍未在窗口中显示任何内容。我的配置如下:

// 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

在此之后,我运行应用程序npm Run Dev(即NPX VITE)和尝试Window。 >。我已经设置/导出vite_coverage = true,但仍然无法正常工作。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

牛↙奶布丁 2025-02-07 20:07:16

您已经声明seecreenv:true,这意味着伊斯坦布尔期望有环境变量vite_coverage存在并设置为true以跟踪文件。

您应该在.env。*文件中设置vite_coverage = true,然后重试。另外,您可以删除seepenteenv行并以这种方式尝试,因为伊斯坦布尔将默认情况下仪器代码。

You have declared requireEnv: true which means istanbul is expecting there to be the environment variable VITE_COVERAGE present and set to true in order to track files.

You should set VITE_COVERAGE=true inside your .env.* files and then try again. Alternatively, you can remove the requireEnv line and try that way, as Istanbul will instrument your code by default.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文