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.
@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?
I apologize for the delay.
Yes, items in the /components are showing up twice in the report!
I've done a few small experiments:
Whatever this is it looks Windows-specific.
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 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 ).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).
I've removed cacheing in 2.1.1, can you see if this solved the issue?
First, the good news - It stopped crashing -- thanks!
Bad news is the "repeated" test is still appearing:
d:\tmp\jest-test7
λ npm run unit
> [email protected] 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.
If you're still having the second issue, please open a new issue with a reproduction that I can run.
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!
Most helpful comment
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
unitscript to use it - issue not present^21.1.0to 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).