diff --git a/package.json b/package.json index 98b4751..aedaa06 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,8 @@ "build": "ionic-app-scripts build", "ionic:build": "ionic-app-scripts build", "ionic:serve": "ionic-app-scripts serve", - "test": "karma start ./test-config/karma.conf.js" + "test": "karma start ./test-config/karma.conf.js", + "test-coverage": "karma start ./test-config/karma.conf.js --coverage" }, "config": { "ionic_source_map": "source-map" @@ -47,17 +48,23 @@ "jasmine": "^2.5.3", "karma": "^1.5.0", "karma-chrome-launcher": "^2.0.0", + "karma-coverage": "^1.1.1", "karma-jasmine": "^1.1.0", "karma-jasmine-html-reporter": "^0.2.2", "karma-sourcemap-loader": "^0.3.7", + "karma-typescript": "^3.0.0", "karma-verbose-reporter": "0.0.6", "karma-webpack": "^2.0.3", "null-loader": "^0.1.1", + "remap-istanbul": "^0.9.5", + "systemjs": "^0.20.12", "ts-loader": "^2.0.3", "tslint": "^5.0.0", "tslint-ionic-rules": "0.0.8", - "typescript": "2.1.6" + "typescript": "^2.1.6", + "istanbul-instrumenter-loader": "^2.0.0", + "karma-coverage-istanbul-reporter": "^1.0.0" }, "version": "0.0.1", "description": "Cross-Platform Ionic App for IMS" -} +} \ No newline at end of file diff --git a/test-config/karma.conf.js b/test-config/karma.conf.js index c8f3d72..21b85a7 100644 --- a/test-config/karma.conf.js +++ b/test-config/karma.conf.js @@ -30,7 +30,14 @@ module.exports = function (config) { terminal: true }, - reporters: ['kjhtml', 'dots', 'verbose'], + coverageIstanbulReporter: { + reports: ['html', 'lcovonly'], + fixWebpackSourcePaths: true + }, + + + + reporters: config.coverage ? ['kjhtml', 'dots', 'coverage-istanbul', 'verbose'] : ['kjhtml', 'dots', 'verbose'], port: 9876, colors: true, logLevel: config.LOG_INFO, diff --git a/test-config/webpack.test.js b/test-config/webpack.test.js index 27d1dd0..05ccf0f 100644 --- a/test-config/webpack.test.js +++ b/test-config/webpack.test.js @@ -15,9 +15,18 @@ module.exports = { loaders: [ { loader: 'ts-loader' - } , 'angular2-template-loader' + }, 'angular2-template-loader' ] }, + { + test: /.+\.ts$/, + exclude: /(index.ts|mocks.ts|\.spec\.ts$)/, + loader: 'istanbul-instrumenter-loader', + enforce: 'post', + query: { + esModules: true + } + }, { test: /\.html$/, loader: 'html-loader'