nyc icon indicating copy to clipboard operation
nyc copied to clipboard

Feature: ignore next 3

Open TheJaredWilcurt opened this issue 2 months ago • 1 comments

Vitest 4 switched to be compatible with nyc's ignore options, which means all of my ignores that specify a number of lines are broken now.

I will have code like this:

// Element visibility would require an E2E test to actually validate.
// Any unit testing of this function would just be theater.
/* v8 ignore next 118 */
/**
 * Checks if an element is fully visible on the screen.
 * This works with overflow: hidden values.
 *
 * @param  {object}  element  A native HTML element
 * @return {boolean}          True = 100% visible, false = <100% visible
 */
export const elementIsVisible = function (element) {
  // ...102 lines of logic
};

Having to add /* v8 ignore next */ hundreds of times is too tedious and annoying to accept as a solution.

The previous solution ignore next # is the cleanest option, a single hint is all that's needed.

However a ignore start and ignore stop would also be fine, especially for code where the amount of lines may fluctuate often.

TheJaredWilcurt avatar Oct 24 '25 17:10 TheJaredWilcurt

This package does not implement ignore hints. They are defined in

https://github.com/istanbuljs/istanbuljs/blob/28ffdbc314596bdcb3007e85d30a62372602b262/packages/istanbul-lib-instrument/src/visitor.js#L7-L10

For Vitest usage you might be looking for

  • https://github.com/vitest-dev/vitest/issues/9203

Also in your case you could just do ignore next to ignore whole node:

/* v8 ignore next */
export const elementIsVisible = function (element) {
  // ...102 lines of logic
};

AriPerkkio avatar Dec 08 '25 06:12 AriPerkkio