Skip to content

<template> line is shown as not covered if v-if used in component (4.6+, 5.0+) #368

Closed
vuejs/core
#13285
@TheJaredWilcurt

Description

@TheJaredWilcurt

Related plugins

Describe the bug

In 4.5.2 and below components with v-if would have 100% test coverage, now with 4.6.0 and above they will report the first line of the Vue component (<template>) as not being covered in tests.

template-coverage

I've made the min-repro as simple as possible, it boils down to this:

Example:

<template>
  <div v-if="true"></div>
</template>

<script>
export default {
  name: 'App'
};
</script>
import { shallowMount } from '@vue/test-utils';

import App from '../../src/App.vue';

describe('App.vue', () => {
  test('Shallow mount', async () => {
    const wrapper = shallowMount(App);

    expect(true)
      .toEqual(true);
  });
});

Reproduction

https://github.com/TheJaredWilcurt/vite-plugin-vue-min-repro

Steps to reproduce

  1. clone repo
  2. npm install
  3. npm t

System Info

Tested on Node 20 and 21, Ubuntu 22.04 LTS and also GHA.

Used Package Manager

npm

Logs

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions