Skip to content

Coverage ignore hints (/* istanbul ignore next */, /* v8 ignore next */) are broken with Vite 8 #9918

@marzelc

Description

@marzelc

Describe the bug

Coverage ignore hints no longer have any effect when running on Vite 8.
Annotated branches are still reported as uncovered, causing coverage threshold failures.

Vite 8 dropped esbuild entirely in favor of Oxc. Oxc seems to strips all comments during transformation and I found no option to preserve them. So, by the time the coverage plugin receives the code, the ignore hints are gone.

Reproduction

With or without @preserve the if is still considered as uncovered by istanbul despite the ignre

/* istanbul ignore if -- @preserve */
if (condition) {
  return false;
}

System Info

Environment                                                                                                                                                                                                                                                                                                                                                     
  - vitest: 4.1.0                                                                                                                                                                                                                                                                                                                                                 
  - @vitest/coverage-istanbul: 4.1.0                                         
  - vite: 8.0.1

Used Package Manager

yarn

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    feat: coverageIssues and PRs related to the coverage featureupstream

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions