Karma: Running test with phantomjs ends-up with TypeError, while succeeds with Chrome

I have got some angular services and a simple test, which tests that 1 method returns an instance of some type.

When I run it in WebStorm with PhantomJS and Chrome

"browsers": ["PhantomJS", "ChromeCanary"]

All tests are passed in chrome but in PhantomJS some tests will pass, but the test mentioned above produces the type error. (Not the test, but the code which is being tested by the test)

    TypeError: 'undefined' is not a function (evaluating 'this._decorateParent.bind(this)')
       <... other info>

Sure, I can mock out some dependencies and it will help. But I want to know what is the reason for such behaviour.

angular.js v1.3.14  
karma      v0.12.32  
PhantomJS  v1.9.8  

illustration

Upvotes: 2

Views: 277

Answers (1)

Artjom B.
Artjom B.

Reputation: 61892

Update to PhantomJS 2 which is the easiest way to solve this. PhantomJS 1.x is based on a 4 year old fork of QtWebKit which didn't support Function.prototype.bind at the time. Usually a shim is required to make that function known to PhantomJS, but this might be hard to impossible to do for karma.

If you want to try it with a shim, this one has always worked for me.

Upvotes: 2

Related Questions