From 96551c20db5b3feca9d2c27a085288e894132dd2 Mon Sep 17 00:00:00 2001 From: etimberg Date: Sat, 13 Feb 2016 21:50:12 -0500 Subject: [PATCH 1/6] begin fixing coverage tests --- gulpfile.js | 3 ++- karma.coverage.conf.js | 8 ++++++-- package.json | 6 ++++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 7b2710983..d0f9d08b9 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -157,7 +157,8 @@ function unittestWatchTask() { } function coverageTask() { - var files = ['./dist/Chart.bundle.js'] + //var files = ['./dist/Chart.bundle.js'] + var files = ['./src/**/*.js']; Array.prototype.unshift.apply(files, preTestFiles); Array.prototype.push.apply(files, testFiles); diff --git a/karma.coverage.conf.js b/karma.coverage.conf.js index cc047aa4d..056b7e655 100644 --- a/karma.coverage.conf.js +++ b/karma.coverage.conf.js @@ -7,10 +7,14 @@ module.exports = function(config) { dir: 'coverage/' }, - frameworks: ['jasmine'], + frameworks: ['browserify', 'jasmine'], preprocessors: { - 'src/**/*.js': ['coverage'] + 'src/**/*.js': ['browserify', 'coverage'] + }, + browserify: { + debug: true, + transform: ['browserify-istanbul'] }, reporters: ['progress', 'coverage'], diff --git a/package.json b/package.json index 3f3602dcf..05b86f665 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ }, "devDependencies": { "browserify": "^13.0.0", + "browserify-istanbul": "^0.2.1", "gulp": "3.9.x", "gulp-concat": "~2.1.x", "gulp-connect": "~2.0.5", @@ -26,7 +27,9 @@ "jasmine": "^2.3.2", "jasmine-core": "^2.3.4", "jquery": "^2.1.4", + "jshint-stylish": "~2.1.0", "karma": "^0.12.37", + "karma-browserify": "^5.0.1", "karma-chrome-launcher": "^0.2.0", "karma-coverage": "^0.5.1", "karma-firefox-launcher": "^0.1.6", @@ -34,8 +37,7 @@ "karma-jasmine-html-reporter": "^0.1.8", "merge-stream": "^1.0.0", "semver": "^3.0.1", - "vinyl-source-stream": "^1.1.0", - "jshint-stylish": "~2.1.0" + "vinyl-source-stream": "^1.1.0" }, "spm": { "main": "Chart.js" From a84f9d917721f4f06965c88186a37e8200aecce7 Mon Sep 17 00:00:00 2001 From: etimberg Date: Sat, 13 Feb 2016 21:58:49 -0500 Subject: [PATCH 2/6] Update other test tasks to use karma-browserify --- gulpfile.js | 5 ++--- karma.conf.ci.js | 8 +++++++- karma.conf.js | 9 ++++++++- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index d0f9d08b9..5b64a1920 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -133,7 +133,7 @@ function validHTMLTask() { function unittestTask() { - var files = ['./dist/Chart.bundle.js'] + var files = ['./src/**/*.js']; Array.prototype.unshift.apply(files, preTestFiles); Array.prototype.push.apply(files, testFiles); @@ -145,7 +145,7 @@ function unittestTask() { } function unittestWatchTask() { - var files = ['./dist/Chart.bundle.js'] + var files = ['./src/**/*.js']; Array.prototype.unshift.apply(files, preTestFiles); Array.prototype.push.apply(files, testFiles); @@ -157,7 +157,6 @@ function unittestWatchTask() { } function coverageTask() { - //var files = ['./dist/Chart.bundle.js'] var files = ['./src/**/*.js']; Array.prototype.unshift.apply(files, preTestFiles); Array.prototype.push.apply(files, testFiles); diff --git a/karma.conf.ci.js b/karma.conf.ci.js index d6ee47bf2..7ed5d0fe2 100644 --- a/karma.conf.ci.js +++ b/karma.conf.ci.js @@ -7,8 +7,14 @@ module.exports = function(config) { flags: ['--no-sandbox'] } }, - frameworks: ['jasmine'], + frameworks: ['browserify', 'jasmine'], reporters: ['progress', 'html'], + preprocessors: { + 'src/**/*.js': ['browserify'] + }, + browserify: { + debug: true + } }; if (process.env.TRAVIS) { diff --git a/karma.conf.js b/karma.conf.js index bce079624..acdff3f9c 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -1,7 +1,14 @@ module.exports = function(config) { config.set({ browsers: ['Chrome', 'Firefox'], - frameworks: ['jasmine'], + frameworks: ['browserify', 'jasmine'], reporters: ['progress', 'html'], + + preprocessors: { + 'src/**/*.js': ['browserify'] + }, + browserify: { + debug: true + } }); }; \ No newline at end of file From 3226dfa4952e16819306f2db519714036b9b6232 Mon Sep 17 00:00:00 2001 From: etimberg Date: Sat, 13 Feb 2016 22:44:55 -0500 Subject: [PATCH 3/6] coverage report works --- karma.coverage.conf.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/karma.coverage.conf.js b/karma.coverage.conf.js index 056b7e655..55992b0e1 100644 --- a/karma.coverage.conf.js +++ b/karma.coverage.conf.js @@ -2,21 +2,24 @@ module.exports = function(config) { config.set({ browsers: ['Chrome', 'Firefox'], - coverageReporter: { - type: 'html', - dir: 'coverage/' - }, - frameworks: ['browserify', 'jasmine'], preprocessors: { - 'src/**/*.js': ['browserify', 'coverage'] + 'src/**/*.js': ['browserify'] }, browserify: { debug: true, - transform: ['browserify-istanbul'] + transform: [['browserify-istanbul', { + instrumenterConfig: { + embed: true + } + }]] }, reporters: ['progress', 'coverage'], + coverageReporter: { + type: 'html', + dir: 'coverage/' + } }); }; \ No newline at end of file From 489f7ce6f7fb95225489fe9ec5f6257b65120771 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sun, 14 Feb 2016 09:38:02 -0500 Subject: [PATCH 4/6] use a new node version --- .travis.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5397abf98..484d1364d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: node_js node_js: - - "0.11" - - "0.10" + - "5.6" + - "4.3" before_install: - "export CHROME_BIN=chromium-browser" @@ -13,6 +13,8 @@ before_script: script: - gulp test + - gulp coverage + - cat ./coverage/lcov.info | ./node_modules/.bin/coveralls notifications: slack: chartjs:pcfCZR6ugg5TEcaLtmIfQYuA From 38b2925e6c9ffe6c1b71087a94ec22d04e570200 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sun, 14 Feb 2016 09:38:26 -0500 Subject: [PATCH 5/6] Use coveralls to report lines of coverage and add a badge to the readme --- README.md | 3 ++- karma.coverage.conf.js | 7 +++++-- package.json | 1 + 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d86543f8b..4be188e8f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # Chart.js -[![Build Status](https://travis-ci.org/nnnick/Chart.js.svg?branch=v2.0-dev)](https://travis-ci.org/nnnick/Chart.js) [![Code Climate](https://codeclimate.com/github/nnnick/Chart.js/badges/gpa.svg)](https://codeclimate.com/github/nnnick/Chart.js) +[![Build Status](https://travis-ci.org/nnnick/Chart.js.svg?branch=v2.0-dev)](https://travis-ci.org/nnnick/Chart.js) [![Code Climate](https://codeclimate.com/github/nnnick/Chart.js/badges/gpa.svg)](https://codeclimate.com/github/nnnick/Chart.js)[![Coverage Status](https://coveralls.io/repos/nnnick/Chart.js/badge.svg?branch=v2.0-dev)](https://coveralls.io/r/nnncik/Chart.js?branch=v2.0-dev) + *Simple HTML5 Charts using the canvas element* [chartjs.org](http://www.chartjs.org) diff --git a/karma.coverage.conf.js b/karma.coverage.conf.js index 55992b0e1..ba75445aa 100644 --- a/karma.coverage.conf.js +++ b/karma.coverage.conf.js @@ -18,8 +18,11 @@ module.exports = function(config) { reporters: ['progress', 'coverage'], coverageReporter: { - type: 'html', - dir: 'coverage/' + dir: 'coverage/', + reporters: [ + { type: 'html', subdir: 'report-html' }, + { type: 'lcovonly', subdir: '.', file: 'lcov.info' } + ] } }); }; \ No newline at end of file diff --git a/package.json b/package.json index 05b86f665..b31416507 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "devDependencies": { "browserify": "^13.0.0", "browserify-istanbul": "^0.2.1", + "coveralls": "^2.11.6", "gulp": "3.9.x", "gulp-concat": "~2.1.x", "gulp-connect": "~2.0.5", From 766b748a58b9936f55b13a35e12274b24e88c099 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sun, 14 Feb 2016 09:48:24 -0500 Subject: [PATCH 6/6] Run coverage properly on the CI --- karma.coverage.conf.js | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/karma.coverage.conf.js b/karma.coverage.conf.js index ba75445aa..dd70f701a 100644 --- a/karma.coverage.conf.js +++ b/karma.coverage.conf.js @@ -1,6 +1,6 @@ module.exports = function(config) { - config.set({ - browsers: ['Chrome', 'Firefox'], + var configuration = { + browsers: ['Firefox'], frameworks: ['browserify', 'jasmine'], @@ -24,5 +24,20 @@ module.exports = function(config) { { type: 'lcovonly', subdir: '.', file: 'lcov.info' } ] } - }); + }; + + // If on the CI, use the CI chrome launcher + if (process.env.TRAVIS) { + configuration.browsers.push('Chrome_travis_ci'); + configuration.customLaunchers = { + Chrome_travis_ci: { + base: 'Chrome', + flags: ['--no-sandbox'] + } + }; + } else { + configuration.browsers.push('Chrome'); + } + + config.set(configuration); }; \ No newline at end of file