Coverage of karma with files and tests in one place

I create karma in an existing project. I have work and the correct work on tests, but I can not get myself to work.

I have all the necessary modules installed, but I think that this is due to the way I include my files in the "preprocessors" object.

My project is set up with the file structure below

App
|--js
  |-- fileToTest.js
  |-- fileToTest.Tests.js

Karma coverage documents state that when setting up coverage, tests or libraries should not be included. I guess I'm wondering how to exclude files using ".Tests.js" at the end.

The object of my preprocessors looks below. Is there a way to include the files that I want to use to create coverage for using glob, or should I, unfortunately, individually add these files?

preprocessors: {
    './App/**/*.tpl.html' : 'ng-html2js',
    './App/**/*.js': ['coverage']
}
+4
1

https://github.com/isaacs/minimatch, ( http://karma-runner.imtqy.com/0.12/config/preprocessors.html), glob.

, :

preprocessors: {
          // source files, that you wanna generate coverage for
          // do not include tests or libraries
          // (these files will be instrumented by Istanbul)
          'www/js/controllers/**/*.js': ['coverage'],
          'www/js/directives/**/*.js': ['coverage'],
          'www/js/filters/**/*.js': ['coverage'],
          'www/js/initializers/**/*.js': ['coverage'],
          'www/js/services/**/*.js': ['coverage'],
          'www/js/services.js': ['coverage']
    }

EDIT:

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

,

resources/javascript/**/!(*Spec).js

,

'./App/**/!(*Tests).js': ['coverage']
+1

All Articles