Nuxt.js: Jest coverage problem, 50% of non-existing branch is not tested

Created on 6 May 2020  路  1Comment  路  Source: nuxt/nuxt.js

Version

v2.12.2

Reproduction link

https://github.com/Uzwername/jest-coverage-problem-reproduction

Steps to reproduce

  1. Clone repository (see reproduction link).
  2. Install node_modules
  3. Run npx jest --coverage
  4. Go to coverage->lcov-report folder & open index.html in a browser.
  5. Check report for file "TheDesktopNavigation.vue"
  6. See the first line with <template> tag highlighted with yellow.
  7. Try to comment out all export's content in script tag of TheDesktopNavigation.vue.
  8. Repeat steps from 3 to 6 (the issue will persist).

What is expected ?

Report should show 100% coverage

What is actually happening?

The <template> tag is highlighted with yellow (which means uncovered branch) while there's only 5 lines of JS with 0 logical branches in the file.

Additional comments?

As a side note, other very similar components that follow the same folder/test structure work ok & show 100% coverage.

This bug report is available on Nuxt community (#c10620)
bug-report

Most helpful comment

@Uzwername When replacing your contents within <template> with

<FaIcon :icon="faCaretRight" />

I does show 100% coverage, also for branches.

Screenshot 2020-05-13 at 10 35 08

It seems you have to double check the contents of the <template>

>All comments

@Uzwername When replacing your contents within <template> with

<FaIcon :icon="faCaretRight" />

I does show 100% coverage, also for branches.

Screenshot 2020-05-13 at 10 35 08

It seems you have to double check the contents of the <template>

Was this page helpful?
0 / 5 - 0 ratings

Related issues

msudgh picture msudgh  路  3Comments

shyamchandranmec picture shyamchandranmec  路  3Comments

bimohxh picture bimohxh  路  3Comments

mattdharmon picture mattdharmon  路  3Comments

vadimsg picture vadimsg  路  3Comments