This is how my project is set up:
project/
assets/
js/
app.js
services.js
directives.js
controllers/
FooCtrl.js
BarCtrl.js
css/
images/
test/
unit/
controllers/
controllerSpec.js
I am struggling to add all the files under js/ to karma-coverage's preProcessor directive.
Doing this
preprocessors: {
'**/assets/js/*.js': ['coverage'],
},
only generates coverage report for files directly under assets/js/ but not for files under assets/js/controllers/.
Specifying a single controller:
preprocessors: {
'**/assets/js/controllers/FooCtrl.js': ['coverage'],
},
just says 'No data to display'.
Finally, just doing a wildcard:
preprocessors: {
'**/*.js': ['coverage'],
},
displays data for all files directly under assets/js/, test/unit/controllers/ test/lib/ etc. but it still refuses to show any coverage data for assets/js/controllers/.
I swear there is something magical about StackOverflow. I spent an hour getting it to work, gave up, posted this question, and 2min later figured it out.
I made the mistake of moving the files from the
filesarray to thepreprocessorsdirective. To get code coverage on a certain file, it needs to be in both places,filesarray and thepreprocessors.My final configuration that works looks like this: