Retry Logic
// 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
// 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
Flaky Test
A test that passes and fails intermittently without any code changes, often caused by timing issues, shared state, async race conditions, or external dependencies. The single largest source of CI noise.
Auto-waiting
A framework feature that pauses an action until the target element is actionable (visible, enabled, stable). Eliminates most need for explicit sleeps and reduces flake.
Parallel Testing
Running multiple tests concurrently to reduce wall-clock time. Requires test independence — shared state will cause non-deterministic failures.
Learn more · TestNG
Chapter 4 · Lesson 3: Retry Logic for Failed Tests