-
Notifications
You must be signed in to change notification settings - Fork 156
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
SFC Vue files with tests disappear from test coverage reports #422
Comments
Odd, definitely a bug. Is this something you might be interested in looking into? I'd recommend trying to reproduce it in this repo next, then we can easily debug, test and deploy a fix. You could add a test project here: https://github.com/vuejs/vue-jest/tree/master/e2e/3.x |
I've added a more minimal reproduction project there, though I don't know if I will have the free time to investigate further due to work commitments |
Facing the same here, I'm trying to find out something that could cause this but I not went so far
|
If anyone wants to take a look at this, it would be great! I'm too busy to look at |
for those who are interested: we had the same issue in our project and as workaround we returned to
for now until this issue is fixed. |
Interesting, we should find out the different between the code in v5 and |
We had the same issue, switching the reporter to V8 fixed it. |
Seeing exactly the same with recent version of (vue2 + vue-jest). Vue2 version 4.5.17, Vue-jest version 3.0.7. |
After my last comment, we've tried to reconstruct the coverage by downgrading. In the end, we also needed to downgrade So we are now in the situation that coverage is working again but with |
Why don't you just use V8? |
V8 is incredibly slow on a GitHub Actions runner and runs into OOM errors for large projects |
Hey, Is there a date announced for the correction of this bug? I'm waiting for this fix because on my application I have 100% coverage everywhere and it's really very annoying. I tried to revert to previous versions and without success. The update of the lock package following an audit fix was fatal for me Thx ! |
Can anyone share a working set of npm packages that gives correct coverage for Vue 2? We were previously using |
There's a tip here you can try which should resolve the issues with the latest version: vuejs/vue-cli#7040 (comment) |
The solution that is proposed is to use the coverprovider v8 + jest 27 is that it? Thanks in advance ! |
You could try If the latest versions has speed/OOM memory issues, we should just fix those. |
Question - does Vue CLI ship this w/ code coverage out of the box? Is it a bug here, or bug in the configuration in your project <-> Jest? |
I noticed something strange while testing with Vue 3. If the Vue SFC does not import anything itself, the test coverage is reported correctly. If there are any import statements in the SFC (even
module.exports = {
preset: '@vue/cli-plugin-unit-jest',
collectCoverageFrom: ['src/**/*.{vue,js}']
} Does anyone else see the same behavior?
EDIT: Switching the |
HI ! To unlock future people looking for a solution to this problem (myself included) it is therefore enough to put (temporarily) our versions in [email protected] and [email protected] and to pass the coverageProvider in "v8" is that right? I will try on my side if it allows me to recover a coherent coverage |
I have similar setup. Passing v8 for the coverageProvider give me the right statements count but still 0/0 of branches and functions count. |
You might want Vue Jest 3 is about 4 years old and is not updated. |
Thanks a lot @lmiller1990 ! Even though I keep getting wrong coverage 🙁 Just sharing my files // jest.conifg
collectCoverage: true,
testEnvironment: "jsdom",
testMatch: ["<rootDir>/**/*.(spec).(ts|tsx)"],
collectCoverageFrom: ["src/**/*.(vue|ts|js)"],
transform: {
"^.+\\.ts$": "ts-jest",
"^.+\\.vue$": "@vue/vue2-jest", // Update to match your installed version
},
coverageProvider: "v8",
coverageReporters: ["json", "lcov", "text-summary", "html"],
|
I have the same issue. Exists Workaround? I tried a lot of combinations but not work I have 100% of coverage allways in typescript code in .vue files. This is my last test:
and my jest.config.js:
Thanks! |
Silly question but is it possible you are actually getting 100% code coverage? Or are you just importing the component and not doing anything in your test? |
Sorry but it worked before and I don't know which library or libraries has stopped working. The tests work but it does not show coverage or allow real-time debugging in them. 😟 Edited to add new info: I triyed with a new project and the code coverage doesn´t work New project: https://github.com/GrRivero/vue2-jest-ts-coverage New Issue: vuejs/vue-cli#7270 Do you have thoughts on why that is happening this? Thanks! |
@GrRivero, I have done the same and also getting the same strange behavior. :/ |
* Update dependencies
* Add vue files to code climate * Add vue files to code climate * Remove unneeded flag Coverage is handled by npm run test in package.json * Add vuejs applications to codeclimate coverage * Move to after js testing * * Switch to v8 for test coverage. See vuejs/vue-jest#422. * Update dependencies * Bump node versions so vue tests can run via v8 * Set project root Co-authored-by: Ben Pennell <[email protected]>
Any update on it? |
* chore: use v8 coverageProvider for Jest See: vuejs/vue-jest#422 * chore: try running unit tests on macos-latest * chore: revert runner
Have the same issue. Tried all suggestions above and didn't work. |
@kaangokdemir what version of Jest and Vue Jest are you using? |
We have a news from other post: I applied the workaround and works more less fine. The coverage its god but in my case i can't use breakpoints in script vue: The workaround for me in npm is: "overrides": {
"@babel/core": "7.17.9",
"@babel/generator": "7.17.9",
"istanbul-lib-instrument": "5.2.0"
} |
I'm using [email protected] and [email protected]. Tried the @vue/vue2-jest and |
Thank you for the idea. This versions did not work but I rollbacked into the: "overrides": {
"@babel/core": "7.12.10",
"@babel/generator": "7.12.11",
"istanbul-lib-instrument": "4.0.3"
} then run Now I have my coverage backs and could continue with this intermediate solution. |
Vue Jest v3 hasn't been updated in years. If there's a bug in |
I have the same issue while using versions below: Some .vue files are missing from the coverage report, even if they have blocks of complex code covered/not covered by tests. I tried using workarounds described, but had no luck. Debug info: removing imports from <script> caused the issue to go away for a given file. In a fresh create-nuxt-app the symptom was 0/100% coverage report, instead of the file disappearing from the coverage report. Using coverageProvider: 'v8' fixes the issue of .vue files missing or having 0/100 coverage, but it's not a solution for me, as it's less precise, uses more resources, and causes reported coverage to be too high. detailed description of trade-offs |
Issue is being encountered all around the globe.... |
I hope someone including myself can look into it and hopefully create a PR to solve it |
Same - I don't have bandwidth to look into it right now, but happy to review a PR. |
@neatcoding Can someone please try this pre_release version: https://github.com/mhdSid/vue-jest/releases/tag/v30.0.0_pre I believe that this pre-release should fix coverage report for vue files. I have currently checked that it is working for vue/js components, but haven't yet tested it with vue /ts + coffee. Additionally, the pre-release requires test updates. |
I have published it to npm registry: experimentalCssCompile: false |
I have Jest setup to test files with
@vue/vue3-jest
and it runs all of the Vue tests just fine, however I came across a peculiar issue regarding test coverage - it was going down in our CI dashboard as I was testing more components.SFC Vue files without a
*.spec.js
test show up in the Jest coverage summary with zero coverage as expected. After adding a*.spec.js
for a component, it will no longer collect or be listed in the coverage summary in our project.Regular JavaScript files are unaffected and report coverage as expected.
I have a demo repository setup, however it only partially reproduces our issue -
@components/Demo.vue
is missing, but the two components in@components/demo/
show up fine (which doesn't happen in our project). Removing the@components/Demo.spec.js
makes it show up again with zero coverage.Demo: https://github.com/wopian/jest-coverage-demoDemo moved to PR: #423
With Demo.spec.js, coverage unreported
With Demo.spec.js.old, (zero) coverage reported
The text was updated successfully, but these errors were encountered: