Rerun failed tests automatically?

We have some flakey webdriver tests. We generally have to use “Rerun failed tests” once for each build. Is there a way to get CircleCI to rerun failed tests once automatically before reporting a failure?

Not at this time unfortunately. There is an open feature request here where we are tracking this ask, but I don’t have a timeline to share.

For Rails this is what I do:

In spec/spec_helper.rb:

RSpec.configure do |config|
  config.example_status_persistence_file_path = "spec/status.txt"

In .circleci/config.yml:

- run: |
    if grep -q "failed" "spec/status.txt"; then
      grep -v passed spec/status.txt
      bundle exec rspec --format progress --only-failures

I hope this helps!