Retry Logic

Automation

// Definition

Re-running a failing test or step automatically. Useful for taming flake from infrastructure issues — but can mask real bugs if used as a band-aid for genuinely flaky tests.

// Code Example

CypressConfigure retries for transient failures
TypeScript
// cypress.config.ts — retry failed tests in CI only
export default defineConfig({
  retries: { runMode: 2, openMode: 0 },
});

// Per-test override for known-flaky third parties
it('handles slow third-party widget', { retries: 3 }, () => {
  cy.visit('/checkout');
  cy.get('[data-testid=widget]').should('be.visible');
});

// Related terms

Learn more · TestNG

Chapter 4 · Lesson 3: Retry Logic for Failed Tests