Skip to content

Commit 5f4b9cd

Browse files
marianayovchevastringiestleeky
committed
feat: Configuring capybara for @javascript tests
We want to use selenium_chrome_headless only on tests which require javascript running (cookie preferences). For the rest of the tests, we want to use the default rack_test driver Co-authored-by: Lucy Stringer <lucy.stringer@citizensadvice.org.uk> Co-authored-by: Leeky <robert.lee-cann@citizensadvice.org.uk>
1 parent 9d6752f commit 5f4b9cd

3 files changed

Lines changed: 8 additions & 0 deletions

File tree

config/environments/test.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
# and recreated between test runs. Don't rely on the data there!
99

1010
Rails.application.configure do
11+
config.hosts << "127.0.0.1"
12+
1113
# Configure 'rails notes' to inspect Cucumber files
1214
config.annotations.register_directories("features")
1315
config.annotations.register_extensions("feature") { |tag| /#\s*(#{tag}):?\s*(.*)$/ }

features/cookie_preferences.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
@javascript
12
Feature: Cookie preferences
23

34
Scenario: Visiting a page for the first time

features/support/env.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
# files.
88

99
require "cucumber/rails"
10+
require "capybara/cucumber"
1011

1112
# frozen_string_literal: true
1213

@@ -59,3 +60,7 @@
5960
# The :transaction strategy is faster, but might give you threading problems.
6061
# See https://github.com/cucumber/cucumber-rails/blob/master/features/choose_javascript_database_strategy.feature
6162
# Cucumber::Rails::Database.javascript_strategy = :truncation
63+
64+
Capybara.configure do |config|
65+
config.javascript_driver = :selenium_chrome_headless
66+
end

0 commit comments

Comments
 (0)