From 3f98e2e559bef6508486c9b1ec0f661a03436b91 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Thu, 15 Feb 2024 10:20:42 +1100 Subject: [PATCH] Reduce Capybara wait time during development In test-driven development, you run tests and expect them to fail. Waiting for the results unnecessarily long just slows down development. And even though CI can be slow, we should aim for good performance of our code. Long wait times can hide performance bottle necks. If anyone struggles with the default value, we can add an environment variable to adjust the wait time to your machine in .env.test.local. But this may just work for everyone. --- spec/system/support/capybara_setup.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/spec/system/support/capybara_setup.rb b/spec/system/support/capybara_setup.rb index 6e46d77420..075826951b 100644 --- a/spec/system/support/capybara_setup.rb +++ b/spec/system/support/capybara_setup.rb @@ -4,10 +4,9 @@ # This allows us to find with `expect(page).to have_field "Name"` Capybara.enable_aria_label = true -# Usually, especially when using Selenium, developers tend to increase the max wait time. -# With Cuprite, there is no need for that. -# We use a Capybara default value here explicitly. -Capybara.default_max_wait_time = 10 +# The default wait time is 2 seconds. Small is good for test-driven development +# ensuring efficient code but CI can be a bit slow. We want to avoid flakiness. +Capybara.default_max_wait_time = 10 if ENV["CI"] # Normalize whitespaces when using `has_text?` and similar matchers, # i.e., ignore newlines, trailing spaces, etc.