vue 2开玩笑的覆盖范围不正确

发布于 2025-01-20 14:03:27 字数 1092 浏览 2 评论 0 原文

我使用

测试正常运行。但是覆盖范围是错误的。

在报告中,出于某种原因,它显示它只有1个语句,1个功能,2个分支。

它没有显示所有线路的覆盖范围。它显示了第一行的覆盖范围,并且在其他任何地方都不会显示覆盖范围。不知道这里是什么问题。

我正在使用bootstrap-vue渲染组件。这可以在覆盖范围内创建问题吗?我之所以问这个,是因为为Helloworld组件出现的示例spec.js正确显示了覆盖范围。

我的DEV依赖关系

"devDependencies": {
    "@babel/core": "^7.12.16",
    "@babel/eslint-parser": "^7.12.16",
    "@vue/cli-plugin-babel": "~5.0.0",
    "@vue/cli-plugin-eslint": "~5.0.0",
    "@vue/cli-plugin-unit-jest": "^5.0.4",
    "@vue/cli-service": "~5.0.0",
    "@vue/test-utils": "^1.3.0",
    "@vue/vue2-jest": "^27.0.0-alpha.2",
    "babel-jest": "^27.0.6",
    "eslint": "^7.32.0",
    "eslint-plugin-vue": "^8.0.3",
    "flush-promises": "^1.0.2",
    "jest": "^27.0.5",
    "node-sass": "^7.0.1",
    "sass-loader": "^12.6.0",
    "vue-template-compiler": "^2.6.14"
  },

I have setup unit testing using installation instructions from https://v1.test-utils.vuejs.org/

Tests are running properly. But the coverage is coming incorrectly.

In the report it is showing it has only 1 statement, 1 function, 2 branches for some reason.

It's not showing coverage for all the lines. It shows coverage in the first line and doesn't show coverage anywhere else. Don't know what's the issue is here.

I'm using Bootstrap-vue to render components. Can this create an issue with coverage? I'm asking this because the example.spec.js that came for the helloworld component is showing coverage correctly.

enter image description here

my dev dependencies

"devDependencies": {
    "@babel/core": "^7.12.16",
    "@babel/eslint-parser": "^7.12.16",
    "@vue/cli-plugin-babel": "~5.0.0",
    "@vue/cli-plugin-eslint": "~5.0.0",
    "@vue/cli-plugin-unit-jest": "^5.0.4",
    "@vue/cli-service": "~5.0.0",
    "@vue/test-utils": "^1.3.0",
    "@vue/vue2-jest": "^27.0.0-alpha.2",
    "babel-jest": "^27.0.6",
    "eslint": "^7.32.0",
    "eslint-plugin-vue": "^8.0.3",
    "flush-promises": "^1.0.2",
    "jest": "^27.0.5",
    "node-sass": "^7.0.1",
    "sass-loader": "^12.6.0",
    "vue-template-compiler": "^2.6.14"
  },

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文