The task
src/lib/auth/retry-utils.ts exports sleep, retryWithBackoff and retrySupabaseAuth, and
has no test file. Add one.
Why this is a good first issue
The module has zero references to document, window, fetch, localStorage or a database
client — the retry logic is self-contained, and you supply the function it retries. That means
you can test it by passing in a function you control: one that always fails, one that fails
twice then succeeds, one that succeeds immediately.
Where the test goes
src/lib/auth/retry-utils.test.ts, beside the source.
Acceptance criteria
The one thing that matters here
Count the calls, don't just check the answer. expect(fn).toHaveBeenCalledTimes(3) is the
assertion that actually proves retrying happened; asserting only the final value would pass
against an implementation that never retried at all.
Then break it on purpose — set max attempts to 1, or delete the retry loop — and confirm your
test goes red. Say which mutation you tried in the PR. A test that cannot fail is the most
common defect in this repo (#396).
Getting set up
docker compose up -d
docker compose exec scripthammer pnpm test --run src/lib/auth/retry-utils.test.ts
The task
src/lib/auth/retry-utils.tsexportssleep,retryWithBackoffandretrySupabaseAuth, andhas no test file. Add one.
Why this is a good first issue
The module has zero references to
document,window,fetch,localStorageor a databaseclient — the retry logic is self-contained, and you supply the function it retries. That means
you can test it by passing in a function you control: one that always fails, one that fails
twice then succeeds, one that succeeds immediately.
Where the test goes
src/lib/auth/retry-utils.test.ts, beside the source.Acceptance criteria
src/lib/auth/retry-utils.test.tsretryWithBackoffsucceeds on the first try without retrying — assert the suppliedfunction was called exactly once, not just that the result was right
vi.useFakeTimers()) rather than really waiting for the backoff — a testthat sleeps for real makes the whole suite slower for everyone
docker compose exec scripthammer pnpm test --run src/lib/auth/retry-utils.test.tspassesThe one thing that matters here
Count the calls, don't just check the answer.
expect(fn).toHaveBeenCalledTimes(3)is theassertion that actually proves retrying happened; asserting only the final value would pass
against an implementation that never retried at all.
Then break it on purpose — set max attempts to 1, or delete the retry loop — and confirm your
test goes red. Say which mutation you tried in the PR. A test that cannot fail is the most
common defect in this repo (#396).
Getting set up