Generating coverage report for Jenkins
Change-Id: Iafff523061f7f9bfa3fb8cdacd491ec7380309f3
diff --git a/conf/karma.conf.js b/conf/karma.conf.js
index 2db6132..066b292 100644
--- a/conf/karma.conf.js
+++ b/conf/karma.conf.js
@@ -34,8 +34,13 @@
},
reporters: ['progress', 'coverage'],
coverageReporter: {
- type: 'html',
- dir: 'coverage/'
+ // type: 'html',
+ dir: 'coverage/',
+ reporters: [
+ {type: 'json', subdir: '.'},
+ {type: 'html', subdir: 'html'},
+ {type: 'cobertura', subdir: '.'}
+ ]
},
webpack: require('./webpack-test.conf'),
webpackMiddleware: {
diff --git a/conf/webpack-test.conf.js b/conf/webpack-test.conf.js
index a87e383..4720649 100644
--- a/conf/webpack-test.conf.js
+++ b/conf/webpack-test.conf.js
@@ -43,11 +43,18 @@
test: /\.(png|woff|woff2|eot|ttf|svg|jpg|gif|jpeg)$/,
loader: 'url-loader?limit=100000'
}
+ ],
+ postLoaders : [
+ {
+ test: /\.ts$/,
+ exclude: /(node_modules|tests|(.spec\.ts))/,
+ loader: 'istanbul-instrumenter' // used to to get the code coverage for TypeScript
+ }
]
},
plugins: [],
debug: true,
- devtool: 'source-map',
+ devtool: false,
resolve: {
extensions: [
'',
@@ -58,7 +65,7 @@
]
},
ts: {
- configFileName: 'tsconfig.json'
+ configFileName: 'tsconfig.test.json'
},
tslint: {
configuration: require('../tslint.json')
diff --git a/gulp_tasks/karma.js b/gulp_tasks/karma.js
index 5b90572..3f828e0 100644
--- a/gulp_tasks/karma.js
+++ b/gulp_tasks/karma.js
@@ -25,3 +25,15 @@
const karmaServer = new karma.Server({configFile}, karmaFinishHandler(done));
karmaServer.start();
}
+
+const remapIstanbul = require('remap-istanbul/lib/gulpRemapIstanbul');
+gulp.task('remap-istanbul', function() {
+ return gulp.src('coverage/coverage-final.json')
+ .pipe(remapIstanbul({
+ reports: {
+ 'json': 'coverage/coverage-final.json',
+ 'html': 'coverage/html',
+ 'cobertura': 'coverage/coverage.xml'
+ }
+ }));
+});
\ No newline at end of file
diff --git a/gulpfile.js b/gulpfile.js
index 08918dc..45cac24 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -11,7 +11,7 @@
gulp.registry(hub);
gulp.task('build', gulp.series(gulp.parallel('other', 'webpack:dist')));
-gulp.task('test', gulp.series('karma:single-run'));
+gulp.task('test', gulp.series('karma:single-run', 'remap-istanbul'));
gulp.task('test:auto', gulp.series('karma:auto-run'));
gulp.task('serve', gulp.series('webpack:watch', 'watch', 'browsersync'));
gulp.task('serve:dist', gulp.series('default', 'browsersync:dist'));
diff --git a/package.json b/package.json
index 98f6686..63d5ecc 100644
--- a/package.json
+++ b/package.json
@@ -55,6 +55,7 @@
"html-loader": "^0.4.3",
"html-webpack-plugin": "^2.9.0",
"http-proxy": "^1.16.2",
+ "istanbul-instrumenter-loader": "^2.0.0",
"jasmine": "^2.4.1",
"jasmine-jquery": "^2.1.1",
"json-loader": "^0.5.4",
@@ -74,6 +75,7 @@
"node-sass": "^3.4.2",
"phantomjs-prebuilt": "^2.1.6",
"postcss-loader": "^0.8.0",
+ "remap-istanbul": "^0.9.5",
"resolve-url-loader": "^1.6.1",
"sass-loader": "^3.1.2",
"style-loader": "^0.13.0",
diff --git a/tsconfig.test.json b/tsconfig.test.json
new file mode 100644
index 0000000..69a067c
--- /dev/null
+++ b/tsconfig.test.json
@@ -0,0 +1,15 @@
+{
+ "compilerOptions": {
+ "inlineSourceMap": true
+ },
+ "compileOnSave": false,
+ "include": [
+ "src/**/*.ts",
+ "src/**/*.tsx"
+ ],
+ "exclude": [
+ "typings/**",
+ "conf/app/**",
+ "node_modules"
+ ]
+}