-
Notifications
You must be signed in to change notification settings - Fork 157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Coverage report incorrect #480
Comments
I've also been investigating this, in our case we do not use vite, but it seems to be related to babel 7 switching from https://github.com/babel/babel/blob/main/CHANGELOG.md#v71710-2022-04-29 |
After some poking around I also narrowed it down to something in babel (noticed coverage working again after downgrading a few packages). Thanks for that link. Wonder if this is outside scope of vue-jest then? |
I'm not really sure, I tried stepping through https://github.com/vuejs/vue-jest/blob/master/packages/vue2-jest/lib/generate-source-map.js and it seemed like it was not able to find the originalLine for many lines in the file. And from investigating the jest transforms cache an indicator of this problem is that the source map for the version with incorrect coverage does not have as much mapping data as the version with correct coverage. Its possible that vue-jest could address this by switching to https://github.com/jridgewell/trace-mapping instead of |
same problem on my application for several weeks. It's really very blocking. Do we have a solution? |
Any update? |
I have downgraded my Anyone with a proposed solution much appreciated |
Downgrading to 7.17.9 does not work because in My really ugly workaround is to to prevent "overrides": {
"@babel/generator": "<7.17.9"
} Then doing an Maybe knowing where the issue comes from more precisely will help maintainers? Edit: This solution works only for npm > 8.3.0 as overrides were introduced in this version. If you still use an older version, you can use @AnthonyRuelle solution |
I'm also having this issue. Is the above PR being considered for a resolution here? |
Same issue |
1 similar comment
Same issue |
Same issue ... 😩
Le mar. 26 juil. 2022 à 08:34, Yurii Rekechuk ***@***.***> a
écrit :
… Same issue
—
Reply to this email directly, view it on GitHub
<#480 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AWJ7JAH32ITDVPH2NZILRBTVV6BFPANCNFSM5ZOORPAA>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Using yarn we were able to fix this by locking both versions of "devDependencies": {
"@babel/core": "7.17.9"
},
"resolutions": {
"@babel/generator": "7.17.9"
}, We only use babel for jest so this doesn't have any other side effects for us, YMMV. |
Any solution how to fix this? Non of the SFC file <script> block code is covered. Only works with .js mixin files.
|
any potential fixes for this?.... having the same issue :( |
Waiting for the fix, in the package.json:
|
I still having this issue. hope it can be solved ASAP |
I have this issue: I tried all the workarounds in this post and no one works for me. Do we have a solution? |
I tried downgrade babel version and add |
Hi! sorry, can you share your package.json or versions of babel? Thnx |
Any update on it? |
same bug over here. I even get code red marked that has been demonstrably tested. on vue3 |
Is there any other workaround? Downgrading EDIT: Installing |
Well, I have a weird workaround after digging into the So, it seems like the old template compiler ( Vue2-jest has a weird handler for which one of these compilers it uses. Basically it does a try/catch, where if What ended up working for me, at least partially (I may still run into some unforeseen error), was to delete the try block and only use the code that was in the catch. So, only use (I am using yarn)
Basically, it pipes the My expectation is that the Vue team will eventually align the two compilers, but in the meantime, this seems to fix my jest coverage. NOTE: This is also using the |
This fix has stopped working quite time ago. So the next iteration of the workaround is (for npm >= 8): "overrides": {
"@babel/core": "7.17.9",
"@babel/generator": "7.17.9",
"istanbul-lib-instrument": "5.2.0"
} |
This workaround works for me with: "dependencies": {
"@types/cli-color": "^2.0.2",
"@types/i18n": "^0.13.5",
"ajv": "^8.11.2",
"axios": "^0.27.2",
"cli-color": "^2.0.3",
"colors": "^1.4.0",
"core-js": "^3.26.1",
"i18next": "^22.0.6",
"js-beautify": "^1.14.7",
"jwt-decode": "^3.1.2",
"lodash.clonedeep": "^4.5.0",
"register-service-worker": "^1.7.2",
"sanitize-html": "^2.7.3",
"uuid": "^9.0.0",
"vue": "^2.7.14",
"vue-class-component": "^7.2.6",
"vue-i18n": "^8.28.2",
"vue-json-viewer": "^2.2.22",
"vue-pdf-embed": "^1.1.5",
"vue-property-decorator": "^9.1.2",
"vue-router": "^3.6.5",
"vue-simple-markdown": "^1.1.5",
"vue-virtual-scroller": "^1.1.2",
"vuedraggable": "^2.24.3",
"vuejs-ace-editor": "^1.0.1",
"vuetify": "^2.6.12",
"vuex": "3.6.2",
"vuex-class": "^0.3.2",
"winston": "^3.8.2"
},
"devDependencies": {
"@4tw/cypress-drag-drop": "^2.2.1",
"@mdi/font": "^7.0.96",
"@playwright/test": "^1.28.0",
"@types/concat-stream": "^2.0.0",
"@types/jest": "^28.1.8",
"@types/js-beautify": "^1.13.3",
"@types/jsdom": "^20.0.1",
"@types/lodash.clonedeep": "^4.5.7",
"@types/mssql": "^8.1.1",
"@types/node": "^18.11.9",
"@types/sanitize-html": "^2.6.2",
"@types/uuid": "^8.3.4",
"@typescript-eslint/eslint-plugin": "^5.43.0",
"@typescript-eslint/parser": "^5.43.0",
"@vue/cli-plugin-babel": "^4.5.19",
"@vue/cli-plugin-eslint": "^4.5.19",
"@vue/cli-plugin-pwa": "^4.5.19",
"@vue/cli-plugin-typescript": "^4.5.19",
"@vue/cli-plugin-unit-jest": "^4.5.19",
"@vue/cli-service": "^4.5.19",
"@vue/eslint-config-prettier": "^6.0.0",
"@vue/eslint-config-typescript": "^10.0.0",
"@vue/test-utils": "^1.3.3",
"concat-stream": "^2.0.0",
"cypress": "9.7.0 ",
"eslint": "^6.8.0",
"eslint-plugin-prettier": "^3.4.1",
"eslint-plugin-tsdoc": "^0.2.17",
"eslint-plugin-vue": "^8.7.1",
"jest-fetch-mock": "^3.0.3",
"jest-junit": "^14.0.1",
"jest-slow-test-reporter": "1.0.0",
"jest-sonar-reporter": "^2.0.0",
"jsdom": "^20.0.2",
"jsdom-worker": "^0.3.0",
"mssql": "^9.0.1",
"node-fetch": "^2.6.7",
"playwright-chromium": "^1.28.0",
"prettier": "^2.7.1",
"sass": "^1.56.1",
"sass-loader": "^10.4.1",
"ts-jest": "^26.5.6",
"typescript": "4.6.4",
"vue-cli-plugin-vuetify": "^2.5.8",
"vue-template-compiler": "^2.7.14",
"vuetify-loader": "^1.9.2"
},
"overrides": {
"@babel/core": "7.17.9",
"@babel/generator": "7.17.9",
"istanbul-lib-instrument": "5.2.0"
} Only the breakpoints in script vue dont works fine when launch jest. Thanks all!!! |
This solved my issue #522, probably worth trying here as well? Upgrading couple of packages and editing jest.config.ts fixed the issue with coverage. package.json
jest.config.ts
|
@Envoy49 This topic talks about fixes for coverage reports. After following one of many fixes from this topic, the coverage reports issue was gone. I updgraded Jest from v27 to v28 || v29, and this error |
relates: vuejs/vue-cli#7129 |
I've tried various solutions listed in this thread. Setting |
Personally, the coverage started to be all wrong after I upgraded from Jest v26 to v29 (using Vue 2). All tests are passing, but the coverage is reporting uncovered lines from the template or simply lines that don't exist (i.e. reporting I tested all the workarounds mentioned in this issue, none of them has worked. Funny enough, the only thing that worked in my case was reverting the changes made in #486, then all went back to normal: my tests were passing and the coverage report was reporting the right uncovered lines. Does anyone else experience the same? You can test the revert by changing
We're using Vue 2.6.12 and |
Not sure about others, but at this stage we're planning to (hopefully) solve this by upgrading to Vue3 ¯_(ツ)_/¯ |
My coworker noticed this issue still persists with |
Yea, v8 works when it comes to coverage, but it is a huge tradeoff in favor of test speed and coverage report accuracy… would be really great to fix babel provider. |
I've been trying to get jest to work properly with a Vue 2 + Vite project. Jest reports pass/fail as I would expect, but the coverage report seems incorrect. Link to the repro here: https://github.com/qkjosh/vue-jest-coverage
package.json
Given an incomplete test suite, the coverage report indicates 100% coverage and seems to treat the whole SFC component as one statement. Do I have something completely misconfigured, or is the coverage report broken?
The text was updated successfully, but these errors were encountered: