Skip to content

Commit 8e89dfa

Browse files
committed
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/
1 parent eb143b7 commit 8e89dfa

File tree

6 files changed

+53
-8
lines changed

6 files changed

+53
-8
lines changed

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
language: node_js
22
node_js: ["0.10"]
3+
before_install:
4+
- export CHROME_BIN=chromium-browser
5+
- export DISPLAY=:99.0
6+
- sh -e /etc/init.d/xvfb start
37
before_script:
48
- npm install -g bower gulp
59
- bower install

gulpfile.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ gulp.task('lint', function () {
7272
module: true,
7373
require: true,
7474
__dirname: true,
75-
document: true
75+
document: true,
76+
process: true
7677
}
7778
}))
7879
// Outputs the results to the console

karma-dist-concatenated.conf.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ module.exports = function(config) {
1717
'karma-chai',
1818
'karma-sinon-chai',
1919
'karma-chrome-launcher',
20-
'karma-phantomjs-launcher',
2120
'karma-jquery',
2221
'karma-chai-jquery'
2322
],
@@ -67,11 +66,25 @@ module.exports = function(config) {
6766

6867
// start these browsers
6968
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
70-
browsers: ['PhantomJS'],
69+
browsers: ['Chrome'],
70+
71+
72+
// Use a custom launcher to run Chrome on TravisCI
73+
customLaunchers: {
74+
Chrome_travis_ci: {
75+
base: 'Chrome',
76+
flags: ['--no-sandbox']
77+
}
78+
},
7179

7280

7381
// Continuous Integration mode
7482
// if true, Karma captures browsers, runs the tests and exits
7583
singleRun: false
7684
});
85+
86+
// Switch browser to Chrome if TravisCI is detected
87+
if (process.env.TRAVIS) {
88+
config.browsers = ['Chrome_travis_ci'];
89+
}
7790
};

karma-dist-minified.conf.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ module.exports = function(config) {
1717
'karma-chai',
1818
'karma-sinon-chai',
1919
'karma-chrome-launcher',
20-
'karma-phantomjs-launcher',
2120
'karma-jquery',
2221
'karma-chai-jquery'
2322
],
@@ -67,11 +66,24 @@ module.exports = function(config) {
6766

6867
// start these browsers
6968
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
70-
browsers: ['PhantomJS'],
69+
browsers: ['Chrome'],
7170

7271

72+
// Use a custom launcher to run Chrome on TravisCI
73+
customLaunchers: {
74+
Chrome_travis_ci: {
75+
base: 'Chrome',
76+
flags: ['--no-sandbox']
77+
}
78+
},
79+
7380
// Continuous Integration mode
7481
// if true, Karma captures browsers, runs the tests and exits
7582
singleRun: false
7683
});
84+
85+
// Switch browser to Chrome if TravisCI is detected
86+
if (process.env.TRAVIS) {
87+
config.browsers = ['Chrome_travis_ci'];
88+
}
7789
};

karma-src.conf.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module.exports = function(config) {
1515
plugins: [
1616
'karma-jasmine',
1717
'karma-sinon-chai',
18-
'karma-phantomjs-launcher',
18+
'karma-chrome-launcher',
1919
'karma-spec-reporter'
2020
],
2121

@@ -65,11 +65,26 @@ module.exports = function(config) {
6565

6666
// start these browsers
6767
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
68-
browsers: ['PhantomJS'],
68+
browsers: ['Chrome'],
69+
70+
71+
// Use a custom launcher to run Chrome on TravisCI
72+
customLaunchers: {
73+
Chrome_travis_ci: {
74+
base: 'Chrome',
75+
flags: ['--no-sandbox']
76+
}
77+
},
6978

7079

7180
// Continuous Integration mode
7281
// if true, Karma captures browsers, runs the tests and exits
7382
singleRun: false
7483
});
84+
85+
// Switch browser to Chrome if TravisCI is detected
86+
if (process.env.TRAVIS) {
87+
config.browsers = ['Chrome_travis_ci'];
88+
}
7589
};
90+

test/unit/angular-zendesk-widget/zendeskWidgetSpec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ describe('Angular Zendesk Widget', function() {
88
module('zendeskWidget');
99
expect(function() {
1010
inject()
11-
}).toThrow();
11+
}).toThrowError('Missing accountUrl. Please set in app config via ZendeskWidgetProvider');
1212
});
1313

1414
});

0 commit comments

Comments
 (0)