Skip to content
Latchkey

Playwright "expect.poll" Timeout - Polling Assertion Never Passes

expect.poll(fn).toBe(...) re-invokes fn until it matches or the timeout elapses. The failure means the polled value never reached the expected state in time - often a backend that is slower in CI, or polling a source that never updates.

What this error means

A polling assertion fails with "Timeout exceeded while waiting for expect.poll." It frequently passes locally and flakes in CI where the API or job it polls takes longer to reach the expected value.

Playwright output
Error: expect.poll(received).toBe(expected)

  Timeout 5000ms exceeded while waiting on the predicate
  Last received value: "pending"  (expected: "done")

Common causes

Polled state reaches the value slower in CI

A background job or API the test polls finishes later on a loaded runner than locally. The default poll timeout expires before the value flips - a timing-only flake.

Polling a stale or wrong source

The poll function reads a cached response, a different record, or never re-fetches, so it can never observe the change. This is deterministic, and a longer timeout will not help.

How to fix it

Give the poll realistic timing and re-fetch each time

Raise the timeout for genuinely slow backends and ensure the predicate fetches fresh state every poll.

job.spec.ts
await expect
  .poll(async () => (await api.getJob(id)).status, {
    timeout: 30000,
    intervals: [500, 1000, 2000],
  })
  .toBe('done');

Verify the source actually changes

  1. Log the last received value - confirm it is moving toward the expected state.
  2. Make sure the predicate re-requests data and bypasses any client cache.
  3. If the value is genuinely stuck, fix the backend/seed rather than extending the timeout.

How to prevent it

  • Set poll timeouts/intervals sized for the slowest CI tier.
  • Ensure poll predicates fetch fresh state, not cached values.
  • Prefer event/response waits over polling when an explicit signal exists.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →