How to run Jasmine javascript tests in CI server (Ruby)

Jasmine.js is a great testing framework for Javascript. However running tests in Continuous Integration (CI) server is somehow problematic because the server usually does not have a screen where to open a browser.

The solution is to use Xvfb and headless gem:

Headless is the Ruby interface for Xvfb. It allows you to create a headless display straight from Ruby code, hiding some low-level action. It can also capture images and video from the virtual framebuffer.

To run your tests in CI server, do the following steps:

  1. Install xvfb
    $ sudo apt-get install xvfb
  2. Install firefox
    $ sudo apt-get install firefox
  3. Install headless gem
    $ gem install headless
    add it to Gemfile
    gem ‘headless’
    and run
    $ bundle install
  4. create rake task for headless jasmine runner (
  5. run or add rake task to your build configuration
    rake jasmine:ci:headless