From 942f6a9adde39d500d45e666757bda3e472597d1 Mon Sep 17 00:00:00 2001 From: Austin Clark Date: Thu, 15 Oct 2015 12:47:06 -0600 Subject: [PATCH] Fix karma-coverage version, use `gulp unit` to run unit tests Downgrades karma-coverages, uses phantomJS to run unit test, and finally adds gulp unit as the test runner. Karma was having issues with Chrome+Browserify. Unit tests still do not run since the example services were removed. Change-Id: I8973a1e12b0b2af992bea5da552aae0736dcdf9c --- app/js/main.js | 10 +++++++--- package.json | 5 ++--- test/karma.conf.js | 10 +++++----- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/app/js/main.js b/app/js/main.js index 9c16a18..6b6e229 100644 --- a/app/js/main.js +++ b/app/js/main.js @@ -11,8 +11,7 @@ require('./controllers/_index'); require('./services/_index'); require('./directives/_index'); -// create and bootstrap application -angular.element(document).ready(function() { +var bootstrap = function() { var requires = [ 'ui.router', @@ -35,4 +34,9 @@ angular.element(document).ready(function() { angular.bootstrap(document, ['app']); -}); + window.bootstrap = null; + +}; +// create and bootstrap application +angular.element(document).ready(bootstrap); +window.bootstrap = bootstrap; diff --git a/package.json b/package.json index dd5d1cb..8d54dce 100644 --- a/package.json +++ b/package.json @@ -53,9 +53,8 @@ "karma": "~0.12.0", "karma-babel-preprocessor": "^4.0.1", "karma-browserify": "^4.0.0", - "karma-chrome-launcher": "0.1.8", "karma-cli": "0.0.4", - "karma-coverage": "0.3.1", + "karma-coverage": "0.2.6", "karma-jasmine": "^0.3.6", "karma-phantomjs-launcher": "0.2.0", "morgan": "^1.6.1", @@ -71,7 +70,7 @@ }, "scripts": { "postinstall": "if [ ! -d .venv ]; then tox -epy27 --notest; fi", - "test": "karma start karma.conf.js --single-run", + "test": "gulp unit", "lint": "eslint --no-color stackviz/static" }, "dependencies": {} diff --git a/test/karma.conf.js b/test/karma.conf.js index 358c44a..50bace0 100644 --- a/test/karma.conf.js +++ b/test/karma.conf.js @@ -12,10 +12,11 @@ module.exports = function(config) { preprocessors: { 'app/js/**/*.js': ['browserify', 'babel', 'coverage'] }, - browsers: ['Chrome'], + browsers: ['PhantomJS'], reporters: ['progress', 'coverage'], autoWatch: true, + singleRun: true, browserify: { debug: true, @@ -35,13 +36,12 @@ module.exports = function(config) { urlRoot: '/__karma__/', files: [ - // 3rd-party resources - 'node_modules/angular/angular.min.js', - 'node_modules/angular-mocks/angular-mocks.js', - // app-specific code 'app/js/main.js', + // 3rd-party resources + 'node_modules/angular-mocks/angular-mocks.js', + // test files 'test/unit/**/*.js' ]