From e8d39a47475a6452bda81f6559ad5a26de45d03f Mon Sep 17 00:00:00 2001 From: Vitaly Kramskikh Date: Thu, 14 Jul 2016 17:23:31 +0300 Subject: [PATCH] Added Istanbul integration This commits introduces integration with Istanbul which allows to track code coverage. Change-Id: Ia106b256308a8d0f7c286134f997c7efd4bcf624 Co-Authored-By: Michael Krotscheck --- .istanbul.yml | 30 ++++++++++++++++++++++++++++++ karma.conf.babel.js | 16 +++++++++++++++- package.json | 6 +++++- 3 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 .istanbul.yml diff --git a/.istanbul.yml b/.istanbul.yml new file mode 100644 index 0000000..33eb122 --- /dev/null +++ b/.istanbul.yml @@ -0,0 +1,30 @@ +verbose: false +instrumentation: + root: . + includes: + - 'src/**' + default-excludes: true +reporting: + print: detail + reports: + - lcov + - html + dir: ./cover/node + watermarks: + statements: [50, 90] + lines: [50, 90] + functions: [50, 90] + branches: [50, 90] +check: + global: + statements: 50 + lines: 50 + branches: 50 + functions: 0 + excludes: [] + each: + statements: 50 + lines: 50 + branches: 50 + functions: 0 + excludes: [] diff --git a/karma.conf.babel.js b/karma.conf.babel.js index 2793f24..9f2d5de 100644 --- a/karma.conf.babel.js +++ b/karma.conf.babel.js @@ -27,7 +27,7 @@ export default (config) => { // test results reporter to use // possible values: 'dots', 'progress' // available reporters: https://npmjs.org/browse/keyword/karma-reporter - reporters: ['progress'], + reporters: ['progress', 'coverage', 'threshold'], // web server port port: 9876, @@ -59,6 +59,20 @@ export default (config) => { webpackMiddleware: { // Don't spam the console. noInfo: true + }, + + // Generate a coverage report in /cover/karma + coverageReporter: { + type: 'html', //produces a html document after code is run + dir: 'cover/browser/' //path to created html doc + }, + + // The current coverage threshold values. These should never drop. + thresholdReporter: { + statements: 88, + branches: 64, + functions: 77, + lines: 75 } }); diff --git a/package.json b/package.json index 812fd57..8477f0e 100644 --- a/package.json +++ b/package.json @@ -5,8 +5,9 @@ "main": "dist/index.js", "scripts": { "test": "npm run test:node; npm run test:browser", - "test:node": "jasmine JASMINE_CONFIG_PATH=test/unit/jasmine.json", + "test:node": "istanbul cover jasmine JASMINE_CONFIG_PATH=test/unit/jasmine.json", "test:browser": "karma start", + "posttest:node": "istanbul check-coverage", "lint": "eslint ./", "prepublish": "nsp check; npm run build", "build": "babel src -d dist && webpack", @@ -34,11 +35,14 @@ "babel-register": "^6.9.0", "eslint": "^2.4.0", "eslint-config-openstack": "2.0.0", + "istanbul": "^1.0.0-alpha.2", "jasmine": "^2.4.1", "karma": "^1.1.1", "karma-chrome-launcher": "^1.0.1", + "karma-coverage": "^1.1.0", "karma-firefox-launcher": "^1.0.0", "karma-jasmine": "^1.0.2", + "karma-threshold-reporter": "^0.1.15", "karma-webpack": "^1.7.0", "nsp": "^2.4.0", "webpack": "^1.13.1"