Shai M. Shai M. - 2 months ago 28
Node.js Question

Excluding files from coverage when using Mocha and Istanbul

How can I exclude folders and files (by path) from coverage report when using mocha and instanbul?

I want to exclude by a configuration and not

/*istanbul ignore next*/


in each file.

(The generated report use by Jenkins)

Thanks,

Answer

You can ignore files matching a certain pattern using the -x parameter.

 istanbul help cover

 ...
 -x <exclude-pattern> [-x <exclude-pattern>]
        one or more fileset patterns e.g. "**/vendor/**"
 ...