Skip to content

v8 code coverage breaking Vitest 4 #9293

@hugs7

Description

@hugs7

Describe the bug

Hi. I noticed in Vitest 4, if you have a React component which is defined as an inline, the coverage won't work when using v8.

If you switch to istanbul, everything is okay. This wasn't an issue for me in vitest 3. In the lcov report it shows up like this

Image

Even though I definitely have a test for this component

Reproduction

export const SomeComponent = () => <div>Some simple component</div>

And test file

import { screen } from "@testing-library/react";

import { SomeComponent } from './SomeComponent.tsx';

describe('<SomeComponent />',  () => {
   it('should render without crashing', () => {
      render(<SomeComponent />);
      expect(screen)).toHaveTextContent("Some simple component");
   })
})

System Info

System:
    OS: Linux 6.8 Ubuntu 24.04.1 LTS 24.04.1 LTS (Noble Numbat)
    CPU: (20) x64 12th Gen Intel(R) Core(TM) i7-12700K
    Memory: 28.45 GB / 31.98 GB
    Container: No
    Shell: 5.2.21 - /bin/bash
  Binaries:
    Node: 25.0.0 - /home/hugo/.nvm/versions/node/v25.0.0/bin/node
    npm: 11.7.0 - /home/hugo/.nvm/versions/node/v25.0.0/bin/npm
  Browsers:
    Chrome: 142.0.7444.175
    Firefox: 145.0.2
    Firefox Developer Edition: 145.0.2
  npmPackages:
    @vitest/coverage-v8: ^4.0.16 => 4.0.16 
    vite: ^7.3.0 => 7.3.0 
    vitest: ^4.0.16 => 4.0.16

Used Package Manager

npm

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions