question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Tests failing with `No coverage available for <vue files only>`

See original GitHub issue

Originally 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:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
ccamaratcommented, Feb 19, 2018

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

  • Tried the Vue Test Utils Jest Example: Issue not present
  • Compared the Vue Webpack Template looking for differences
    1. Copied the config file from the template to the test utils and updated unit script to use it - issue not present
    2. With above config file in place, updated Jest from ^21.1.0 to Jest 22.0.0 - issue appears (experimented with several explicit 22.* versions; issue was introduced in 22.0.0, which unfortunately has a long changelist ).
    3. Backed out config file change from #i (using example’s package.json config) - issue not present

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: image I find it interesting that a file with no branches would report 50% coverage (while it’s peer shows 100% covered with 0% overall).

0reactions
ccamaratcommented, Jan 10, 2019

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!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found