From b456d9a11a44f31aa0b71309a87c0318e570a1f7 Mon Sep 17 00:00:00 2001 From: Braydon Fuller Date: Wed, 26 Nov 2014 09:55:03 -0500 Subject: [PATCH 1/8] Tests: Add karma config and dependencies --- gulpfile.js | 4 ++++ karma.conf.js | 9 +++++++++ package.json | 2 ++ 3 files changed, 15 insertions(+) create mode 100644 karma.conf.js diff --git a/gulpfile.js b/gulpfile.js index 646588d..f23dc57 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -85,6 +85,10 @@ gulp.task('browser-test', shell.task([ 'find test/ -type f -name "*.js" | xargs browserify -o ./browser/tests.js' ])); +gulp.task('karma', shell.task([ + './node_modules/karma/bin/karma start karma.conf.js' +])); + gulp.task('minify', function() { return gulp.src('dist/bitcore.js') .pipe(closureCompiler({ diff --git a/karma.conf.js b/karma.conf.js new file mode 100644 index 0000000..eb04f38 --- /dev/null +++ b/karma.conf.js @@ -0,0 +1,9 @@ +// karma.conf.js +module.exports = function(config) { + config.set({ + frameworks: ['mocha'], + files: [ + 'browser/tests.js' + ] + }); +}; diff --git a/package.json b/package.json index 6254f19..cf1f1a5 100644 --- a/package.json +++ b/package.json @@ -92,6 +92,8 @@ "lodash": "^2.4.1", "mocha": "~2.0.1", "run-sequence": "^1.0.2" + "karma": "^0.12.28", + "karma-mocha": "^0.1.9", }, "license": "MIT" } From 3300aa80159604256a0a3f921051fcc3a0b3abf2 Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Wed, 26 Nov 2014 16:52:45 -0300 Subject: [PATCH 2/8] fix package.json --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index cf1f1a5..decd5e3 100644 --- a/package.json +++ b/package.json @@ -91,9 +91,9 @@ "gulp-shell": "^0.2.10", "lodash": "^2.4.1", "mocha": "~2.0.1", - "run-sequence": "^1.0.2" + "run-sequence": "^1.0.2", "karma": "^0.12.28", - "karma-mocha": "^0.1.9", + "karma-mocha": "^0.1.9" }, "license": "MIT" } From 25651813e88c1da9995a3d225440faed6d1a3f90 Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Wed, 26 Nov 2014 18:50:53 -0300 Subject: [PATCH 3/8] make travis run all tests --- .travis.yml | 17 +++++++++-------- gulpfile.js | 33 ++++++++++++++++++++++++--------- karma.conf.js | 4 ++++ package.json | 2 +- 4 files changed, 38 insertions(+), 18 deletions(-) diff --git a/.travis.yml b/.travis.yml index 88d499a..e8d01a5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,12 @@ language: node_js node_js: - '0.10' -notifications: - hipchat: - rooms: - secure: p6IUoOsKoM7cEmUsYh9JV5XKpUSASXukGkiBxdPU+ELM1CgNT0PyUROXwgDvI0vjSBCJemNh5sqrEQWiT70PcR69rH1JQ6+mHZah4r6W1Ql0NuWibvsofLyCeTzW2nrptdx97Z4y65NiHsaaOo3F+BShTeBpmBAvRMNp/FLMjWU= - template: - - '%{repository}#%{build_number} (%{branch} - %{commit} : %{author}): %{message} (Details/Change view)' - format: html - on_success: never +before_install: + - npm install -g bower + - npm install -g grunt-cli + - export DISPLAY=:99.0 + - sh -e /etc/init.d/xvfb start +install: + - bower install + - npm install + diff --git a/gulpfile.js b/gulpfile.js index f23dc57..a1adf03 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -33,12 +33,23 @@ function ignoreError() { /* jshint ignore:end */ } -function testMocha() { - return gulp.src(tests).pipe(new mocha({reporter: 'spec'})); -} +var testMocha = function() { + return gulp.src(tests).pipe(new mocha({ + reporter: 'spec' + })); +}; + +var testKarma = shell.task([ + './node_modules/karma/bin/karma start --single-run --browsers Firefox' +]); + gulp.task('test', testMocha); +gulp.task('test-all', function(callback) { + runSequence(['test'], ['karma'], callback); +}); + gulp.task('test-nofail', function() { return testMocha().on('error', ignoreError); }); @@ -55,6 +66,10 @@ gulp.task('watch:lint', function() { return gulp.watch(alljs, ['lint']); }); +gulp.task('watch:browser', function() { + return gulp.watch(alljs, ['browser', 'browser-test']); +}); + gulp.task('coverage', shell.task(['istanbul cover _mocha -- --recursive'])); gulp.task('jsdoc', function() { @@ -81,13 +96,13 @@ gulp.task('browser', function() { .pipe(gulp.dest('browser')); }); -gulp.task('browser-test', shell.task([ - 'find test/ -type f -name "*.js" | xargs browserify -o ./browser/tests.js' -])); +gulp.task('browser-test', function() { + shell.task([ + 'find test/ -type f -name "*.js" | xargs browserify -o ./browser/tests.js' + ]); +}); -gulp.task('karma', shell.task([ - './node_modules/karma/bin/karma start karma.conf.js' -])); +gulp.task('karma', testKarma); gulp.task('minify', function() { return gulp.src('dist/bitcore.js') diff --git a/karma.conf.js b/karma.conf.js index eb04f38..cc5620a 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -1,7 +1,11 @@ +'use strict'; + // karma.conf.js module.exports = function(config) { config.set({ frameworks: ['mocha'], + browsers: ['Chrome', 'Firefox'], + singleRun: true, files: [ 'browser/tests.js' ] diff --git a/package.json b/package.json index decd5e3..8274dae 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "main": "index.js", "scripts": { "lint": "gulp lint", - "test": "gulp test", + "test": "gulp test-all", "coverage": "gulp coverage", "build": "gulp" }, From 089744f64590eba71a42ee8cfbb7b34b42e4796f Mon Sep 17 00:00:00 2001 From: Braydon Fuller Date: Wed, 26 Nov 2014 17:20:58 -0500 Subject: [PATCH 4/8] Tests: Add firefox launcher to package.json for karma tests --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 8274dae..ee928d6 100644 --- a/package.json +++ b/package.json @@ -93,7 +93,8 @@ "mocha": "~2.0.1", "run-sequence": "^1.0.2", "karma": "^0.12.28", - "karma-mocha": "^0.1.9" + "karma-mocha": "^0.1.9", + "karma-firefox-launcher": "^0.1.3" }, "license": "MIT" } From 433cd815438cac97b49623a92d319c6865f4a442 Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Wed, 26 Nov 2014 19:33:50 -0300 Subject: [PATCH 5/8] add npm install hook for browserify --- gulpfile.js | 4 ++++ package.json | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/gulpfile.js b/gulpfile.js index a1adf03..9ea31e9 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -102,6 +102,10 @@ gulp.task('browser-test', function() { ]); }); +gulp.task('browser-all', function(callback) { + runSequence(['browser'], ['browser-test'], callback); +}); + gulp.task('karma', testKarma); gulp.task('minify', function() { diff --git a/package.json b/package.json index 8274dae..956ab26 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,8 @@ "lint": "gulp lint", "test": "gulp test-all", "coverage": "gulp coverage", - "build": "gulp" + "build": "gulp", + "postinstall": "gulp browser-all" }, "contributors": [ { From 4fb0ddd8f2a0d687ebb75fae9f4023c6e2d4c31e Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Wed, 26 Nov 2014 19:36:59 -0300 Subject: [PATCH 6/8] use local gulp --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 956ab26..831f671 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "test": "gulp test-all", "coverage": "gulp coverage", "build": "gulp", - "postinstall": "gulp browser-all" + "postinstall": "node_modules/gulp/bin/gulp.js browser-all" }, "contributors": [ { From 115c581bd0c28232a0a631ac5099c79112b39739 Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Wed, 26 Nov 2014 19:48:28 -0300 Subject: [PATCH 7/8] simplify gulpfile for watch:browser --- gulpfile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gulpfile.js b/gulpfile.js index 9ea31e9..8919e52 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -67,7 +67,7 @@ gulp.task('watch:lint', function() { }); gulp.task('watch:browser', function() { - return gulp.watch(alljs, ['browser', 'browser-test']); + return gulp.watch(alljs, ['browser-all']); }); gulp.task('coverage', shell.task(['istanbul cover _mocha -- --recursive'])); From c6a0803df2577b2ab38ee28f604682b4ee47c0f3 Mon Sep 17 00:00:00 2001 From: Braydon Fuller Date: Wed, 26 Nov 2014 18:13:03 -0500 Subject: [PATCH 8/8] Tests: Fix browser-test build --- gulpfile.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 8919e52..6285ae7 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -96,11 +96,9 @@ gulp.task('browser', function() { .pipe(gulp.dest('browser')); }); -gulp.task('browser-test', function() { - shell.task([ +gulp.task('browser-test', shell.task([ 'find test/ -type f -name "*.js" | xargs browserify -o ./browser/tests.js' - ]); -}); +])); gulp.task('browser-all', function(callback) { runSequence(['browser'], ['browser-test'], callback);