AngularJS code converage
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的更多相关文章
- Jenkins integration for AngularJS code coverage
Install Jenkins plugins 'Cobertura' and 'HTML Publisher' 1. add Post-build Actions "Publish HTM ...
- 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 ...
- 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 ...
- AngularJS实现简单的分页功能
本篇文章由:http://xinpure.com/angularjs-simple-paging-functionality/ 初学 AngularJS, 尝试着写一些小功能 代码逻辑写得略粗糙,仅仅 ...
- bootstrap 练习
bookList.html <!DOCTYPE html> <html lang="zh-cn"> <head> <!-- 父路径 --& ...
- Cheatsheet: 2015 08.01 ~ 08.31
Java Beginner's Guide to MVC with Spring Framework Exploring the Spring Web MVC for Web Application ...
- Angular DirtyChecking(脏值检查) $watch, $apply, $digest
Dirty Checking (脏值检查) Digest cycle and $scope Digest cycle and $scope First and foremost, AngularJS ...
- AnguarJS——第10章 路由
第10章 路由 一个应用是由若个视图组合而成的,根据不同的业务逻辑展示给用户不同的视图,路由则是实现这一功能的关键. 10.1 SPA SPA(Single Page Application)指的是通 ...
- 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 ...
随机推荐
- 【Android 复习】 : Activity之间传递数据的几种方式
在Android开发中,我们通常需要在不同的Activity之间传递数据,下面我们就来总结一下在Activity之间数据传递的几种方式. 1. 使用Intent来传递数据 Intent表示意图,很多时 ...
- HDU-1372 Knight Moves (BFS)
Problem Description A friend of you is doing research on the Traveling Knight Problem (TKP) where yo ...
- How to install Apache Server on Windows
Note Those of you interested in the Apache 2.0.X tutorial, it has been abandon and I will no longer ...
- 主流智能手机屏幕材质介绍 及 LCD闪屏现象分析
TN TN(Twisted Nematic) 即扭曲向列型面板,属于有源矩阵液晶显示器中的一种.由于TFT是主动式矩阵LCD可让液晶的排列方式具有记忆性,不会在电流消失后马上恢复 ...
- 矩阵乘法 and BIOS loads MBR into 0x7C00?
tianpeng <再谈矩阵与矩阵乘法> 讲的也好 矩阵乘矩阵 这个结果是怎么算出来的? 第一个矩阵第一行的每个数字(2和1),各自乘以第二个矩阵第一列对应位置的数字(1和1),然后将乘积 ...
- python面向对象(二)——类成员
Python面向对象 类成员 1.字段 普通字段 属于对象 静态字段 属于类 2.方法 普通方法 触发者是对象 括号里至少一个参数 se ...
- Verilog HDL模块的结构
一个设计是由一个个模块(module)构成的.一个模块的设计如下: 1.模块内容是嵌在module 和endmodule两个语句之间.每个模块实现特定的功能,模块可进行层次的嵌套,因此可以将大型的数字 ...
- 395. Coins in a Line II
最后更新 这个题做得也不好,dp[n]尝试写了几下,不太对. 应该是类似于gem theory的题. 当只有1个硬币剩下的时候直接拿走,不BB. 剩俩的时候也都拿了.. dp[n]表示剩下多少个硬币. ...
- 命令 "sudo -H" 中的这个 "H" 什么作用?
脚本中使用$HOME变量 问题描述:某些同事原来写的脚本中包含如下内容. BIN_DIR=${HOME}/tools TAIR_BIN_DIR=${HOME}/tair_bin TAIR_SRC_DI ...
- MiniCodeEditor:只有168字节的在线Html/CSS/JavaScript编辑器
博客搬到了fresky.github.io - Dawei XU,请各位看官挪步.最新的一篇是:MiniCodeEditor:只有168字节的在线Html/CSS/JavaScript编辑器.