C8 Annotations

V8 Coverage provider annotations are similar as Istanbul.

Ignoring the next line

const myVariable = 99;
/* c8 ignore next */
if (process.platform === 'win32') console.info('hello world');

Unlike istanbul, this annotation only ignores one line.

Ignoring the next N lines

const myVariable = 99;
/* c8 ignore next 3 */
if (process.platform === 'win32') {
  console.info('hello world');
}

Ignoring all lines until told

/* c8 ignore start */
function dontMindMe() {
  // ...
}
/* c8 ignore stop */

/* c8 ignore else */ is only working without else statement:

So when you have an else statement should proceed as follow:

if (process.platform === 'win32') {
  console.info('hello world');
} /* c8 ignore start*/ else {
  console.info('hello');
} /* c8 ignore stop */

Another little difference with this is, c8 marks it in the coverage report when istanbul doesn't.

Ignoring a block on the current line

const myVariable = 99;
const os = process.platform === 'darwin' ? 'OSXy' /* c8 ignore next */ : 'Windowsy';

This is useful when you want to ignore else statement for example.

Last updated