- run a small install script setting up the remaining dependency of PhantomJS and PhantomJS itself,
- start up a virtual framebuffer (xvfb, “headless” is not completely true when on Linux) running on port 99
- and finally run PhantomJS with the QUnit (alternatively Jasmine) test runner on our test suite.
Here is the full .travis.yml file:
rvm: - 1.9.3before_script: - "sudo bash install_phantomjs > /dev/null" - sh -e /etc/init.d/xvfb startscript: - DISPLAY=:99.0 phantomjs run-qunit.js test/index.html
The first line indicates that we are wanting Ruby version 1.9.3, even though we don’t need it. I believe we have to chose some target system, so there it goes.Here is the install_phantomjs script:
#!/bin/bashapt-get install libqtwebkit-dev -ygit clone git://github.com/ariya/phantomjs.gitcd phantomjsqmake-qt4makecp bin/phantomjs /usr/local/bin/We are ready to test this on Travis. If you haven’t registered there yet, get an account, set up the hook by visiting your profile page, and commit your own .travis.yml together with the PhantomJS install script and the relevant test runner described above. You should pretty quickly find your project in the build queue on travis-ci.org. Happy testing!