karma-coverage

The easiest way is to keep karma-coverage as a devDependency in your package.json. More details refer to https://github.com/karma-runner/karma-coverage

{
"devDependencies": {
"karma": "~0.10",
"karma-coverage": "~0.1"
}
}

example karma_code_coverage.conf.js

module.exports = function(config){
config.set({ basePath : '../../', autoWatch : true, frameworks: ['jasmine'], browsers : ['Firefox'], plugins : [
//'karma-chrome-launcher',
'karma-firefox-launcher',
'karma-jasmine',
'karma-coverage'
], // Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun : true, // test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters : ['progress', 'coverage'],
coverageReporter:{
type:'html',
dir: 'test_out/angular/coverage/',
subdir:'report'
},
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
"src/js/angular/**/*.js":"coverage"
}
});
};

Gruntfile.js sample

module.exports = function (grunt) {

    grunt.loadNpmTasks('grunt-karma');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.initConfig({
'pkg': grunt.file.readJSON('package.json'), 'meta': {
'jsFilesForTesting': [
'src/bower_components/angular/angular.js',
'src/bower_components/angular-route/angular-route.js',
'src/bower_components/angular-resource/angular-resource.js',
'src/bower_components/angular-animate/angular-animate.js',
'src/bower_components/angular-sanitize/angular-sanitize.js',
'src/bower_components/angular-mocks/angular-mocks.js',
'src/bower_components/restangular/dist/restangular.js',
'src/bower_components/underscore/underscore.js',
'src/bower_components/jquery/jquery.js',
'src/bower_components/bootstrap/dist/js/bootstrap.js',
'src/js/usher/ajax.js',
'src/js/lib/jquery.sparkline.js',
'src/js/lib/ui-bootstrap-tpls-0.12.0.min.js',
'src/js/ui-2/common/customized-modal.js',
'test/angular/unit/**/*.js'
]
}, 'karma': {
'development': {
'configFile': 'test/angular/karma_grunt.conf.js',
'options': {
'files': [
'<%= meta.jsFilesForTesting %>',
'src/js/angular/**/*.js'
]
}
}, 'coverage':{
'configFile' : 'test/angular/karma_code_coverage.conf.js',
'options':{
'files':[
'<%= meta.jsFilesForTesting %>',
'src/js/angular/**/*.js'
]
}
}, 'dist': {
'options': {
'configFile': 'test/angular/karma_grunt_dist.conf.js',
'files': [
'<%= meta.jsFilesForTesting %>',
'dist/<%= pkg.name %>-<%= pkg.version %>.js'
]
}
}, 'minified': {
'options': {
'configFile': 'test/angular/karma_grunt_minified.conf.js',
'files': [
'<%= meta.jsFilesForTesting %>',
'dist/<%= pkg.name %>-<%= pkg.version %>.min.js'
]
}
}
}, 'jshint': {
'options': {
'reporter': require('jshint-jenkins-violations-reporter'),
'reporterOutput': 'test_out/angular/jshint.xml',
'force': true,
'jshintrc': true
},
'beforeconcat': ['src/js/angular/**/*.js']
}, 'concat': {
'dist': {
'src': ['src/js/angular/**/*.js'],
'dest': 'dist/<%= pkg.name %>-<%= pkg.version %>.js'
}
}, 'uglify': {
'options': {
'mangle': false
},
'dist': {
'files': {
'dist/<%= pkg.name %>-<%= pkg.version %>.min.js': ['dist/<%= pkg.name %>-<%= pkg.version %>.js']
}
}
}
}); grunt.registerTask('test', ['karma:development','karma:coverage']);
grunt.registerTask('coverage',['karma:coverage']);
grunt.registerTask('build',
[
'karma:development',
'karma:coverage',
'jshint',
]);
};

  

AngularJS code converage的更多相关文章

  1. Jenkins integration for AngularJS code coverage

    Install Jenkins plugins 'Cobertura' and 'HTML Publisher' 1. add Post-build Actions "Publish HTM ...

  2. Using AngularJS with .NET MVC 5

    This tip shows the use of AngularJS with .NET MVC5 application. Here is a simple step-by-step exampl ...

  3. Ultimate guide to learning AngularJS in one day

    What is AngularJS? Angular is a client-side MVC/MVVM framework built in JavaScript, essential for mo ...

  4. AngularJS实现简单的分页功能

    本篇文章由:http://xinpure.com/angularjs-simple-paging-functionality/ 初学 AngularJS, 尝试着写一些小功能 代码逻辑写得略粗糙,仅仅 ...

  5. bootstrap 练习

    bookList.html <!DOCTYPE html> <html lang="zh-cn"> <head> <!-- 父路径 --& ...

  6. Cheatsheet: 2015 08.01 ~ 08.31

    Java Beginner's Guide to MVC with Spring Framework Exploring the Spring Web MVC for Web Application ...

  7. Angular DirtyChecking(脏值检查) $watch, $apply, $digest

    Dirty Checking (脏值检查) Digest cycle and $scope Digest cycle and $scope First and foremost, AngularJS ...

  8. AnguarJS——第10章 路由

    第10章 路由 一个应用是由若个视图组合而成的,根据不同的业务逻辑展示给用户不同的视图,路由则是实现这一功能的关键. 10.1 SPA SPA(Single Page Application)指的是通 ...

  9. How to Build a Search Page with Elasticsearch and .NET

    Although SQL Server's Full-Text search is good for searching text that is within a database, there a ...

随机推荐

  1. ♫【网站优化】Reflow / Repaint

    web移动开发最佳实践之js篇 浏览器的回流与重绘 by 张盛志 DOM性能瓶颈与Javascript性能优化 浏览器的渲染原理简介 其中一个跟浏览器有关的原因,那就是浏览器需要花时间.花精力去渲染. ...

  2. VM Depot 助您使用本地开源软件架设开发 Web 站点

     发布于 2014-04-25 作者 云 浪生 使用 VM Depot 中的镜像在 Azure 上创建.开发.部署网站与应用不仅方便快捷而且省时省力!感谢开源社区的大力支持,我们的VM Depot ...

  3. Centos6.4 为用户添加sudo功能

    sudo即super user do,以超级管理员的方式运行命令.使用时,只需在命令最前面加上sudo即可. 要为用户添加sudo功能,需要修改sudo的配置文件: vi /etc/sudoers ( ...

  4. HDOJ/HDU 1113 Word Amalgamation(字典顺序~Map)

    Problem Description In millions of newspapers across the United States there is a word game called J ...

  5. msm8610 lcd driver code analysis

    ---恢复内容开始--- 1  lcd probe The probe sequence is determined by compilation sequence: mdss-mdp3-objs = ...

  6. 使用python爬取P站图片

    刚开学时有一段时间周末没事,于是经常在P站的特辑里收图,但是P站加载图片的速度比较感人,觉得自己身为计算机专业,怎么可以做一张张图慢慢下这么low的事,而且这样效率的确也太低了,于是就想写个程序来帮我 ...

  7. weekend110(Hadoop)的 第三天笔记

    (2015年1月17日) 课程目录 01-hdfs源码跟踪之打开输入流 02-hdfs源码跟踪之打开输入流总结 03-mapreduce介绍及wordcount 04-wordcount的编写和提交集 ...

  8. ==和equals()的用法

    先看一段代码: public class TestEqual{ public static void main(String [ ] args){ //基本类型比较 int a = 100; int ...

  9. IO(Input Output)流__字符流

    一.IO流简述------用于操作数据的 IO流用来处理设备之间的数据传输; Java对数据的操作是通过流的方式; Java用于操作流的对象都是在IO包中; 流按操作数据分为: 字节流(通用)和字符流 ...

  10. 转载-Linux下搭建VPN服务器(CentOS、pptp)

    转自:http://www.cnblogs.com/sixiweb/archive/2012/11/20/2778732.html 搭建过程参考这篇文章 先说我搭建过程中出现的问题吧: 按照 教程搭建 ...