VUE 2覆盖范围问题:为VUE 2和VUE 3获得不同的行为

发布于 2025-02-08 19:49:53 字数 1694 浏览 1 评论 0 原文

我使用

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

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

这与Vue 2不使用,而是使用Vue 3的工作。

包裹: { “名称”:“ vue_three_without_ts”, “版本”:“ 0.1.0”, “私人”:是的, “脚本”:{ “服务”:“ vue-cli服务服务”, “构建”:“ vue-cli服务构建”, “测试:单位”:“ Vue-CLI服务测试:单位”, “ lint”:“ Vue-Cli-Service lint” },, “依赖关系”:{ “ core-js”:“^3.8.3”, “ vue”:“^3.2.13” },, “ devDectiencies”:{ “@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.0”, “@vue/cli-service”:“ 〜5.0.0”, “@vue/test-utils”:“^2.0.0-0”, “@vue/vue3-jest”:“^27.0.0-alpha.1”, “ babel-jest”:“^27.0.6”, “ eslint”:“^7.32.0”, “ eslint-plugin-vue”:“^8.0.3”, “开玩笑”:“^27.0.5” } }

vue3

软件包: { “名称”:“ vue_two_without_ts”, “版本”:“ 0.1.0”, “私人”:是的, “脚本”:{ “服务”:“ vue-cli服务服务”, “构建”:“ vue-cli服务构建”, “测试:单位”:“ Vue-CLI服务测试:单位”, “ lint”:“ Vue-Cli-Service lint” },, “依赖关系”:{ “ core-js”:“^3.8.3”, “ vue”:“^2.6.14” },, “ devDectiencies”:{ “@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.0”, “@vue/cli-service”:“ 〜5.0.0”, “@vue/test-utils”:“^1.1.3”, “@vue/vue2-jest”:“^27.0.0-alpha.2”, “ babel-jest”:“^27.0.6”, “ eslint”:“^7.32.0”, “ eslint-plugin-vue”:“^8.0.3”, “开玩笑”:“^27.0.5”, “ vue-template-compiler”:“^2.6.14” } }

vue2

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.

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.

This is not working with Vue 2. But with Vue 3 its working.

Package:
{
"name": "vue_three_without_ts",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"test:unit": "vue-cli-service test:unit",
"lint": "vue-cli-service lint"
},
"dependencies": {
"core-js": "^3.8.3",
"vue": "^3.2.13"
},
"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.0",
"@vue/cli-service": "~5.0.0",
"@vue/test-utils": "^2.0.0-0",
"@vue/vue3-jest": "^27.0.0-alpha.1",
"babel-jest": "^27.0.6",
"eslint": "^7.32.0",
"eslint-plugin-vue": "^8.0.3",
"jest": "^27.0.5"
}
}

Vue3

package:
{
"name": "vue_two_without_ts",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"test:unit": "vue-cli-service test:unit",
"lint": "vue-cli-service lint"
},
"dependencies": {
"core-js": "^3.8.3",
"vue": "^2.6.14"
},
"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.0",
"@vue/cli-service": "~5.0.0",
"@vue/test-utils": "^1.1.3",
"@vue/vue2-jest": "^27.0.0-alpha.2",
"babel-jest": "^27.0.6",
"eslint": "^7.32.0",
"eslint-plugin-vue": "^8.0.3",
"jest": "^27.0.5",
"vue-template-compiler": "^2.6.14"
}
}

Vue2

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

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

发布评论

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