jest icon indicating copy to clipboard operation
jest copied to clipboard

/* istanbul ignore next */ is ignored

Open k2xl opened this issue 2 years ago • 4 comments

I switched from ts-jest to swc-jest - everything works but noticed that

/* istanbul ignore next */
export default function ...

that code coverage picks up those lines from the function (when I want them ignored). I'm confused grepping through github on what I should do to get it to work. Should I add preserveAllComments in .swcrc (that didn't seem to work) or try something else?

k2xl avatar Aug 29 '22 18:08 k2xl

preserveAllComments works for the most part -- it seems to flag this as not covered, which seems odd given that it should be ignoring the whole arrow func.

image

akhileshraju avatar Nov 24 '22 00:11 akhileshraju

Try to do empty line:

image

YozhEzhi avatar Nov 29 '22 08:11 YozhEzhi

@YozhEzhi that's an "ignore file" rather than "ignore next"

ctsstc avatar Jul 14 '23 21:07 ctsstc

Okay so I encountered this issue again 1 year later and actually just figured out a workaround that seems to work for some files but not others

Instead of

/* istanbul ignore next */
export default function ...

do

/* istanbul ignore next
// Newline needed for istanbul next to work
*/
export default function ...

or even

/* istanbul ignore next
*/
export default function ...

k2xl avatar Dec 30 '23 18:12 k2xl