From 8e89dfa4af42b4a3dbae7583dd15537ce621e753 Mon Sep 17 00:00:00 2001 From: Kel Kanhirun Date: Wed, 1 Jun 2016 09:00:10 -0500 Subject: [PATCH 1/5] Fixes error where app module cannot be imported When calling `module()` with `inject()`, an error is thrown: ``` Error: [$injector:modulerr] Failed to instantiate module ng due to: TypeError: 'undefined' is not an object (evaluating 'Function.prototype.bind.apply') ``` PhantomJS is not amongst Karma's officially supported browsers. In 1.x, `Function.prototype.bind` isn't defined. Instead of polyfilling, or using Phantom 2.x, it is better to stick with supported browsers. (In addition, TravisCI has been reconfigured to run Chrome.) READ MORE: http://blog.500tech.com/setting-up-travis-ci-to-run-tests-on-latest-google-chrome-version/ --- .travis.yml | 4 ++++ gulpfile.js | 3 ++- karma-dist-concatenated.conf.js | 17 +++++++++++++++-- karma-dist-minified.conf.js | 16 ++++++++++++++-- karma-src.conf.js | 19 +++++++++++++++++-- .../zendeskWidgetSpec.js | 2 +- 6 files changed, 53 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8a4cb73..d3da6e1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,9 @@ language: node_js node_js: ["0.10"] +before_install: + - export CHROME_BIN=chromium-browser + - export DISPLAY=:99.0 + - sh -e /etc/init.d/xvfb start before_script: - npm install -g bower gulp - bower install diff --git a/gulpfile.js b/gulpfile.js index 9ba5d88..2fecf86 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -72,7 +72,8 @@ gulp.task('lint', function () { module: true, require: true, __dirname: true, - document: true + document: true, + process: true } })) // Outputs the results to the console diff --git a/karma-dist-concatenated.conf.js b/karma-dist-concatenated.conf.js index ad8cf85..db6e00c 100644 --- a/karma-dist-concatenated.conf.js +++ b/karma-dist-concatenated.conf.js @@ -17,7 +17,6 @@ module.exports = function(config) { 'karma-chai', 'karma-sinon-chai', 'karma-chrome-launcher', - 'karma-phantomjs-launcher', 'karma-jquery', 'karma-chai-jquery' ], @@ -67,11 +66,25 @@ module.exports = function(config) { // start these browsers // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher - browsers: ['PhantomJS'], + browsers: ['Chrome'], + + + // Use a custom launcher to run Chrome on TravisCI + customLaunchers: { + Chrome_travis_ci: { + base: 'Chrome', + flags: ['--no-sandbox'] + } + }, // Continuous Integration mode // if true, Karma captures browsers, runs the tests and exits singleRun: false }); + + // Switch browser to Chrome if TravisCI is detected + if (process.env.TRAVIS) { + config.browsers = ['Chrome_travis_ci']; + } }; diff --git a/karma-dist-minified.conf.js b/karma-dist-minified.conf.js index bf58e54..07879c7 100644 --- a/karma-dist-minified.conf.js +++ b/karma-dist-minified.conf.js @@ -17,7 +17,6 @@ module.exports = function(config) { 'karma-chai', 'karma-sinon-chai', 'karma-chrome-launcher', - 'karma-phantomjs-launcher', 'karma-jquery', 'karma-chai-jquery' ], @@ -67,11 +66,24 @@ module.exports = function(config) { // start these browsers // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher - browsers: ['PhantomJS'], + browsers: ['Chrome'], + // Use a custom launcher to run Chrome on TravisCI + customLaunchers: { + Chrome_travis_ci: { + base: 'Chrome', + flags: ['--no-sandbox'] + } + }, + // Continuous Integration mode // if true, Karma captures browsers, runs the tests and exits singleRun: false }); + + // Switch browser to Chrome if TravisCI is detected + if (process.env.TRAVIS) { + config.browsers = ['Chrome_travis_ci']; + } }; diff --git a/karma-src.conf.js b/karma-src.conf.js index aa48853..5ebae22 100644 --- a/karma-src.conf.js +++ b/karma-src.conf.js @@ -15,7 +15,7 @@ module.exports = function(config) { plugins: [ 'karma-jasmine', 'karma-sinon-chai', - 'karma-phantomjs-launcher', + 'karma-chrome-launcher', 'karma-spec-reporter' ], @@ -65,11 +65,26 @@ module.exports = function(config) { // start these browsers // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher - browsers: ['PhantomJS'], + browsers: ['Chrome'], + + + // Use a custom launcher to run Chrome on TravisCI + customLaunchers: { + Chrome_travis_ci: { + base: 'Chrome', + flags: ['--no-sandbox'] + } + }, // Continuous Integration mode // if true, Karma captures browsers, runs the tests and exits singleRun: false }); + + // Switch browser to Chrome if TravisCI is detected + if (process.env.TRAVIS) { + config.browsers = ['Chrome_travis_ci']; + } }; + diff --git a/test/unit/angular-zendesk-widget/zendeskWidgetSpec.js b/test/unit/angular-zendesk-widget/zendeskWidgetSpec.js index 8b01731..2cedd2c 100644 --- a/test/unit/angular-zendesk-widget/zendeskWidgetSpec.js +++ b/test/unit/angular-zendesk-widget/zendeskWidgetSpec.js @@ -8,7 +8,7 @@ describe('Angular Zendesk Widget', function() { module('zendeskWidget'); expect(function() { inject() - }).toThrow(); + }).toThrowError('Missing accountUrl. Please set in app config via ZendeskWidgetProvider'); }); }); From 79ca3152ac233f6058c93456d6ce7ab06d9f308b Mon Sep 17 00:00:00 2001 From: Kel Kanhirun Date: Sat, 4 Jun 2016 18:45:04 -0500 Subject: [PATCH 2/5] Chore: Removes PhantomJS support on Karma READ MORE: 5fa13245cc536af723a464cb02bc9b2d54ea5b80 --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index 9d7d603..36ce1f9 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,6 @@ "karma-jasmine": "^0.3.6", "karma-jquery": "^0.1.0", "karma-mocha": "^0.1.8", - "karma-phantomjs-launcher": "^0.1.4", "karma-sinon-chai": "^0.2.0", "karma-spec-reporter": "^0.0.18", "mocha": "^1.21.4", From d1af81a8afa2e52d431856ef386a8d0d3ee71306 Mon Sep 17 00:00:00 2001 From: Kel Kanhirun Date: Mon, 6 Jun 2016 15:18:26 -0500 Subject: [PATCH 3/5] Fixes existing tests to successfully run as minified The matcher, `toThrowError()` is valid only in Jasmine, and not Mocha. Managing multiple competing test frameworks is not ideal. Therefore, I have configured all karma config files to use Jasmine only. --- karma-dist-concatenated.conf.js | 8 +++----- karma-dist-minified.conf.js | 8 +++----- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/karma-dist-concatenated.conf.js b/karma-dist-concatenated.conf.js index db6e00c..9dbe80d 100644 --- a/karma-dist-concatenated.conf.js +++ b/karma-dist-concatenated.conf.js @@ -10,15 +10,13 @@ module.exports = function(config) { // frameworks to use // available frameworks: https://npmjs.org/browse/keyword/karma-adapter - frameworks: ['mocha', 'chai-jquery', 'jquery-1.8.3', 'sinon-chai'], + frameworks: ['jasmine'], plugins: [ - 'karma-mocha', - 'karma-chai', + 'karma-jasmine', 'karma-sinon-chai', 'karma-chrome-launcher', - 'karma-jquery', - 'karma-chai-jquery' + 'karma-spec-reporter' ], // list of files / patterns to load in the browser diff --git a/karma-dist-minified.conf.js b/karma-dist-minified.conf.js index 07879c7..62981da 100644 --- a/karma-dist-minified.conf.js +++ b/karma-dist-minified.conf.js @@ -10,15 +10,13 @@ module.exports = function(config) { // frameworks to use // available frameworks: https://npmjs.org/browse/keyword/karma-adapter - frameworks: ['mocha', 'chai-jquery', 'jquery-1.8.3', 'sinon-chai'], + frameworks: ['jasmine'], plugins: [ - 'karma-mocha', - 'karma-chai', + 'karma-jasmine', 'karma-sinon-chai', 'karma-chrome-launcher', - 'karma-jquery', - 'karma-chai-jquery' + 'karma-spec-reporter' ], // list of files / patterns to load in the browser From 895eee981dca9a301e25486cf03713a7a7f2a49b Mon Sep 17 00:00:00 2001 From: Kel Kanhirun Date: Mon, 6 Jun 2016 15:26:06 -0500 Subject: [PATCH 4/5] Chore: Replaces support for Mocha for Jasmine See: 8e89dfa4af42b4a3dbae7583dd15537ce621e753 --- package.json | 2 -- 1 file changed, 2 deletions(-) diff --git a/package.json b/package.json index 36ce1f9..aa2153b 100644 --- a/package.json +++ b/package.json @@ -29,10 +29,8 @@ "karma-chrome-launcher": "^0.1.4", "karma-jasmine": "^0.3.6", "karma-jquery": "^0.1.0", - "karma-mocha": "^0.1.8", "karma-sinon-chai": "^0.2.0", "karma-spec-reporter": "^0.0.18", - "mocha": "^1.21.4", "run-sequence": "^1.0.2", "sinon": "^1.10.3", "sinon-chai": "^2.5.0" From 8ae668400857eaf21d5303311f8741719a4911b2 Mon Sep 17 00:00:00 2001 From: Kel Kanhirun Date: Mon, 6 Jun 2016 20:10:11 -0500 Subject: [PATCH 5/5] Adds missing build artifacts See: 2a2a03173c6e240111c5ea84c50323ce34e1e4aa --- dist/angular-zendesk-widget.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/dist/angular-zendesk-widget.js b/dist/angular-zendesk-widget.js index b1fc16d..640c54f 100644 --- a/dist/angular-zendesk-widget.js +++ b/dist/angular-zendesk-widget.js @@ -10,13 +10,12 @@ } var window = $window; + // Following is essentially a copy paste of JS portion of the Zendesk embed code // with our settings subbed in. For more info, see: // https://support.zendesk.com/hc/en-us/articles/203908456-Using-Web-Widget-to-embed-customer-service-in-your-website - // Note that JSHint ignore is not working in latest release, so can't actually turn - // on JSHint yet. See https://github.com/jshint/jshint/issues/2411 - /* jshint ignore:start */ + /*eslint-disable */ window.zEmbed || function(e, t) { var n, o, d, i, s, a = [], @@ -35,7 +34,7 @@ }, o.write(''), o.close() }("https://assets.zendesk.com/embeddable_framework/main.js", zendeskWidgetSettings.accountUrl); - /* jshint ignore:end */ + /*eslint-enable */ $window.zE(function() { zendeskWidgetSettings.beforePageLoad($window.zE);