thomasstreet/famous-angular-starter

Issue with unit test

Closed this issue · 2 comments

Hi,

Unit test (gulp test) are failing with the following error :

NFO [karma]: Karma v0.12.24 server started at http://localhost:9876/                                                                                                                                 
INFO [launcher]: Starting browser PhantomJS                                                                                                                                                           
INFO [PhantomJS 1.9.7 (Linux)]: Connected on socket 2ThvgK0qLRM3WHzuTun9 with id 38233390                                                                                                             
PhantomJS 1.9.7 (Linux) ERROR                                                                                                                                                                         
  TypeError: 'undefined' is not a function (evaluating 'window.requestAnimationFrame(loop)')                                                                                                          
  at /home/codio/workspace/famous-angular-starter/app/bower_components/famous/famous-global.js:434                                                                                                    
....

I think it comes from the fact that phantomJS does not know window.requestAnimationFrame

Have you ever succeeded in running the unit test with phantomJS in this project ?

You're spot-on about this issue being due to PhantomJS not natively supporting requestAnimationFrame. Fortunately, there's a polyfill that can be added, and that's how we manage unit tests with PhantomJS on the core project.

In the Famo.us/Angular codebase we use phantomjs-polyfills.js (included here https://github.com/Famous/famous-angular/blob/master/karma.conf.js#L17 and available here https://github.com/Famous/famous-angular/blob/master/test/phantomjs-polyfills.js). If you grab that file and that line of config, you should be good to go.

Hey @zackbrown
just made a PR #19 for fixing that
Instead of using https://github.com/Famous/famous-angular/blob/master/test/phantomjs-polyfills.js I used famous-polyfills bower package

I also fixed

  • karma.conf so tests can be run also outside of gulp
  • main test as it is looking for a property on scope that did not exist