Tests failing with `No coverage available for <vue files only>`
See original GitHub issueOriginally posted at vuejs-templates/webpack; steps to reproduce the issue are in that post.
Tests were working on Saturday; they started failing last night (PST). JavaScript-only Jest tests without Vue components pass with coverage enabled. Vue tests pass if coverage is disabled.
Note: The setup for this is defect to simply use the vue-cli to install the webpack template and run npm run test
. I’m using Windows 10.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:7 (2 by maintainers)
Top Results From Across the Web
No coverage for .vue files when using Jest - Get Help
I'm using vue-test-utils with Jest to test single-file Vue components. Everything seems to be working fine, but I'm unable to generate ...
Read more >Jest is not collecting coverage from all my Vue files
I am testing a Vue3 project with Jest and I am facing this issue: I recently added Jest to my Vue project through...
Read more >Code Coverage for Vue Applications - Vue.js Developers
We do not want to instrument the production code. Let's only instrument the code when NODE_ENV=test since we will use the collected code ......
Read more >Jest | IntelliJ IDEA Documentation - JetBrains
If a snapshot does not match the rendered application, the test fails. This indicates that either some changes in your code have caused...
Read more >Snapshot Testing - Jest
If they match, the test will pass. If they don't match, either the test runner found a bug in your code (in the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I was able to throw a couple hours at this one today. I’ve got a successful (if limited) workaround and was able to determine that the issue was introduced with Jest v22.0.0. I also have some info that may help someone track this down or resolve.
Work Around Place the Jest configuration directly inside package.json following the vue test utils jest-example
Troubleshooting Activities
unit
script to use it - issue not present^21.1.0
to Jest22.0.0
- issue appears (experimented with several explicit 22.* versions; issue was introduced in 22.0.0, which unfortunately has a long changelist ).I futzed around with the config file for a while. For a bit I was hopeful that the
path.resolve()
was somehow involved because removing it caused the problem to disappear. I’m pretty sure this was a red herring (but not completely sure); the coverage report was simply “All files: Unknown”.The last piece of information while reviewing the coverage report itself. As @BeauAgst pointed out, the coverage report lists the tested Vue files twice, while the untested Vue files are only listed once. I’m not sure how many core devs use Windows so I’ll post a picture: I find it interesting that a file with no branches would report 50% coverage (while it’s peer shows 100% covered with 0% overall).
Thanks. I was away from jest for a bit and lost track of this. I tried it again the other day and did not notice the duplicated report anymore. Thanks again!