Skip to content
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

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

Closed
ccamarat opened this issue Jan 22, 2018 · 7 comments
Closed

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

ccamarat opened this issue Jan 22, 2018 · 7 comments
Labels

Comments

@ccamarat
Copy link

ccamarat commented Jan 22, 2018

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.

@metacurb
Copy link

metacurb commented Feb 8, 2018

@ccamarat I ran into this issue this morning, and couldn't work out for the life of me what the problem was. All of my files were doubling up in the coverage report too, was that happening to you?

I ended up back-tracking over what I'd done since yesterday, and I'd moved some tests into a directory inside of specs. Apparently, for my setup this was a big no-no, and moving them back out of their own directory and back into specs fixed it. I'm not sure if that could be a possibility for you?

@ccamarat
Copy link
Author

I apologize for the delay.

Yes, items in the /components are showing up twice in the report!

I've done a few small experiments:

  • Moved the spec up one level to \test\unit per @BeauAgst's suggestion - No change
  • Upgraded from Node 8.9.3 / NPM 5.5.1 to Node 8.9.4 / NPM 5.6.0 - No change
  • Tried same project on Lubuntu - Issue goes away
  • Tried same project on Bash for Windows - Issue goes away

Whatever this is it looks Windows-specific.

@ccamarat
Copy link
Author

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).

@eddyerburgh
Copy link
Member

I've removed cacheing in 2.1.1, can you see if this solved the issue?

@ccamarat
Copy link
Author

ccamarat commented Mar 5, 2018

First, the good news - It stopped crashing -- thanks!

Bad news is the "repeated" test is still appearing:

d:\tmp\jest-test7
λ npm run unit

> jest-test7@1.0.0 unit d:\tmp\jest-test7
> jest --config test/unit/jest.conf.js --coverage

 PASS  test\unit\specs\HelloWorld.spec.js
  HelloWorld.vue
    √ should render correct contents (25ms)

----------------|----------|----------|----------|----------|-------------------|
File            |  % Stmts | % Branch |  % Funcs |  % Lines | Uncovered Line #s |
----------------|----------|----------|----------|----------|-------------------|
All files       |     91.3 |       50 |    83.33 |       80 |                   |
 HelloWorld.vue |      100 |       50 |      100 |      100 |   102,103,104,105 |
 HelloWorld.vue |        0 |      100 |        0 |        0 |             89,90 |
----------------|----------|----------|----------|----------|-------------------|
Test Suites: 1 passed, 1 total
Tests:       1 passed, 1 total
Snapshots:   0 total
Time:        3.784s
Ran all test suites.

d:\tmp\jest-test7

I guess that's a separate problem - who'd have thunk it? LMK if I should open a new defect for it.

@eddyerburgh
Copy link
Member

If you're still having the second issue, please open a new issue with a reproduction that I can run.

@ccamarat
Copy link
Author

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants