From 180eae99a751063e67ce1a4247b136cb607e1f83 Mon Sep 17 00:00:00 2001 From: "Dr. Kibitz" Date: Sun, 12 Jan 2014 01:07:13 -0800 Subject: [PATCH 1/3] Karma cleanup, spec reporter --- package.json | 4 +++- tasks/karma.js | 37 ++++++++++++++++--------------------- test/karma.conf.js | 13 +++++++------ 3 files changed, 26 insertions(+), 28 deletions(-) diff --git a/package.json b/package.json index 7d535b5..3346d9c 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,9 @@ "mocha": "~1.15", "chai": "~1.8", "karma": "~0.10", + "karma-chrome-launcher": "~0.1", "karma-firefox-launcher": "~0.1", - "karma-mocha": "~0.1" + "karma-mocha": "~0.1", + "karma-spec-reporter": "~0.0.6" } } diff --git a/tasks/karma.js b/tasks/karma.js index c340485..e20aca5 100644 --- a/tasks/karma.js +++ b/tasks/karma.js @@ -1,27 +1,22 @@ -'use strict'; - -var path = require('path'); -var server = require('karma').server; - module.exports = function (grunt) { - grunt.registerMultiTask('karma', 'run karma.', function() { - var done = this.async(); - var options = this.options({ - background: false - }); - var data = this.data; + 'use strict'; - //merge options onto data, with data taking precedence - data = grunt.util._.merge(options, data); - data.configFile = path.resolve(data.configFile); - if (data.configFile) { - data.configFile = grunt.template.process(data.configFile); + var path = require('path'); + var server = require('karma').server; + + grunt.registerMultiTask('karma', 'run karma.', function(target) { + //merge data onto options, with data taking precedence + var options = grunt.util._.merge(this.options(), this.data), + done = this.async(); + + if (options.configFile) { + options.configFile = grunt.template.process(options.configFile); + options.configFile = path.resolve(options.configFile); } - server.start( - data, - function(code) { - done(!code); - }); + done = this.async(); + server.start(options, function(code) { + done(!code); + }); }); }; diff --git a/test/karma.conf.js b/test/karma.conf.js index cf5f7c1..6c63217 100644 --- a/test/karma.conf.js +++ b/test/karma.conf.js @@ -17,12 +17,12 @@ module.exports = function(config) { ], // list of files to exclude - exclude : [], + //exclude : [], // use dolts reporter, as travis terminal does not support escaping sequences // possible values: 'dots', 'progress', 'junit', 'teamcity' // CLI --reporters progress - reporters : ['progress'], + reporters : ['spec'], // web server port // CLI --port 9876 @@ -39,7 +39,7 @@ module.exports = function(config) { // level of logging // possible values: karma.LOG_DISABLE || karma.LOG_ERROR || karma.LOG_WARN || karma.LOG_INFO || karma.LOG_DEBUG // CLI --log-level debug - logLevel : config.LOG_DEBUG, + logLevel : config.LOG_INFO, // enable / disable watching file and executing tests whenever any file changes // CLI --auto-watch --no-auto-watch @@ -69,14 +69,15 @@ module.exports = function(config) { reportSlowerThan : 500, preprocessors : { - // '**/client/js/*.js': 'coverage' + // '**/client/js/*.js': 'coverage' }, plugins : [ - 'karma-mocha', - // 'karma-chrome-launcher', + 'karma-chrome-launcher', 'karma-firefox-launcher', + 'karma-mocha', // 'karma-phantomjs-launcher' + 'karma-spec-reporter' ] }); }; From 6c6e7ca50fa2b03c8835e939bc20008f0769c0fc Mon Sep 17 00:00:00 2001 From: "Dr. Kibitz" Date: Sun, 12 Jan 2014 01:34:07 -0800 Subject: [PATCH 2/3] Add karma.conf.js to jshint --- Gruntfile.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 8f53bd3..81dd7d7 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -104,6 +104,7 @@ module.exports = function(grunt) { files: { srcBlob: '<%= dirs.src %>/**/*.js', testBlob: '<%= dirs.test %>/{functional,lib/pixi,unit/pixi}/**/*.js', + testConf: '<%= dirs.test %>/karma.conf.js', build: '<%= dirs.build %>/pixi.dev.js', buildMin: '<%= dirs.build %>/pixi.js' }, @@ -133,7 +134,10 @@ module.exports = function(grunt) { }, source: srcFiles.filter(function(v) { return v.match(/(Intro|Outro|Spine|Pixi)\.js$/) === null; }).concat('Gruntfile.js'), test: { - src: ['<%= files.testBlob %>'], + src: [ + '<%= files.testBlob %>', + '<%= files.testConf %>' + ], options: { jshintrc: undefined, //don't use jshintrc for tests expr: true, @@ -184,7 +188,7 @@ module.exports = function(grunt) { }, karma: { unit: { - configFile: 'test/karma.conf.js', + configFile: '<%= files.testConf %>', // browsers: ['Chrome'], singleRun: true } From 7ac987230fd5736f7cc14982090452e4ed419f41 Mon Sep 17 00:00:00 2001 From: "Dr. Kibitz" Date: Sun, 12 Jan 2014 01:43:42 -0800 Subject: [PATCH 3/3] Use jshint ignores option instead --- Gruntfile.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 81dd7d7..8bf07c2 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -103,7 +103,7 @@ module.exports = function(grunt) { }, files: { srcBlob: '<%= dirs.src %>/**/*.js', - testBlob: '<%= dirs.test %>/{functional,lib/pixi,unit/pixi}/**/*.js', + testBlob: '<%= dirs.test %>/**/*.js', testConf: '<%= dirs.test %>/karma.conf.js', build: '<%= dirs.build %>/pixi.dev.js', buildMin: '<%= dirs.build %>/pixi.js' @@ -132,13 +132,16 @@ module.exports = function(grunt) { options: { jshintrc: './.jshintrc' }, - source: srcFiles.filter(function(v) { return v.match(/(Intro|Outro|Spine|Pixi)\.js$/) === null; }).concat('Gruntfile.js'), - test: { - src: [ - '<%= files.testBlob %>', - '<%= files.testConf %>' - ], + source: { + src: srcFiles.concat('Gruntfile.js'), options: { + ignores: '<%= dirs.src %>/**/{Intro,Outro,Spine,Pixi}.js' + } + }, + test: { + src: ['<%= files.testBlob %>'], + options: { + ignores: '<%= dirs.test %>/lib/resemble.js', jshintrc: undefined, //don't use jshintrc for tests expr: true, undef: false,