Skip to content

Add ignore start and ignore stop coverage ignore hints #9203

@AriPerkkio

Description

@AriPerkkio

Clear and concise description of the problem

In Vitest v3 it was possible to use ignore start and ignore stop code coverage ignore hints on V8 coverage. This was possible due to usage of v8-to-istanbul. However v8-to-istanbul had really limited support for ignore hints as it doesn't operate on AST level - it did not support ignore if, ignore else or ignore next. Also v8-to-istanbul reports inaccurate coverage results which was the main reason to replace it.

Users on Vitest v3 got used to ignore start and ignore stop and have been asking its support in:

One major difference in v8-to-istanbul's ignore hint support is that it "parsed" (regex match against text file) the original source file instead of the transpiled runtime code. This made it possible to use ignore hints even when the compiler (99% of times Vue) removed comments, or placed the generated code on different line.

Note that istanbul-lib-instrument has never supported ignore start/stop in its 13 years of existence. This is just a work-around v8-to-istanbul had to come up with due to its lack of AST analysis.

Suggested solution

Add support for ignore start and ignore stop to upstream packages. These ignore hints should be parsed from the original source text file, not from the transpiled runtime code.

Alternative

Have the same conversation over and over again explaining the difference between these coverage tools.

Additional context

Support for V8 coverage:

Support for Istanbul coverage:

Validations

Metadata

Metadata

Assignees

Labels

feat: coverageIssues and PRs related to the coverage featurep2-nice-to-haveNot breaking anything but nice to have (priority)

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions