Capybara is a fantastic testing tool. In our experience, we've encountered fragile feature specs when running headless browsers.
At it's core,
Capybara::Maleficent exposes a method for wrapping blocks of code within sleep intervals (see
Capybara::Maleficent.with_sleep_injection), rescuing handled exceptions and trying again. Yes, this is not ideal, as it slows down potential tests. But it is far worse (again in our experience) to have a of Capybara spec fail erratically.
This gem goes a step further, when you
require 'capybara/maleficent/spindle', then the node matchers will automatically make use of the
The nature of
Capybara::Maleficent is such that most of the time the matching will be as fast as they can be (they're slow enough as you are leveraging a browser for this testing). However, when a failure occurs,
Capybara::Maleficent assumes that its due to a slowness in the browser (and not an actual failure). From there, it sleeps for a bit, then tries again.
In you Gemfile:
gem 'capybara-maleficent', require 'false'