swc-project / jest

Super-fast alternative for babel-jest or ts-jest without type checking. Please use main repository for issues
757 stars 36 forks source link

/* istanbul ignore next */ is ignored #119

Open k2xl opened 2 years ago

k2xl commented 2 years ago

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?

akhileshraju commented 1 year ago

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

YozhEzhi commented 1 year ago

Try to do empty line:

image

ctsstc commented 1 year ago

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

k2xl commented 8 months ago

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 ...