Skip to content

c8 coverage seems broken when testing vue file with style tag #2539

@Polluux

Description

@Polluux

Describe the bug

Hi,
I'm using c8 for test coverage in a Vite/Vue project and encountered an issue while testing a .vue file with a <style> tag.
When having a <style> tag with content, coverage report indicate only 1 line, and 100% coverage.
Removing the tag content causes the coverage report to display correct values.
(Running test with istanbul does not raise this issue.)

Result:
Statements : 100% ( 1/1 )
Branches : 100% ( 0/0 )
Functions : 100% ( 0/0 )
Lines : 100% ( 1/1 )

Expected Result:
Statements : 91.66% ( 11/12 )
Branches : 0% ( 0/1 )
Functions : 100% ( 0/0 )
Lines : 91.66% ( 11/12 )

Reproduction

Here is a repository to reproduce : https://github.com/Polluux/demo-c8-issues
(Note : This repository contains multiple issues for c8)

System Info

System: 
  Ubuntu 22.04.1 LTS x86_64 GNU/Linux
Node:
  v16.15.1
Dependencies:
  "vue": "^3.2.45"
  "@vitejs/plugin-vue": "^4.0.0",
  "@vitest/coverage-c8": "^0.26.0",
  "@vue/test-utils": "2.2.6",
  "c8": "^7.12.0",
  "jsdom": "^20.0.3",
  "typescript": "^4.9.4",
  "vite": "^4.0.2",
  "vitest": "^0.26.0",
  "vue-tsc": "^1.0.14"

Used Package Manager

npm

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    feat: coverageIssues and PRs related to the coverage feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions