-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
New Project with vue 2 + babel + typescript + jest doesn't work code coverage #7270
Comments
possible to add the testcase codes as well @GrRivero ? |
The reason why this happens for new projects is, that newer babel versions (> 7.17.9) generate different source maps, that vue2-jest does not understand. See:
This appears to have been fixed for vue-jest@28 with vuejs/vue-jest#486. Unfortunately vue-cli still uses jest@27 and vue-jest@27. So to fix this in vue-cli I see 2 options:
A workaround is to downgrade the babel dependencies in your vue-cli projects to versions <= 7.17.9, but this is rather cumbersome because there are so many of them. |
Sorry @vigneshwarankaliselvam I don't understand you well but you can reproduce the issue easy. You can install a new vue-cli project with vue2 + babel + typescript + jest and see the coverage. or You can use the link that i attached in the first post to run a repo with this params and one test modified |
This workaround maybe it's a good idea but it's not possible to maintain. In my project i see more than 100 references of babel, it's crazy!! For my part I think it's better to migrate vue-cli to jest@28 because if you create a new project with vue-cli doesn't work. But... It's no my decision :) |
Did you able to find any solution? @GrRivero |
@kaangokdemir
This requires some dependency locking, which I'm doing through yarn's resolutions property. In the meantime, I found another transient dependency that breaks code coverage in newer versions: "instanbul-lib-instrument" - hence the resolutions entry above. This setup works well for me with both vue@2 and vue@3. |
We have a news from other post: I applied the workaround and works more less fine. The coverage its god but in my case i can't use breakpoints in script vue: The workaround for me in npm is: "overrides": {
"@babel/core": "7.17.9",
"@babel/generator": "7.17.9",
"istanbul-lib-instrument": "5.2.0"
} |
Version
5.0.8
Reproduction link
github.com
Environment info
Steps to reproduce
Run test:unit:coverage script
What is expected?
A coverage under 100% with uncovered lines
What is actually happening?
See that the coverage is 100% with uncovered lines
It's a new clean project. But i reproduce this with other projects in vue2
The text was updated successfully, but these errors were encountered: