-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Jest coverage showing 1/1 statements for .vue file when file has import #7040
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
Comments
I'm experiencing the same problem. |
Same problem for me |
Same issue here, have checked to see if an upgrade to jest 28.0.0 made a difference, but it didn't. Using the default coverageProvider: Perhaps related: vuejs/vue-jest/issues/422 |
I've tried downgrading to jest/ts-jest/babel-jest 26 and vue-jest 4 and even that didn't make a difference in the behaviour above, which is really weird.. I know I've seen this working correctly before... 😒 |
I use vue-cli 4.5.17 on another project and this started happening for me couple of weeks ago after I updated package-lock.json. I guess because of some babel packages were updated. |
Yeah.. i'm currently running old pipelines to see if I can pin-point which upgrade caused this exactly |
I dealt with this problem a while back, trying to get tests working. I boiled it down to a single line in my package.json, it was when I tried to update I'm trying to get it to work with 5.0.4, but nothing I do seems to have any effect. I need to update to this version now, though, so I'm just going to deal with it, I suppose. If it's not clear to everyone what's going on here, your export and import statements are causing the code you're importing/exporting to be ignored. You can get coverage on much of your code simply by changing code like this: export default {
data() {
}
} Into code like this: const Component = {
data() {
}
}
export default Component Yes, I recognize that's a hassle. I didn't make the bug I'm just dealing with it, lol. |
Unfortunately that doesn't help. I still see coverage being reported only on the lines that are outside of the <script>
/** COVERED **/
import xyz from 'some-package'
import { somethingElse } from 'another-package'
const Component = {
/** -- **/
/** NOT COVERED **/
data() { return { ... } },
methods: { ... },
}
/** -- **/
/** COVERED **/
export default Component
/** -- **/
</script> |
Hi, We are seeing the same issue. Upgraded to node16 and lost our coverage (widget only). I've tried locking @vue/cli-plugin-unit-jest@4.5.17 to that version and that didn't help. Manually breaking up our single file components into javascript component object and .vue files does work around the issue but its super ugly. This is quite a big issue for us as we like to have 100% coverage which is imposible if you can't test for it. We can't migrate to vue3 yet as we just have too much code. Package versions: Any help would be greatly appreciated. Cheers |
Try making sure all of the vue-cli stuff you can is version 4.5.17. I found that ultimately that was my problem and I was able to fix the issue by making sure my versions matched across those particular packages. |
I have the same issue. Exists Workaround? I tried a lot of combinations but not work I have 100% of coverage allways in typescript code in .vue files. This is my last test:
and my jest.config.js:
Thanks! |
I triyed with a new project and the code coverage doesn´t work New project: https://github.com/GrRivero/vue2-jest-ts-coverage New Issue: #7270 Do you have thoughts on why that is happening this? Thanks! |
I have one project using One workaround I have found is to asynchronously load imported components (does not work with other imports such as mixins or common js)
|
Version
5.0.1
Environment info
Steps to reproduce
Create project using vue create (manually, make sure to select Babel and Unit Testing as options, select Vue 2, select Jest as unit testing solution).
Add collectCoverage: true to jest.config.js/package.json.
Make random component and import it inside HelloWorld.vue, also add random method inside HelloWorld.vue.
What is expected?
After running npm run test:unit coverage should report that HelloWorld.vue has lines that are not covered
What is actually happening?
Coverage reports that HelloWorld.vue has 100% coverage and that it has 1/1 statements
The text was updated successfully, but these errors were encountered: