Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Vue SFCs not included in coverage reports #217
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
I'm using Jest at
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
All JS/Vue files live in a
Here are the relevant parts of the Jest configuration being used:
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.
Facing the same issue.
And my directory structure is:
Please let us know guys. Thought setting up complete unit-testing is not so difficult.
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...
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.