-
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
Vue SFCs not included in coverage reports #217
Comments
Facing the same issue.
And my directory structure is:
Please let us know guys. Thought setting up complete unit-testing is not so difficult. |
Having the same issue, tests run fine for SFCs but no coverage. vue-cli seems to get it right though and it appears to use vue-jest |
@TerminalSpirit Is there any other way you could suggest? We did not set up our project using vue-cli. |
sorry @sai-velamuri I'm still stuck myself. To prove it is possible to get the coverage I installed some of vue-cli's packages manually
I don't think that's a good approach though as at this point you might as well go ahead and use vue-cli properly. When I ran the tests it does include SFCs in the coverage. Scratching around those cli packages, it does look like there's work needed to get it to work (which they've done). Since they are also using vue-jest I can only think it's some kind of config issue. That's as far as I got with my rookie knowledge :) |
@TerminalSpirit this is useful, thank you for sharing. It seems like Adding these packages to
And then running That gives me the following report:
This is a decent solution for now but I'd still love to understand what options are actually being provided to Jest here that suddenly allows everything to work properly... |
See here for more info: vuejs/vue-jest#217 (comment) Running unit tests now outputs a coverage report that includes vue SFCs. Change-Id: I638810389ddc89351c4ec86638976f6d5c9f63c0
I was also facing this issue, your solution works perfect. Thanks! |
@egardner glad to hear it was of some help :) |
so that version of vue-cli-service seems to be using jest 24.9.0 I have exactly the same problem this post is talking about and I was running 25.1.0 Downgraded to 24.9.0 and coverage started working again. So major update of jest is breaking something with the vue-jest reporting. |
Probably fixed in jestjs/jest#9724 and |
Yes. It is fixed in 25.2.4 |
Great, I'll update my project to Jest 25 again (sans Vue-CLI tools) and confirm that the functionality is restored. Thanks to everyone who helped track down the problem here! |
From my side I can confirm that upgrading to Jest v25.2.4 restores ability to collect coverage reports from .vue files |
upgrading Jest works for me too! thanks all! |
Problem
I'm using vue-test-utils with Jest to run unit tests for single-file Vue components. I'm relying on vue-jest to transform the component files so that I don't have to rely on Webpack, etc.
I'm able to
require
Vue components in tests and run them without any problems, but for some reason I'm not able to get Jest to include these files in the coverage reports that it generates.I'm using Jest at
25.1.0
, vue-jest at3.0.5
, and vue at2.6.11
.One other thing I should note: for this project, my Vue components are all written in ES5 (plus module.exports and require statements; I’m relying on a non-JS module tool to deliver this code in browser). I'm not running any webpack or babel transformations on JS code either at runtime or in testing, just the vue-jest transform for SFCs. Everything works fine until it comes to generating the coverage report.
Source code is visible here: https://github.com/egardner/mediawiki-extensions-VueTest
Configuration
All JS/Vue files live in a
resources
folder which is structured like this:Here are the relevant parts of the Jest configuration being used:
Output
When I run the tests using Jest, I get output like this:
The tests (which require various Vue files) run and succeed, but the coverage report only includes the plain JS files.
Do Vue files need to be transformed with Webpack or Babel so that they can be assessed for coverage in Jest? I had assumed that the vue-jest transformations would allow for this.
The text was updated successfully, but these errors were encountered: