5

I am using karma for unit testing my angular 2 application. I have following 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 my

src/lib/!(filters)/**

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

I tried,

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

But it's skipping everything.

How to do this?

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

Community
  • 1
  • 1
Display Name
  • 337
  • 5
  • 13

1 Answers1

0

A couple of things to try:

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

If that doesn't work add a coveragePreprocessor to your karma config.

coveragePreprocessor: {
    exclude: [ "**/lib/filters/*.js" ]
}
David Bradshaw
  • 11,859
  • 3
  • 41
  • 70