Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Add karma-coverage #304

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
logs/*
!.gitkeep
build/
node_modules/
bower_components/
tmp
.DS_Store
.idea
.idea
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,14 @@ predefined script to do this:
```
npm run test-single-run
```
#### Code Coverage Reports

Unit test coverage reports are automatically generated using the [karma-coverage][karma-coverage] plugin.
This plugin creates an HTML code coverage report with [Istanbul][istanbul] to give you Statement, Branch,
Function, and Line coverage statistics for your tests.

* the configuration is found at 'karma.conf.js'
* the reports are available under 'build/reports/coverage/'

### End to end testing

Expand Down Expand Up @@ -293,5 +300,7 @@ For more information on AngularJS please check out http://angularjs.org/
[protractor]: https://github.com/angular/protractor
[jasmine]: http://jasmine.github.io
[karma]: http://karma-runner.github.io
[karma-coverage]: https://github.com/karma-runner/karma-coverage
[istanbul]: https://github.com/gotwarlost/istanbul
[travis]: https://travis-ci.org/
[http-server]: https://github.com/nodeapps/http-server
19 changes: 19 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module.exports = function(config){
'app/bower_components/angular/angular.js',
'app/bower_components/angular-route/angular-route.js',
'app/bower_components/angular-mocks/angular-mocks.js',
'app/*.js',
'app/components/**/*.js',
'app/view*/**/*.js'
],
Expand All @@ -21,9 +22,27 @@ module.exports = function(config){
'karma-chrome-launcher',
'karma-firefox-launcher',
'karma-jasmine',
'karma-coverage',
'karma-junit-reporter'
],

// coverage reporter generates the coverage
reporters: ['progress', 'coverage'],

preprocessors: {
// source files, that you want to generate coverage for
// do not include tests or libraries
// these files will be instrumented by Istanbul
'app/app.js': ['coverage'],
'app/components/**/!(*_test).js': ['coverage'],
'app/view*/!(*_test).js': ['coverage']
},

coverageReporter: {
type : 'html',
dir : 'build/reports/coverage/'
},

junitReporter : {
outputFile: 'test_out/unit.xml',
suite: 'unit'
Expand Down
6 changes: 1 addition & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"jasmine-core": "^2.3.4",
"karma": "~0.12",
"karma-chrome-launcher": "^0.1.12",
"karma-coverage": "^0.5.3",
"karma-firefox-launcher": "^0.1.6",
"karma-jasmine": "^0.3.5",
"karma-junit-reporter": "^0.2.2",
Expand All @@ -19,20 +20,15 @@
},
"scripts": {
"postinstall": "bower install",

"prestart": "npm install",
"start": "http-server -a localhost -p 8000 -c-1",

"pretest": "npm install",
"test": "karma start karma.conf.js",
"test-single-run": "karma start karma.conf.js --single-run",

"preupdate-webdriver": "npm install",
"update-webdriver": "webdriver-manager update",

"preprotractor": "npm run update-webdriver",
"protractor": "protractor e2e-tests/protractor.conf.js",

"update-index-async": "node -e \"require('shelljs/global'); sed('-i', /\\/\\/@@NG_LOADER_START@@[\\s\\S]*\\/\\/@@NG_LOADER_END@@/, '//@@NG_LOADER_START@@\\n' + sed(/sourceMappingURL=angular-loader.min.js.map/,'sourceMappingURL=bower_components/angular-loader/angular-loader.min.js.map','app/bower_components/angular-loader/angular-loader.min.js') + '\\n//@@NG_LOADER_END@@', 'app/index-async.html');\""
}
}