Commit 731d574d authored by Douwe Maan's avatar Douwe Maan

Merge branch '30236-fix-capybara-timeouts' into 'master'

Increase Capybara's timeout

Closes #30236

See merge request !10337
parents b54acba8 2fa56074
...@@ -3,7 +3,7 @@ require 'capybara/poltergeist' ...@@ -3,7 +3,7 @@ require 'capybara/poltergeist'
require 'capybara-screenshot/spinach' require 'capybara-screenshot/spinach'
# Give CI some extra time # Give CI some extra time
timeout = (ENV['CI'] || ENV['CI_SERVER']) ? 30 : 10 timeout = (ENV['CI'] || ENV['CI_SERVER']) ? 60 : 30
Capybara.javascript_driver = :poltergeist Capybara.javascript_driver = :poltergeist
Capybara.register_driver :poltergeist do |app| Capybara.register_driver :poltergeist do |app|
...@@ -25,5 +25,5 @@ Capybara.ignore_hidden_elements = false ...@@ -25,5 +25,5 @@ Capybara.ignore_hidden_elements = false
Capybara::Screenshot.prune_strategy = :keep_last_run Capybara::Screenshot.prune_strategy = :keep_last_run
Spinach.hooks.before_run do Spinach.hooks.before_run do
TestEnv.warm_asset_cache unless ENV['CI'] || ENV['CI_SERVER'] TestEnv.eager_load_driver_server
end end
# rubocop:disable Style/GlobalVars
require 'capybara/rails' require 'capybara/rails'
require 'capybara/rspec' require 'capybara/rspec'
require 'capybara/poltergeist' require 'capybara/poltergeist'
require 'capybara-screenshot/rspec' require 'capybara-screenshot/rspec'
# Give CI some extra time # Give CI some extra time
timeout = (ENV['CI'] || ENV['CI_SERVER']) ? 30 : 10 timeout = (ENV['CI'] || ENV['CI_SERVER']) ? 60 : 30
Capybara.javascript_driver = :poltergeist Capybara.javascript_driver = :poltergeist
Capybara.register_driver :poltergeist do |app| Capybara.register_driver :poltergeist do |app|
...@@ -26,7 +27,10 @@ Capybara.ignore_hidden_elements = true ...@@ -26,7 +27,10 @@ Capybara.ignore_hidden_elements = true
Capybara::Screenshot.prune_strategy = :keep_last_run Capybara::Screenshot.prune_strategy = :keep_last_run
RSpec.configure do |config| RSpec.configure do |config|
config.before(:suite) do config.before(:context, :js) do
TestEnv.warm_asset_cache next if $capybara_server_already_started
TestEnv.eager_load_driver_server
$capybara_server_already_started = true
end end
end end
...@@ -169,16 +169,11 @@ module TestEnv ...@@ -169,16 +169,11 @@ module TestEnv
# #
# Otherwise they'd be created by the first test, often timing out and # Otherwise they'd be created by the first test, often timing out and
# causing a transient test failure # causing a transient test failure
def warm_asset_cache def eager_load_driver_server
return if warm_asset_cache?
return unless defined?(Capybara) return unless defined?(Capybara)
Capybara.current_session.driver.visit '/' puts "Starting the Capybara driver' server..."
end Capybara.current_session.visit '/'
def warm_asset_cache?
cache = Rails.root.join(*%w(tmp cache assets test))
Dir.exist?(cache) && Dir.entries(cache).length > 2
end end
private private
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment