-
Notifications
You must be signed in to change notification settings - Fork 45
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
tested vue single file components should show 100% code coverage instead of 0% #2463
Comments
Are you able to provide a simple example for us that has this problem? |
Hi @smcenlly I mean a props only component like this:
It will show as 0% code coverage even if you write a simple test. But if we put a computed property in there and test that, the code coverage will become 100%:
|
This is expected behavior due to the way Vue internals/Jest transforms SFC props-only components and is not related to Wallaby. In Wallaby App, you should see coverage reported as Using your example, I wrote the following test:
Using the jest CLI, my test passes but when I collect coverage from jest using
If I change the script to simply define a variable (e.g.
In order to report on coverage for single file components, Jest/Vue SFC script needs to contain executable JavaScript. You will see that the Vue repository also contains another issue about templates not being included in coverage calculations (vuejs/vue-jest#198), for example, in the case of If the Vue/Jest integration changes to support your scenario, Wallaby should then also report it correctly. |
@smcenlly thanks for taking the time to explain it :-) |
Issue description or question
Vue apps usually have many small components which are essentially functional: they receive props and render html. They are easy to test, but the code coverage stays at 0%. Code coverage is useful because it shows at a glance what components haven't been tested yet, so 0% is misleading. Could you add a feature which treats these components like pure functions: if all the props are tested they should report 100% code coverage?
The text was updated successfully, but these errors were encountered: