Skip to content

codegen: keep code coverage comments #10091

@Boshen

Description

@Boshen

Upstream: vitest-dev/vitest#2021

There was also a request in the discord channel:

Istanbul ignores: https://github.com/istanbuljs/nyc?tab=readme-ov-file#parsing-hints-ignoring-lines
C8, V8 and node:coverage ignores: https://github.com/istanbuljs/v8-to-istanbul/blob/46b972458b40ea0d628c80dd60223cc909f81cd0/lib/source.js#L44-L81

These are poorly documented, and the ecosystem doesn't have conventions around this. Atm I'm building parser that can pick this regexp: https://github.com/AriPerkkio/ast-v8-to-istanbul/blob/f1424941cb3b1197b0a9a061b285fdc1b818e220/src/ignore-hints.ts#L13-L14 - but there's also the start, stop next 7 comments in original v8-to-istanbul.
I'd recommend to use this as reference in test cases. For example esbuild fails to pass legal comments that are between if and else nodes. It works as intended, but isn't great for testing tools. https://github.com/istanbuljs/istanbuljs/blob/main/packages/istanbul-lib-instrument/test/specs/if-hints.yaml

Metadata

Metadata

Assignees

Labels

A-codegenArea - Code Generation

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions