Skip to content
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

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

Closed
6 tasks done
Polluux opened this issue Dec 20, 2022 · 1 comment · Fixed by #2591
Closed
6 tasks done

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

Polluux opened this issue Dec 20, 2022 · 1 comment · Fixed by #2591
Labels
feat: coverage Issues and PRs related to the coverage feature

Comments

@Polluux
Copy link

Polluux commented Dec 20, 2022

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

@sheremet-va sheremet-va added bug feat: coverage Issues and PRs related to the coverage feature labels Dec 20, 2022
@AriPerkkio
Copy link
Member

This one is weird. There seems to be some flakiness in how sourcemaps load. I can reproduce the issue about 70% times, but rest of the runs work fine. When coverage is incorrect, the sourcemaps seem to be missing source and sourceContent.

~30% of the runs look fine, as below.

--------------|---------|----------|---------|---------|-------------------
File          | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
--------------|---------|----------|---------|---------|-------------------
All files     |   93.33 |        0 |     100 |   93.33 |                   
 StyleTag.vue |   93.33 |        0 |     100 |   93.33 | 3                 
--------------|---------|----------|---------|---------|-------------------

=============================== Coverage summary ===============================
Statements   : 93.33% ( 14/15 )
Branches     : 0% ( 0/1 )
Functions    : 100% ( 0/0 )
Lines        : 93.33% ( 14/15 )
================================================================================

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feat: coverage Issues and PRs related to the coverage feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants