Files
Satyajit Sahoo 7e3205461b feat(expect): expect(fn).toPass() and expect.poll intervals (#2013)
* feat(expect)!: expect(fn).toPass() and expect.poll intervals

A block of assertions can be retried with `expect(fn).toPass({ timeout,
intervals })`, including the `.not.toPass()` and `expect.soft(fn).toPass()`
forms. Defaults are set with a top-level `toPass` config key. Both APIs
run on one retry loop.

BREAKING CHANGE: `expect.poll` no longer takes `interval`. It takes
`intervals`, a list of pauses whose last entry repeats. The default pauses
are `[100, 250, 500, 1000]` ms where they were a flat 100 ms.

Steps still running in a poll read or a toPass try are cancelled when the
try fails or is cut at its deadline. Later step calls from that try are
refused.

When a retry reaches the phase deadline, the runner's timeout is the
reported error. The last retry error is kept under `secondaryErrors`.

In `beforeAll`, `afterAll`, and worker fixture teardown, both APIs are
bounded by the hook deadline and use the config defaults.

A call `timeout` above the timer limit is `INVALID_CONFIG`.

* fix(expect): let skips through a retry and follow a moved deadline

A `test.skip()` or `test.fixme()` thrown inside a toPass block or a poll
read ends the retry right away and propagates unchanged.

The phase deadline is read on every pass, so a `test.setTimeout()` call
during a retry takes effect. The call's timeout stays fixed.

Options for `expect.poll` and `toPass` must be a plain object with known
keys.

* fix(expect): deprecate the interval option of expect.poll

`interval` works again as an alias for `intervals: [interval]`, following
the deprecation window in CONTRIBUTING.md. A warning that names `intervals`
is printed the first time it is used in a process. Passing both options is
`INVALID_CONFIG`.

* fix(expect): take a final sample at the deadline and refuse late ones

When a pause is cut short by the deadline, one more sample is taken. Its
result counts only if it settles without waiting past the deadline. A
sample that overran the time it had when it started no longer passes.

Call options for `intervals` use the config's rule, positive integers.

* fix(expect): drop the final sample at the deadline

The extra read counted only when it settled in its starting turn, so it
helped a synchronous read and never one that awaits the app or the
network. When the next pause would cross the deadline, the retry ends
without another read, as Playwright's loop does.

* fix(expect): keep a late try's skip and error

A try that settles after its time still does not pass. A `test.skip()` it
threw now reports `skipped`, and an error it threw is the `last:` line of
the timeout message.
2026-11-22 02:37:02 +00:00
..