Skip to content

@vitest/coverage-istanbul breaks when running tests in @vitest/browser with scss #8154

@alecgibson

Description

@alecgibson

Describe the bug

Trying to run coverage with:

Will accidentally try to instrument the SASS in an SFC.

This worked fine in @vitest/[email protected]

I suspect this bug was introduced by #7939 and we're running into issues because the transformed id looks like App.vue?vue&type=style&index=0&lang.scss, but the check is ignoring files that end in .css (which doesn't match .scss).

Reproduction

  1. Clone https://github.com/alecgibson/vitest-coverage-bug
  2. npm i
  3. npm test
  4. See errors in console about coverage trying to parse SCSS, when I would expect no errors

System Info

System:
    OS: macOS 15.5
    CPU: (10) arm64 Apple M1 Pro
    Memory: 124.19 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.9.0 - ~/.nvm/versions/node/v20.9.0/bin/node
    Yarn: 1.22.22 - ~/.yarn/bin/yarn
    npm: 10.1.0 - ~/.nvm/versions/node/v20.9.0/bin/npm
    pnpm: 10.5.2 - ~/.nvm/versions/node/v20.9.0/bin/pnpm
    bun: 1.0.15 - ~/.bun/bin/bun
  Browsers:
    Chrome: 137.0.7151.70
    Safari: 18.5
  npmPackages:
    @vitejs/plugin-vue: ^5.2.4 => 5.2.4 
    @vitest/browser: ^3.2.3 => 3.2.3 
    @vitest/coverage-istanbul: ^3.2.3 => 3.2.3 
    playwright: ^1.53.0 => 1.53.0 
    vite: ^6.3.5 => 6.3.5

Used Package Manager

npm

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    feat: coverageIssues and PRs related to the coverage featurep3-minor-bugAn edge case that only affects very specific usage (priority)

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions