-
Notifications
You must be signed in to change notification settings - Fork 157
Source map files disappear from coverage report #32
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
Comments
I created simple example: https://github.com/tmy/vue-jest-map-coverage-issue-sample
|
I've had some issues aswell: 1/ Using an older version of vue-jest and the 2/ We migrated the source code to a more recent |
Hi, I'm the original author of this PR on vue-template/webpack repo I think the problem come from Jest itself. |
I've got some updates on this issue: my coverage report is bugged on my Windows 10 machine (even with a fresh install of my repo), but testing inside Docker or on CircleCI provides a coverage report that seem correct. EDIT: This is maybe a different issue as I have all of my files listed on the coverage, but with some inexisting |
@tsauvajon are you sure about this? Configurations are the same? |
Looks like the missing files lack the data property. If the component doesn't have the data segment it is dropped from the coverage report. Adding an empty segment is enough to get it included.
|
@nirkki: I can confirm this fixed the exact same issue I had. Just added the data property back and coverage came in properly. |
I have a problem with mapCoverage too. I have some components with no logic at all in it, only html. Something like the following: GameInstruction.vue: <template>
<p>This game ... blah blah blah</p>
</template>
<script>
export default { }
</script>
<style></style> And looks like Jest is picking up the coverage with this config:
And the resulting coverage is 0%. 😢 I saw the comment mentioning about the absence of Is this the expected behaviour? Are we not suppose to have empty components that only have template? |
Definately not expected behaviour. |
Ok, coz I am new to testing in vue. I was just following the steps on the documentation on here and thought I was doing something wrong. Alright, now at lease I now I am not the only one. I will just add |
Hi,
Now this 3 component got better coverage. That's cool. But there is still some missing files 😢
Now the file Ps: I also tried to put data() in every .vue files (even if there are no tests on these files) but it didn't change anything. |
@maxpou I find removing |
Hi, See related pull request and comments from the @codecov bot maxpou/gitvub#43 The only thing that worry me is I don't know what's happened. |
Sounds awesome! I will try it out later. I though Jest has remove the option mapCoverage? |
yes this option is now deprecated! |
Still something strange going on with the data() -blocks. Strange thing is that there are some files where the data block is not the last but the coverage is still working as expected. Is this some sort of timing problem where the parallel tests somehow affect each other? |
@nirkki What OS are you using? Can you try deleting this line in the package and see if it solves the issue—https://github.com/vuejs/vue-jest/blob/master/vue-jest.js#L6 |
Oh yes, removing |
I've removed cacheing in 2.1.1, can you see if this solved the issue? |
Updated to 2.1.1 |
Is the fix for this still to add an empty |
same here |
Hi. I'm using vue-jest 2.5 with vue 2.5.16 and am also getting the problem with coverage. To try to isolate the problem, I'm running jest with --no-cache option, and I can confirm that putting in a data block will put the vue file in the coverage report, and taking it out will remove it. |
Just to complement the information from my last post, I did some more testing and found that not only adding a data section will cause the file to appear in coverage, but also adding things like a "methods" or "computed" section with a dummy function or adding lifecyle hooks such as created will also "work". |
I'm also having this issue. Adding the data block combined with --no-cache helped partially. Why partially? Well, first let me briefly explain the project's composition: I've split my component into these files: [comp1.html, comp1.scss, comp1.js, comp1.spec.js, index.vue]. Then, the index.vue is like this:
So, after running the tests, the coverage is 100% on the index.vue but 0% on the comp1.js. |
Was a solution found for this other than adding the empty data? Using the latest versions of vue-jest, vue-cli (3.0.1) etc and only way I can get "dummy" components that have props only to appear in the coverage reports is to include the additional markup. |
@eddyerburgh I suggest we upgrade from |
We can upgrade the dev dependency, but I believe this issue still stands. This issue with source mapping still stands |
I have been dealing with this issue setting up a new project. It can be reproduced using the latest vue-cli (3.0.5) and following the "Creating a Project" guide (https://cli.vuejs.org/guide/creating-a-project.html#vue-create).
Edit
Run Notice that Edit
Run Notice that Thanks @nirkki for the workaround!! I have been parsing bug reports all evening with no luck as to what was causing this missing coverage. The package.json that results from the vue-cli build:
It's not a vue-cli issue, either, as I originally ran across the bug with a manual setup. In that scenario, the empty data segment also fixed the issue. That package json looks like:
|
I have also a strange issue. data () {
return {}
} THESE 2 files, will now be covered. The other 2 files have real data there (just an example): data () {
return {
items: [],
somethingElse: []
}
} Additional information (as mentioned by #32 (comment))
implemented (in addition to data)
These 2 files will not be under coverage, even with empty With |
that's crazy, why in the world we need to add data property so the component can be tested for vuejs component? and the ticket was opened since 2017............ is there something wrong with vue or with jest? any idea? Having the same trouble even upgrade jest to latest as well as vue to 2.5
|
The issue will be fixed by this PR. Sorry for the delay. |
Has anybody gotten code coverage to work for functional components? If I add |
...Srsly 🤦♂
Still seems to be an issue in |
Bump. @eddyerburgh–which vue-jest version fixes this? |
Is there a solution to this? |
It's the same thing for ava, or mocha. |
People have already figured this out.. 🤦♂ It's because of the lack of a data property. Merely add the following to your component, and it will show up. data() {
return {
// This solely exists to appear in the coverage report
};
} |
@range-of-motion It changes nothing to add an empty data. |
Right. But we're not gonna get much further with "this isn't working".. If you want this investigated, we need a test case. |
@range-of-motion I will create a repository to reproduce this. |
Hi,
I'm getting coverage issues with Jest.
When I set mapCoverage: true, some files disapear from the coverage report.
Example:
(I remove some file for a better readability. See full coverage report (link to travis build):
All sources files are available here: https://github.com/maxpou/gitvub and jest config here
Thank you
The text was updated successfully, but these errors were encountered: