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

Duplicate text-summary or text coverage report #3439

Closed
MkMan opened this issue May 24, 2023 · 5 comments · Fixed by solidjs/vite-plugin-solid#101
Closed

Duplicate text-summary or text coverage report #3439

MkMan opened this issue May 24, 2023 · 5 comments · Fixed by solidjs/vite-plugin-solid#101
Labels

Comments

@MkMan
Copy link

MkMan commented May 24, 2023

Describe the bug

When running vitest with coverage reporting using either text or text-summary reporter, the reported coverage is duplicated in the terminal.

> [email protected] test /home/mkman/dev/my-app
> vitest run --coverage


 RUN  v0.31.1 /home/mkman/dev/my-app
      Coverage enabled with c8

 ✓ src/app.test.ts (1)

 Test Files  1 passed (1)
      Tests  1 passed (1)
   Start at  18:55:31
   Duration  656ms (transform 38ms, setup 0ms, collect 8ms, tests 2ms, environment 0ms, prepare 99ms)

 % Coverage report from c8

=============================== Coverage summary ===============================
Statements   : 0% ( 0/42 )
Branches     : 100% ( 0/0 )
Functions    : 0% ( 0/2 )
Lines        : 0% ( 0/42 )
================================================================================
-----------|---------|----------|---------|---------|-------------------
File       | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
-----------|---------|----------|---------|---------|-------------------
All files  |       0 |      100 |       0 |       0 |                   
 App.tsx   |       0 |      100 |       0 |       0 | 1-27              
 index.tsx |       0 |      100 |       0 |       0 | 1-15              
-----------|---------|----------|---------|---------|-------------------

=============================== Coverage summary ===============================
Statements   : 0% ( 0/42 )
Branches     : 100% ( 0/0 )
Functions    : 0% ( 0/2 )
Lines        : 0% ( 0/42 )
================================================================================
-----------|---------|----------|---------|---------|-------------------
File       | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
-----------|---------|----------|---------|---------|-------------------
All files  |       0 |      100 |       0 |       0 |                   
 App.tsx   |       0 |      100 |       0 |       0 | 1-27              
 index.tsx |       0 |      100 |       0 |       0 | 1-15              
-----------|---------|----------|---------|---------|-------------------

Reproduction

Run the test script in this repo

System Info

System:
    OS: Linux 5.19 Ubuntu 22.04.2 LTS 22.04.2 LTS (Jammy Jellyfish)
    CPU: (12) x64 AMD Ryzen 5 5600U with Radeon Graphics
    Memory: 9.12 GB / 13.51 GB
    Container: Yes
    Shell: 3.6.1 - /usr/bin/fish
  Binaries:
    Node: 18.13.0 - /run/user/1000/fnm_multishells/15846_1684918295743/bin/node
    npm: 8.19.3 - /run/user/1000/fnm_multishells/15846_1684918295743/bin/npm
  Browsers:
    Brave Browser: 113.1.51.118
    Chrome: 113.0.5672.126
  npmPackages:
    @vitest/coverage-c8: ^0.31.1 => 0.31.1 
    vite: ^4.1.1 => 4.1.1 


### Used Package Manager

pnpm

### Validations

- [X] Follow our [Code of Conduct](https://github.com/vitest-dev/vitest/blob/main/CODE_OF_CONDUCT.md)
- [X] Read the [Contributing Guidelines](https://github.com/vitest-dev/vitest/blob/main/CONTRIBUTING.md).
- [X] Read the [docs](https://vitest.dev/guide/).
- [X] Check that there isn't [already an issue](https://github.com/vitest-dev/vitest/issues) that reports the same bug to avoid creating a duplicate.
- [X] Check that this is a concrete bug. For Q&A open a [GitHub Discussion](https://github.com/vitest-dev/vitest/discussions) or join our [Discord Chat Server](https://chat.vitest.dev).
- [X] The provided reproduction is a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) of the bug.
@AriPerkkio AriPerkkio added the feat: coverage Issues and PRs related to the coverage feature label May 24, 2023
@AriPerkkio
Copy link
Member

When the vite-plugin-solid is removed, coverage results are not duplicated.

export default defineConfig({
-  plugins: [solidPlugin()],

@AriPerkkio
Copy link
Member

AriPerkkio commented May 24, 2023

The vite-plugin-solid seems to duplicate config.test. Removing this line from the plugin resolves the issue. It's not just coverage options that get duplicated.

https://github.com/solidjs/vite-plugin-solid/blob/66955a81de1e6b84e02271e4f8603500b45656cb/src/index.ts#L328

It can return a partial config object that will be deeply merged into existing config
https://vitejs.dev/guide/api-plugin.html#config

@AriPerkkio AriPerkkio added upstream and removed feat: coverage Issues and PRs related to the coverage feature labels May 24, 2023
@MkMan
Copy link
Author

MkMan commented May 25, 2023

Thanks for looking into this and writing a fix so quickly @AriPerkkio 🙏

@GitMurf
Copy link

GitMurf commented Aug 30, 2023

I can confirm the same thing! And as @AriPerkkio alluded to, it is not just duplicating the report itself but it is actually running all the unit tests twice! The way to test is to add beforeEach() and/or afterEach() to a few tests and add a console log and you will see they duplicate all the tests themselves.

See here where I show my initial example/issue: solidjs/vite-plugin-solid#112 (comment)

image

@AriPerkkio
Copy link
Member

Fixed by solidjs/vite-plugin-solid#101. Please wait for Solid to publish new release and test whether it fixes the issue.

@github-actions github-actions bot locked and limited conversation to collaborators Oct 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants