Skip to content

Add per-test retry support #1101

@sirenkovladd

Description

@sirenkovladd

Add the ability to automatically re-run failed tests a configurable number of times. Retries are essential for flaky integration and E2E tests where transient failures (network timeouts, resource contention, race conditions) cause false negatives in CI.

Motivation

Flaky tests are a reality in any non-trivial project. Without retries, teams either:

  • Disable flaky tests — losing coverage
  • Commit process.exit(0) hacks — masking real failures
  • Add manual retry loops in test code — verbose, error-prone, and not standardized

Every major runner supports this: Jest (--retryTimes), Mocha (--retries), Playwright (retries), Vitest (retry).

Proposal

Global CLI flag

poku --retries 2

Retries each failed test file up to 2 additional times (3 total attempts) before marking it as failed. Default: 0 (no retries, current behavior).

Config file:

{
  "retries": 2
}

Per-test option (primary use case)

import { it } from 'poku';

// This specific test retries up to 3 times before failing
it('flaky API call', { retries: 3 }, async () => {
  const res = await fetch('/api/data');
  assert.strictEqual(res.status, 200);
});

// Other tests use the global default (0 retries unless --retries is set)
it('stable test', () => {
  assert.ok(true);
});

Output

On retry, poku should indicate the retry in the reporter output:

✔ login flow (1 retry)
✖ dashboard loads (3/3 attempts failed)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions