unit testing - How can I improve Karma test coverage on config files in AngularJS? -
unit testing - How can I improve Karma test coverage on config files in AngularJS? -
i have file app/routes.coffee
'use strict'
webapp.config [ '$stateprovider' '$urlrouterprovider' '$locationprovider' ($stateprovider, $urlrouterprovider, $locationprovider) -> $urlrouterprovider.otherwise '/' $stateprovider .state('dashboard', { url: '/' views: appview: templateurl: '/templates/app/dashboard.html' }) .state('repository', { url: '/repository/:repo_host/:username/:name' views: appview: templateurl: '/templates/app/repository.html' }) .state('profile', { url: '/profile' views: appview: templateurl: '/templates/app/profile.html' }) .state('faq', { url: '/faq' views: appview: templateurl: '/templates/app/faq.html' }) ... # lots of other states .state('account.users.statistics', { url: '/:host/:username' views: statisticsview: templateurl: '/templates/app/_userstatistics.html' }) $locationprovider.html5mode true ]
however, code coverage pretty poor:
statements: 55.56% (5 / 9) branches: 0% (0 / 4) functions: 50% (1 / 2) lines: 100% (5 / 5) ignored: none
what can improve code coverage?
it('should test routeprovider', function() { inject(function($route) { expect($route.routes['/faq'].controller).tobe('faqctrl'); expect($route.routes['/faq'].templateurl).toequal('/templates/app/faq.html'); }); });
you can test this. code written in angularjs, tested using jasmine framework. sorry, don't have knowledge in coffescript,
angularjs unit-testing code-coverage karma-runner
Comments
Post a Comment