Open GrRivero opened 1 year ago
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 https://github.com/vuejs/vue-jest/pull/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.
possible to add the testcase codes as well @GrRivero ?
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
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.
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 I settled on the following workaround for my projects: Instead of fixing the babel dependencies, I'm now using vue-cli@5 with jest@28, which works quite nicely.
"devDependencies": {
"@types/jest": "^28.0.0",
"@vue/cli-plugin-babel": "~5.0.8",
"@vue/cli-plugin-unit-jest": "~5.0.8",
"@vue/cli-service": "~5.0.8",
"@vue/vue3-jest": "^28.0.0",
"jest": "^28.0.0",
"jest-environment-jsdom": "^28.0.0",
"ts-jest": "^28.0.0",
},
"resolutions": {
"@types/jest": "^28.1.8",
"babel-jest": "28.1.3",
"istanbul-lib-instrument": "5.2.0",
"jest": "28.1.3"
}
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.
Did you able to find any solution? @GrRivero
We have a news from other post:
https://github.com/vuejs/vue-jest/issues/480
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:
https://github.com/vuejs/vue-jest/issues/480#issuecomment-1328691421
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