unit testing - AngularJS + Karma + Jasmine + Karma-Coverage: Empty coverage report -
i'm trying integrate current angularjs project karma coverage. please find below package.json , karma-config.
package.json
{ "name": "project", "description": "description", "repository": "https://www.repo.com", "devdependencies": { "karma": "~0.10.9", "karma-junit-reporter": "~0.2.1", "karma-jasmine": "~0.1.5", "karma-ng-scenario": "~0.1", "karma-script-launcher": "~0.1.0", "karma-chrome-launcher": "~0.1.3", "karma-firefox-launcher": "~0.1.3", "karma-phantomjs-launcher": "~0.1.4", "karma-ng-html2js-preprocessor": "~0.1", "karma-coverage": "~0.1" } }
karma config
'use strict'; module.exports = function (config) { config.set({ basepath: '../../public/', loglevel: config.log_debug, frameworks: ['jasmine'], singlerun: true, files: [ 'libs/jquery/jquery-1.9.0.js', 'libs/angular/1.2.10/angular.js', 'libs/angular/**/*.js', 'libs/angular/*.js', 'libs/vendor/*.js', 'libs/test/**/*.js', // fixtures {pattern: 'test/mock-data/helloworld/*.json', watched: true, served: true, included: false}, 'apps/helloworld/**/*.js', 'apps/helloworld/*.js', 'test/helloworld/unit/**/*.js', 'test/helloworld/*.js', 'views/helloworld/directives/*.html' ], exclude: [ 'libs/angular/1.2.10/*.min.js', 'libs/angular/angular-animate.js' ], browsers: ['phantomjs'], reporters: ['progress', 'junit', 'coverage'], preprocessor: { 'apps/helloworld/**/*.js': ['coverage'], '*.html': ['ng-html2js'] } }) };
when try run "node_modules/.bin/karma start conf/advisor/karma.conf.js" tests run karma-coverage report empty. i've tried couple of options cannot make reports appear.
the console output never runs preprocessor coverage. can see runs html2js.
debug [plugin]: loading karma-* /users/alansouza/workspace/helloworld/node_modules debug [plugin]: loading plugin /users/alansouza/workspace/helloworld/node_modules/karma-chrome-launcher. debug [plugin]: loading plugin /users/alansouza/workspace/helloworld/node_modules/karma-coffee-preprocessor. debug [plugin]: loading plugin /users/alansouza/workspace/helloworld/node_modules/karma- coverage. debug [plugin]: loading plugin /users/alansouza/workspace/helloworld/node_modules/karma-firefox-launcher. debug [plugin]: loading plugin /users/alansouza/workspace/helloworld/node_modules/karma-html2js-preprocessor. debug [plugin]: loading plugin /users/alansouza/workspace/helloworld/node_modules/karma-jasmine. debug [plugin]: loading plugin /users/alansouza/workspace/helloworld/node_modules/karma-junit-reporter. debug [plugin]: loading plugin /users/alansouza/workspace/helloworld/node_modules/karma-ng-html2js-preprocessor. debug [plugin]: loading plugin /users/alansouza/workspace/helloworld/node_modules/karma-ng-scenario. debug [plugin]: loading plugin /users/alansouza/workspace/helloworld/node_modules/karma-phantomjs-launcher. debug [plugin]: loading plugin /users/alansouza/workspace/helloworld/node_modules/karma-requirejs. debug [plugin]: loading plugin /users/alansouza/workspace/helloworld/node_modules/karma-script-launcher. info [karma]: karma v0.10.10 server started @ http://localhost:9876/ info [launcher]: starting browser phantomjs debug [launcher]: creating temp dir @ /var/folders/8_/vw105h0j3vn66cgzttktdjmm0000gn/t/karma-29140367 debug [launcher]: /users/alansouza/workspace/helloworld/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/lib/phantom/bin/phantomjs /var/folders/8_/vw105h0j3vn66cgzttktdjmm0000gn/t/karma-29140367/capture.js debug [watcher]: excluded file "/users/alansouza/workspace/helloworld/public/libs/angular/1.2.10/angular-animate.min.js" debug [watcher]: excluded file "/users/alansouza/workspace/helloworld/public/libs/angular/1.2.10/angular-resource.min.js" debug [watcher]: excluded file "/users/alansouza/workspace/helloworld/public/libs/angular/1.2.10/angular-route.min.js" debug [watcher]: excluded file "/users/alansouza/workspace/helloworld/public/libs/angular/1.2.10/angular-sanitize.min.js" debug [watcher]: excluded file "/users/alansouza/workspace/helloworld/public/libs/angular/1.2.10/angular.min.js" debug [preprocessor.html2js]: processing "/users/alansouza/workspace/helloworld/public/views/advisor/directives/av-product-total.html". debug [preprocessor.html2js]: processing "/users/alansouza/workspace/helloworld/public/views/advisor/directives/av-product.html". debug [preprocessor.html2js]: processing "/users/alansouza/workspace/helloworld/public/views/advisor/directives/av-select-product.html". debug [watcher]: resolved files:
question: doing wrong here? how make karma coverage load src js files?
you missing preprocessors
property , coveragereporter
property.
add section karma config file:
preprocessors: { 'apps/helloworld/**/*.js':['coverage'] }, coveragereporter:{ type:'html', dir:'c:/dev/coverage/' },
you can change coveragereporter
output directory whatever want.
Comments
Post a Comment