dwyl / learn-istanbul

:checkered_flag: Learn how to use the Istanbul JavaScript Code Coverage Tool
339 stars 41 forks source link

How to ignore files (e.g: libraries) from coverage using a .istanbul.yml file? #9

Open nelsonic opened 8 years ago

nelsonic commented 8 years ago

Sometimes you want to ignore a specific file or even a folder from being checked by Istanbul e.g you include a 3rd party library or code in your project (instead of putting it on a CDN)

You can define a list of excludes files in a .istanbul.yml at the root of your project/repo.

Its not an especially well-documented feature... There's only one reference to .istanbul.yml in the entire Istanbul project, see: https://github.com/gotwarlost/istanbul/search?l=markdown&q=.istanbul.yml&utf8=%E2%9C%93

There are examples on the StackOverflows if you search for them. e.g: http://stackoverflow.com/a/34685175/1148249

instrumentation:
    root: .
    extensions:
        - .js
    default-excludes: true
    excludes: ['**/tinymce/**', '**/lib/**', '**/tools/**', '**/build/**']
    include-all-sources: true

a more detailed sample file: https://github.com/vesln/todo/blob/master/.istanbul.yml

@nikhilaravi needed this today in our project, it reminded me we should add it to the readme.