Karma configuration to exclude subdirectories

I use karma to unit test my angular 2 application. I have a directory structure -

└── src/ ├── index.js ├── index.js.text ├── index.test.js ├── README.txt ├── startuptest.js ├── lib/ | ├── util.js | ├── util.test.js | └── filters/ | ├── kalman.js | └── lowpass.js ├── test/ | ├── main.js | └── lib/ | ├── filters.js | └── util.js └── vendor/ ├── jquery.js └── three/ ├── three.js └── three.fps.js 

I want to exclude all files under mine

 src/lib/!(filters)/** 

from the coverage report. But I want to save all the files from the rest of the directory

I tried,

 {src/**, src/lib/!(filters)/**}/!(*.spec!).js : coverage 

But he misses everything.

How to do it?

Link - https://github.com/karma-runner/karma/issues/508

+5
source share
1 answer

A few things to try:

 {src/*/!(lib/filters)/**}/!(*.spec!).js : coverage 

If this does not work, add coveragePreprocessor to your karma configuration.

 coveragePreprocessor: { exclude: [ "**/lib/filters/*.js" ] } 
0
source

Source: https://habr.com/ru/post/1263949/


All Articles