I have an application which I just updated to 1.5.0-rc.1, and all our tests began to fail. It appears that the latest releases of Karma and PhantomJS are incompatible with rc1, though I'm not sure what's changed.
Tested with [email protected]
and [email protected]
, see the gist's package.json
for more specifics.
To reproduce, clone and see the files in this gist: https://gist.github.com/mattdsteele/33f9b237fd13e9edc222
The error I'm seeing:
Error: [$injector:modulerr] Failed to instantiate module ng due to:
TypeError: 'undefined' is not an object (evaluating 'Function.prototype.bind.apply')
at instantiate (C:/app/node_modules/angular/angular.js:4622)
at provider (C:/app/node_modules/angular/angular.js:4433)
at C:/app/node_modules/angular/angular.js:385
at forEach (C:/app/node_modules/angular/angular.js:355)
at C:/app/node_modules/angular/angular.js:4423
at ngModule (C:/app/node_modules/angular/angular.js:2492)
at invoke (C:/app/node_modules/angular/angular.js:4604)
at runInvokeQueue (C:/app/node_modules/angular/angular.js:4497)
at C:/app/node_modules/angular/angular.js:4506
at forEach (C:/app/node_modules/angular/angular.js:341)
at loadModules (C:/app/node_modules/angular/angular.js:4529)
at createInjector (C:/app/node_modules/angular/angular.js:4409)
at workFn (C:/app/node_modules/angular-mocks/angular-mocks.js:2799)
at C:/app/node_modules/angular-mocks/angular-mocks.js:2779
at C:/app/sampleProvider_spec.js:38
http://errors.angularjs.org/1.5.0-rc.1/$injector/modulerr?p0=ng&p1=TypeError%3A%20'undefined'%20is%20not%20an%20object%20(evaluating%20'Function.prototype.bind.apply')%0A%20%20%20%20at%20instantiate%20(http%3A%2F%2Flocalhost%3A9876%2FC:/app%2Fnode_modules%2Fangular%2Fangular.js%3F0bb3a8e438d28a96d20c57229ea2d6f6be3eedbc%3A4622)%0A%20%20%20%20at%20provider%20(http%3A%2F%2Flocalhost%3A9876%2Fbase%2Fnode_modules%2Fangular%2Fangular.js%3F0bb3a8e438d28a96d20c57229ea2d6f6be3eedbc%3A4433)%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A9876%2Fbase%2Fnode_modules%2Fangular%2Fangular.js%3F0bb3a8e438d28a96d20c57229ea2d6f6be3eedbc%3A385%0A%20%20%20%20at%20forEach%20(http%3A%2F%2Flocalhost%3A9876%2Fbase%2Fnode_modules%2Fangular%2Fangular.js%3F0bb3a8e438d28a96d20c57229ea2d6f6be3eedbc%3A355)%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A9876%2Fbase%2Fnode_modules%2Fangular%2Fangular.js%3F0bb3a8e438d28a96d20c57229ea2d6f6be3eedbc%3A4423%0A%20%20%20%20at%20ngModule%20(http%3A%2F%2Flocalhost%3A9876%2Fbase%2Fnode_modules%2Fangular%2Fangular.js%3F0bb3a8e438d28a96d20c57229ea2d6f6be3eedbc%3A2492)%0A%20%20%20%20at%20invoke%20(http%3A%2F%2Flocalhost%3A9876%2Fbase%2Fnode_modules%2Fangular%2Fangular.js%3F0bb3a8e438d28a96d20c57229ea2d6f6be3eedbc%3A4604)%0A%20%20%20%20at%20runInvokeQueue%20(http%3A%2F%2Flocalhost%3A9876%2Fbase%2Fnode_modules%2Fangular%2Fangular.js%3F0bb3a8e438d28a96d20c57229ea2d6f6be3eedbc%3A4497)%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A9876%2Fbase%2Fnode_modules%2Fangular%2Fangular.js%3F0bb3a8e438d28a96d20c57229ea2d6f6be3eedbc%3A4506%0A%20%20%20%20at%20forEach%20(http%3A%2F%2Flocalhost%3A9876%2Fbase%2Fnode_modules%2Fangular%2Fangular.js%3F0bb3a8e438d28a96d20c57229ea2d6f6be3eedbc%3A341)%0A%20%20%20%20at%20loadModules%20(http%3A%2F%2Flocalhost%3A9876%2Fbase%2Fnode_modules%2Fangular%2Fangular.js%3F0bb3a8e438d28a96d20c57229ea2d6f6be3eedbc%3A4529)%0A%20%20%20%20at%20createInjector%20(http%3A%2F%2Flocalhost%3A9876%2Fbase%2Fnode_modules%2Fangular%2Fangular.js%3F0bb3a8e438d28a96d20c57229ea2d6f6be3eedbc%3A4409)%0A%20%20%20%20at%20workFn%20(http%3A%2F%2Flocalhost%3A9876%2Fbase%2Fnode_modules%2Fangular-mocks%2Fangular-mocks.js%3F15873dbd705e0c8571c8c5d0a1bd3d60324beb9c%3A2799)%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A9876%2Fbase%2Fnode_modules%2Fangular-mocks%2Fangular-mocks.js%3F15873dbd705e0c8571c8c5d0a1bd3d60324beb9c%3A2779%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A9876%2Fbase%2FsampleProvider_spec.js%3F264ed98e3af6ef6813ab2d8fdc752a9b30a6e6db%3A38%0A%20%20%20%20at%20attemptSync%20(http%3A%2F%2Flocalhost%3A9876%2Fbase%2Fnode_modules%2Fjasmine-core%2Flib%2Fjasmine-core%2Fjasmine.js%3F391e45351df9ee35392d2e5cb623221a969fc009%3A1886)%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A9876%2Fbase%2Fnode_modules%2Fjasmine-core%2Flib%2Fjasmine-core%2Fjasmine.js%3F391e45351df9ee35392d2e5cb623221a969fc009%3A1874%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A9876%2Fbase%2Fnode_modules%2Fjasmine-core%2Flib%2Fjasmine-core%2Fjasmine.js%3F391e45351df9ee35392d2e5cb623221a969fc009%3A1859%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A9876%2Fbase%2Fnode_modules%2Fjasmine-core%2Flib%2Fjasmine-core%2Fjasmine.js%3F391e45351df9ee35392d2e5cb623221a969fc009%3A697%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A9876%2Fbase%2Fnode_modules%2Fjasmine-core%2Flib%2Fjasmine-core%2Fjasmine.js%3F391e45351df9ee35392d2e5cb623221a969fc009%3A363%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A9876%2Fbase%2Fnode_modules%2Fjasmine-core%2Flib%2Fjasmine-core%2Fjasmine.js%3F391e45351df9ee35392d2e5cb623221a969fc009%3A2479%0A%20%20%20%20at%20attemptAsync%20(http%3A%2F%2Flocalhost%3A9876%2Fbase%2Fnode_modules%2Fjasmine-core%2Flib%2Fjasmine-core%2Fjasmine.js%3F391e45351df9ee35392d2e5cb623221a969fc009%3A1916)%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A9876%2Fbase%2Fnode_modules%2Fjasmine-core%2Flib%2Fjasmine-core%2Fjasmine.js%3F391e45351df9ee35392d2e5cb623221a969fc009%3A1871%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A9876%2Fbase%2Fnode_modules%2Fjasmine-core%2Flib%2Fjasmine-core%2Fjasmine.js%3F391e45351df9ee35392d2e5cb623221a969fc009%3A1859%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A9876%2Fbase%2Fnode_modules%2Fjasmine-core%2Flib%2Fjasmine-core%2Fjasmine.js%3F391e45351df9ee35392d2e5cb623221a969fc009%3A697%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A9876%2Fbase%2Fnode_modules%2Fjasmine-core%2Flib%2Fjasmine-core%2Fjasmine.js%3F391e45351df9ee35392d2e5cb623221a969fc009%3A2473%0A%20%20%20%20at%20attemptAsync%20(http%3A%2F%2Flocalhost%3A9876%2Fbase%2Fnode_modules%2Fjasmine-core%2Flib%2Fjasmine-core%2Fjasmine.js%3F391e45351df9ee35392d2e5cb623221a969fc009%3A1916)%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A9876%2Fbase%2Fnode_modules%2Fjasmine-core%2Flib%2Fjasmine-core%2Fjasmine.js%3F391e45351df9ee35392d2e5cb623221a969fc009%3A1871%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A9876%2Fbase%2Fnode_modules%2Fjasmine-core%2Flib%2Fjasmine-core%2Fjasmine.js%3F391e45351df9ee35392d2e5cb623221a969fc009%3A1898%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A9876%2Fbase%2Fnode_modules%2Fjasmine-core%2Flib%2Fjasmine-core%2Fjasmine.js%3F391e45351df9ee35392d2e5cb623221a969fc009%3A1842%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A9876%2Fbase%2Fnode_modules%2Fjasmine-core%2Flib%2Fjasmine-core%2Fjasmine.js%3F391e45351df9ee35392d2e5cb623221a969fc009%3A2467%0A%20%20%20%20at%20clearStack%20(http%3A%2F%2Flocalhost%3A9876%2Fbase%2Fnode_modules%2Fjasmine-core%2Flib%2Fjasmine-core%2Fjasmine.js%3F391e45351df9ee35392d2e5cb623221a969fc009%3A660)%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A9876%2Fbase%2Fnode_modules%2Fjasmine-core%2Flib%2Fjasmine-core%2Fjasmine.js%3F391e45351df9ee35392d2e5cb623221a969fc009%3A1881%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A9876%2Fbase%2Fnode_modules%2Fjasmine-core%2Flib%2Fjasmine-core%2Fjasmine.js%3F391e45351df9ee35392d2e5cb623221a969fc009%3A1898%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A9876%2Fbase%2Fnode_modules%2Fjasmine-core%2Flib%2Fjasmine-core%2Fjasmine.js%3F391e45351df9ee35392d2e5cb623221a969fc009%3A1842%0A%20%20%20%20at%20complete%20(http%3A%2F%2Flocalhost%3A9876%2Fbase%2Fnode_modules%2Fjasmine-core%2Flib%2Fjasmine-core%2Fjasmine.js%3F391e45351df9ee35392d2e5cb623221a969fc009%3A371)%0A%20%20%20%20at%20clearStack%20(http%3A%2F%2Flocalhost%3A9876%2Fbase%2Fnode_modules%2Fjasmine-core%2Flib%2Fjasmine-core%2Fjasmine.js%3F391e45351df9ee35392d2e5cb623221a969fc009%3A660)%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A9876%2Fbase%2Fnode_modules%2Fjasmine-core%2Flib%2Fjasmine-core%2Fjasmine.js%3F391e45351df9ee35392d2e5cb623221a969fc009%3A1881%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A9876%2Fbase%2Fnode_modules%2Fjasmine-core%2Flib%2Fjasmine-core%2Fjasmine.js%3F391e45351df9ee35392d2e5cb623221a969fc009%3A1859%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A9876%2Fbase%2Fnode_modules%2Fjasmine-core%2Flib%2Fjasmine-core%2Fjasmine.js%3F391e45351df9ee35392d2e5cb623221a969fc009%3A697%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A9876%2Fbase%2Fnode_modules%2Fjasmine-core%2Flib%2Fjasmine-core%2Fjasmine.js%3F391e45351df9ee35392d2e5cb623221a969fc009%3A363%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A9876%2Fbase%2Fnode_modules%2Fjasmine-core%2Flib%2Fjasmine-core%2Fjasmine.js%3F391e45351df9ee35392d2e5cb623221a969fc009%3A2479%0A%20%20%20%20at%20attemptAsync%20(http%3A%2F%2Flocalhost%3A9876%2Fbase%2Fnode_modules%2Fjasmine-core%2Flib%2Fjasmine-core%2Fjasmine.js%3F391e45351df9ee35392d2e5cb623221a969fc009%3A1916)%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A9876%2Fbase%2Fnode_modules%2Fjasmine-core%2Flib%2Fjasmine-core%2Fjasmine.js%3F391e45351df9ee35392d2e5cb623221a969fc009%3A1871%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A9876%2Fbase%2Fnode_modules%2Fjasmine-core%2Flib%2Fjasmine-core%2Fjasmine.js%3F391e45351df9ee35392d2e5cb623221a969fc009%3A1859%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A9876%2Fbase%2Fnode_modules%2Fjasmine-core%2Flib%2Fjasmine-core%2Fjasmine.js%3F391e45351df9ee35392d2e5cb623221a969fc009%3A697%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A9876%2Fbase%2Fnode_modules%2Fjasmine-core%2Flib%2Fjasmine-core%2Fjasmine.js%3F391e45351df9ee35392d2e5cb623221a969fc009%3A2473%0A%20%20%20%20at%20attemptAsync%20(http%3A%2F%2Flocalhost%3A9876%2Fbase%2Fnode_modules%2Fjasmine-core%2Flib%2Fjasmine-core%2Fjasmine.js%3F391e45351df9ee35392d2e5cb623221a969fc009%3A1916)%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A9876%2Fbase%2Fnode_modules%2Fjasmine-core%2Flib%2Fjasmine-core%2Fjasmine.js%3F391e45351df9ee35392d2e5cb623221a969fc009%3A1871%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A9876%2Fbase%2Fnode_modules%2Fjasmine-core%2Flib%2Fjasmine-core%2Fjasmine.js%3F391e45351df9ee35392d2e5cb623221a969fc009%3A1859%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A9876%2Fbase%2Fnode_modules%2Fjasmine-core%2Flib%2Fjasmine-core%2Fjasmine.js%3F391e45351df9ee35392d2e5cb623221a969fc009%3A697%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A9876%2Fbase%2Fnode_modules%2Fjasmine-core%2Flib%2Fjasmine-core%2Fjasmine.js%3F391e45351df9ee35392d2e5cb623221a969fc009%3A2473%0A%20%20%20%20at%20attemptAsync%20(http%3A%2F%2Flocalhost%3A9876%2Fbase%2Fnode_modules%2Fjasmine-core%2Flib%2Fjasmine-core%2Fjasmine.js%3F391e45351df9ee35392d2e5cb623221a969fc009%3A1916)%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A9876%2Fbase%2Fnode_modules%2Fjasmine-core%2Flib%2Fjasmine-core%2Fjasmine.js%3F391e45351df9ee35392d2e5cb623221a969fc009%3A1871%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A9876%2Fbase%2Fnode_modules%2Fjasmine-core%2Flib%2Fjasmine-core%2Fjasmine.js%3F391e45351df9ee35392d2e5cb623221a969fc009%3A1859%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A9876%2Fbase%2Fnode_modules%2Fjasmine-core%2Flib%2Fjasmine-core%2Fjasmine.js%3F391e45351df9ee35392d2e5cb623221a969fc009%3A697%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A9876%2Fbase%2Fnode_modules%2Fjasmine-core%2Flib%2Fjasmine-core%2Fjasmine.js%3F391e45351df9ee35392d2e5cb623221a969fc009%3A2332%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A9876%2Fbase%2Fnode_modules%2Fjasmine-core%2Flib%2Fjasmine-core%2Fjasmine.js%3F391e45351df9ee35392d2e5cb623221a969fc009%3A761%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A9876%2Fbase%2Fnode_modules%2Fkarma-jasmine%2Flib%2Fadapter.js%3F3030709c83121e1b2ca4d1e657306b834fc13350%3A318%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A9876%2Fkarma.js%3A191%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A9876%2Fcontext.html%3A48
at forEach (C:/app/node_modules/angular/angular.js:341)
at loadModules (C:/app/node_modules/angular/angular.js:4529)
at createInjector (C:/app/node_modules/angular/angular.js:4409)
at workFn (C:/app/node_modules/angular-mocks/angular-mocks.js:2799)
at C:/app/node_modules/angular-mocks/angular-mocks.js:2779
at C:/app/sampleProvider_spec.js:38
at C:/app/node_modules/angular/angular.js:4527
TypeError: 'undefined' is not an object (evaluating 'sample.getValue')
at C:/app/sampleProvider_spec.js:42
PhantomJS 1.9.8 (Windows 7 0.0.0): Executed 2 of 2 (2 FAILED) ERROR (0.014 secs / 0.007 secs)
The tests pass if I do any of the following:
angular
and angular-mocks
to 1.5.0-rc.0
PhantomJS
to Chrome
The tests do not pass if I:
Tested on Windows 7 and OS X.
Phantom 1.x doesn't have Function.prototype.bind. Just use Phantom 2.x or a polyfill.
Using a polyfill fixed the issue for me.
Interestingly we already had a Function.prototype.bind
polyfill in our code (MDN's version) but it didn't seem to get triggered in our PhantomJS environment.
Switching to this polyfill worked.
Should this be announced more widely? I'm not sure whether this is necessarily a breaking change, but there's enough usage of Phantom 1.x + Karma out there that I'd guess this will hit a lot of folks.
PhantomJs isn't among the officially supported browsers. Also, Phantom JS 1 is very old. We'll rely on the social channels here to spread the word. I'm leaving this issue open for a bit because of that.
It was hard for me to figure out how to use PhantomJS2 as an alternative to polyfill. Here are the steps I used, in case it helps others:
@gillius Thanks, this is good info. I'm gonna close this issue, as there's nothing more we can do about this.
Why is this not in the changelog?
Because we don't support PhamtomJS officially
FYI: karma-phantomjs2-launcher is deprecated. If you update karma-phantomjs-launcher to "1.0.0" you get the same effect (PhantomJS 2.1.1) and you don't need to edit karma.conf.
For me. https://www.npmjs.com/package/phantomjs-polyfill
That polyfill worked. The bower one listed above did not resolve the issue..
Most helpful comment
It was hard for me to figure out how to use PhantomJS2 as an alternative to polyfill. Here are the steps I used, in case it helps others: