From 233309a068d871776553a871ea1e1bf6b453aa55 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Mon, 2 Feb 2015 15:47:37 -0800 Subject: [PATCH 1/3] configure karma for code coverage --- gulpfile.js | 18 ++++++++++++++++++ package.json | 1 + spec/karma.conf.js | 17 +++++++++++++++-- 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 5cbf73c..577ce97 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -209,10 +209,28 @@ gulp.task('mocha', function (cb) { */ gulp.task('coveralls', function () { if (!process.env.CI) return; + return gulp.src([ + './coverage/client/lcov.info', + './coverage/lcov.info' + ]) + .pipe(concat('lcov.info')) + .pipe(coveralls) return gulp.src('./coverage/lcov.info') .pipe(coveralls()); }); + + +gulp.task('testy', function () { + return gulp.src([ + './coverage/client/lcov.info', + './coverage/lcov.info' + ]) + .pipe(concat('test.info')) + .pipe(gulp.dest('./coverage')); +}); + + gulp.task('watch', function() { gulp.watch(paths.src.img + '/**/*', ['image']); gulp.watch(paths.src.scss + '/**/*.scss', ['compass']); diff --git a/package.json b/package.json index f4d1f72..e16417e 100644 --- a/package.json +++ b/package.json @@ -72,6 +72,7 @@ "karma-chai": "^0.1.0", "karma-chrome-launcher": "^0.1.7", "karma-cli": "0.0.4", + "karma-coverage": "^0.2.7", "karma-mocha": "^0.1.10", "mocha": "^2.1.0", "request": "^2.51.0", diff --git a/spec/karma.conf.js b/spec/karma.conf.js index 017c268..f95d07b 100644 --- a/spec/karma.conf.js +++ b/spec/karma.conf.js @@ -17,7 +17,7 @@ module.exports = function(config) { files: [ // TODO: specify client files more carefully // src files - 'client/dist/app.min.js', + 'client/app/dist/app.min.js', // TODO: set up server-side tests in karma // spec files @@ -34,13 +34,24 @@ module.exports = function(config) { // preprocess matching files before serving them to the browser // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor preprocessors: { + /** + * source files to test coverage for + * do not include tests or libraries + * (these files will be instrumented by Istanbul) + */ + 'client/app/src/js/**/*.js': ['coverage'] }, + // optionally, configure the coverage reporter + coverageReporter: { + type : 'html', + dir : 'coverage/client' + }, // test results reporter to use // possible values: 'dots', 'progress' // available reporters: https://npmjs.org/browse/keyword/karma-reporter - reporters: ['progress'], + reporters: ['progress', 'coverage'], // web server port @@ -73,6 +84,8 @@ module.exports = function(config) { }, + + // Continuous Integration mode // if true, Karma captures browsers, runs the tests and exits singleRun: true From 1635b84bf474ac2304193df9e5285e7ab0de6aaf Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Tue, 3 Feb 2015 15:36:16 -0800 Subject: [PATCH 2/3] more edits --- gulpfile.js | 15 ++++++++------- spec/karma.conf.js | 5 +++-- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 577ce97..1232546 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -222,15 +222,16 @@ gulp.task('coveralls', function () { gulp.task('testy', function () { - return gulp.src([ - './coverage/client/lcov.info', - './coverage/lcov.info' - ]) - .pipe(concat('test.info')) - .pipe(gulp.dest('./coverage')); + // return gulp.src([ + // './coverage/client/lcov.info', + // './coverage/lcov.info' + // ]) + // .pipe(concat('combined.info')) + // .pipe(gulp.dest('./coverage')) + return gulp.src('./coverage/combined.info') + .pipe(coveralls()); }); - gulp.task('watch', function() { gulp.watch(paths.src.img + '/**/*', ['image']); gulp.watch(paths.src.scss + '/**/*.scss', ['compass']); diff --git a/spec/karma.conf.js b/spec/karma.conf.js index f95d07b..939f71c 100644 --- a/spec/karma.conf.js +++ b/spec/karma.conf.js @@ -44,8 +44,9 @@ module.exports = function(config) { // optionally, configure the coverage reporter coverageReporter: { - type : 'html', - dir : 'coverage/client' + type : 'lcov', + dir : 'coverage/client', + subdir: 'lcovTest' }, // test results reporter to use From 80b0560c91ff839b416d453dcb5ac8315b5f36ff Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Fri, 6 Feb 2015 17:22:32 -0800 Subject: [PATCH 3/3] finishing touches --- gulpfile.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 1232546..13d6c08 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -208,15 +208,16 @@ gulp.task('mocha', function (cb) { * Sends code coverage data to Coveralls. */ gulp.task('coveralls', function () { - if (!process.env.CI) return; - return gulp.src([ - './coverage/client/lcov.info', - './coverage/lcov.info' - ]) + // if (!process.env.CI) return; + return gulp + .src([ + './coverage/client/lcovTest/lcov.info', + './coverage/lcov.info' + ]) .pipe(concat('lcov.info')) - .pipe(coveralls) - return gulp.src('./coverage/lcov.info') .pipe(coveralls()); + // return gulp.src('./coverage/lcov.info') + // .pipe(coveralls()); });