vue-jest: Code coverage seems to be collected incorrectly
I am looking to upgrade several projects to Vue 3 and I am running into an interesting issue when collecting code coverage. For some reason, when switching to Vue 3, the code coverage statistics are incorrect, but the tests are running correctly. Below is a repository that minimally reproduces the issue I am running into. Also attached are a couple of screenshots that show the difference in coverage between Vue 2 and Vue 3.
https://github.com/sam-pastoriza/vue-3-coverage
With Vue 2, you get the following coverage in the repo.
With Vue 3, you get the following coverage, without changing the tests.

A readme file in that repository details how I switch between Vue 2 and Vue 3.
A couple of notes on the structure of the project I am working with.
- We use
vue-class-componentas a library. I don’t think this is causing the issue, but I could be wrong. - We are required to split up the components into separate .ts and .vue files.
Many thanks for the help. Hopefully this is the right place to post this issue.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 1
- Comments: 17 (10 by maintainers)
This is most likely a bug in
vue-jestwhich isn’t handling source maps correctly - test utils just provides some basic functions likemount, the problem lies in the mapping between the source (vuefile) and output (compiled viavue-jestinto something Jest can read).Either way this is a very good reproduction, thank you!
I’ll move this issue to vue-jest, which I desperately need to find time to work on…
It’s out:
https://github.com/vuejs/vue-jest/releases/tag/v5.0.0-alpha.9
Hi! Sure. I will do a release by the end of this week, since we had a bunch of stuff merged up. I didn’t realize it had been so long since we did a release on the next branch.
We might want to look into sem-release so we can have stuff in the wild asap at some point 🤔
The vue2 output was wrong.
@lmiller1990 #331 should fix this.
@saksham-malhotra try #330