Excluding files from coverage when using Mocha and Istanbul

Shai M. picture Shai M. · May 19, 2015 · Viewed 20.4k times · Source

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

Blaise picture Blaise · Jun 7, 2015

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/**"
 ...