Install your own PhantomJS on Travis CI

On a current project, we switched our javascript driver to Poltergeist, a driver for Capybara that allows you to run your tests in a headless browser provided by PhantomJS. Happy days and green dots locally, but our build server on Travis CI had a different opinion.

Failure/Error: And I am logged in as user "member@company.com"
  Capybara::Poltergeist::PhantomJSTooOld:
    PhantomJS version 1.6.1 is too old. You must use at least version 1.7.0

Fortunately Travis CI has made it easy and convenient to install any software you like on the virtual machine. So until the default is bumped to the required version of PhantomJS, add the following lines to your .travis.yml and you will be off and running with Poltergeist in no time.

before_install:                                                                                                                                                                                                                               
  - wget http://phantomjs.googlecode.com/files/phantomjs-1.7.0-linux-i686.tar.bz2                                                                                                                                                             
  - tar -xf phantomjs-1.7.0-linux-i686.tar.bz2                                                                                                                                                                                                
  - sudo rm -rf /usr/local/phantomjs                                                                                                                                                                                                          
  - sudo mv phantomjs-1.7.0-linux-i686 /usr/local/phantomjs
Photo of Eric Milford

Eric enjoys crafting well-architected web applications. With a career spanning nearly ten years, he has worked with established companies and small startups. An avid and passionate learner, Eric continues to grow as a developer and improve upon his craft.

Aside from coding, Eric enjoys singing and playing guitar, as well as performing improv comedy in his home of NYC. Having previously cooked professionally in fine dining, he is also learning to bake bread as an apprentice at SCRATCHBread in Brooklyn, NY.

Comments:


Post a Comment

(optional)
(optional — will be included as a link.)
  1. I believe this web site has got some really fantastic info for everyone . “I like work it fascinates me. I can sit and look at it for hours.” by Jerome K. Jerome.

    March 17, 2013 at 17:44 PM
  2. Hi,

    I tried above , but after adding above line into travis.yml my build is stopped.

    If i removed above line then travis build is complete.

    I am able to run my test on my local environment but not on travis.

    sujitlkumbhar@gmail.com
    Sujit Kumbhar
    July 10, 2015 at 6:05 AM