in Development, Rails

Headless javascript tests with capybara-webkit and Ubuntu

After some struggle I found a working solution for integration testing with enabled javascript on my headless ubuntu setup.

We need an X-server and QT4

sudo apt-get install libicu48 xvfb libqt4-dev

Gemfile:

group :development, :test do
  gem 'rspec-rails'
  gem 'capybara'
  gem 'capybara-webkit'
  gem 'headless'
end

/spec/rails_helper.rb

Capybara.javascript_driver = :webkit
...
RSpec.configure do |config|
...
  config.before(:suite) do
    @headless = Headless.new
    @headless.start
  end

  config.after(:suite) do
    @headless.destroy
  end
end

Webmentions

  • Headless javascript tests with poltergeist and Ubuntu – Entwicklerbier

    […] If you already have a nodejs dependency, I recommend the following solution for headless testing instead of my first one. […]