Open pasanenf opened 1 year ago
yeah,same question,has any solution?
Running into this issue too. Coverage seems to default to 100% when components which use <script setup>
that don't have their own tests run are imported into a file which is being tested. If their own tests are run then coverage is calculated properly.
If you change the component to not use <script setup>
then it doesn't default to 100% but this is not really a viable solution.
I am experiencing the same issue as #422 with some Vue files not included in the coverage report, so I decided to try changing to v8 as recommended. However, using v8, used files without tests are being reported as having 100% coverage.
In the repo below, there are tests for two components, RedirectLink and Anchor. There is another component (ArrowLink) that is not used, and it is being correctly reported with 0% coverage.
Repo: https://github.com/pasanenf/jest-coverage-bug
RedirectLink is using Anchor to display links, and Anchor is being stubbed in the tests. The stub is not the Anchor component mentioned above, but another one under
__mocks__
. (Even if Anchor is not stubbed, coverage is the same.)Anchor has also got tests, but it is only using standard HTML. There are a few branches and functions in the code, so I'd expect these to be counted in the report, even if I'm not actually testing Anchor.
When testing only the RedirectLink component, the Anchor component is reported with 100% coverage.
However, test everything, and the coverage changes.
Is this the expected behavior? I'd expect the coverage for Anchor to be the same, even if I'm not specifically testing Anchor. Btw, removing the tests for Anchor and running
yarn test
also results in 100% coverage for Anchor.