diff --git a/config/karma.conf.js b/config/karma.conf.js index 3d221f4..cd99a33 100644 --- a/config/karma.conf.js +++ b/config/karma.conf.js @@ -57,7 +57,7 @@ module.exports = function(config) { * possible values: 'dots', 'progress' * available reporters: https://npmjs.org/browse/keyword/karma-reporter */ - reporters: [ 'mocha', 'coverage' ], + reporters: [ 'mocha', 'coverage', 'remap-coverage' ], // web server port port: 9876, diff --git a/config/webpack.test.js b/config/webpack.test.js index 63cedcf..4c226f4 100644 --- a/config/webpack.test.js +++ b/config/webpack.test.js @@ -145,6 +145,26 @@ module.exports = function (options) { test: /\.html$/, use: ['raw-loader'], exclude: [helpers.root('src/index.html')] + }, + + /** + * Instruments JS files with Istanbul for subsequent code coverage reporting. + * Instrument only testing sources. + * + * See: https://github.com/deepsweet/istanbul-instrumenter-loader + */ + { + enforce: 'post', + test: /\.(js|ts)$/, + loader: 'istanbul-instrumenter-loader', + query: { + esModules: true + }, + include: helpers.root('src'), + exclude: [ + /\.(e2e|spec)\.ts$/, + /node_modules/ + ] } ] }, diff --git a/package.json b/package.json index cce5f75..e5737d9 100644 --- a/package.json +++ b/package.json @@ -118,6 +118,7 @@ "karma-chrome-launcher": "2.0.0", "karma-cli": "1.0.1", "karma-coverage": "1.1.1", + "karma-remap-coverage": "^0.1.4", "karma-htmlfile-reporter": "0.3.5", "karma-jasmine": "1.1.0", "karma-jasmine-html-reporter": "0.2.2",