Skip to content

Instantly share code, notes, and snippets.

@ArturT
Created October 18, 2021 11:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ArturT/7d2eda7ff4fd18c89d75ac7340277748 to your computer and use it in GitHub Desktop.
Save ArturT/7d2eda7ff4fd18c89d75ac7340277748 to your computer and use it in GitHub Desktop.
rspec-retry only features (capybara) tests on CI
# spec/support/config/rspec_retry.rb
RSpec.configure do |config|
# show retry status in spec process
config.verbose_retry = true
# show exception that triggers a retry if verbose_retry is set to true
config.display_try_failure_messages = true
# run retry only on features
config.around :each, :js do |ex|
# retry test 3 times on CI but do not retry when testing locally
ex.run_with_retry retry: (ENV['CI'] ? 3 : 1)
end
# callback to be run between retries
config.retry_callback = proc do |ex|
# run some additional clean up task - can be filtered by example metadata
if ex.metadata[:js]
Capybara.reset!
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment