How to See Your Feature Specs Run in the Browser

by Jason Swett,

When you write feature specs you can either have them run headlessly (i.e. invisibly) or not-headlessly, where you can actually see a browser instance being spun up and see your tests run in the browser.

I might be in the minority but I prefer to see the tests run in the browser, especially when I’m in the process of developing the tests.

Non-headless test running can be enabled with the following two steps.

First, add this to `spec/rails_helper.rb`:

Capybara.default_driver = :selenium_chrome

Then add these gems to the `Gemfile`:

group :development, :test do
  gem 'selenium-webdriver'
  gem 'chromedriver-helper'

And don’t forget to run `bundle install`.

Now, when you run your tests, they should come up in Chrome.

Leave a Reply

Your email address will not be published. Required fields are marked *