Skip to content

Surface in-flight expect.poll on test timeout error #10136

@hi-ogawa

Description

@hi-ogawa

Describe the bug

When test timeout occurs with pending expect.poll like below:

import { expect, test } from 'vitest'

test('repro', { timeout: 2000 }, async () => {
  await expect.poll(async () => {
    return 4321
  }, { timeout: 10000 }).toBe(1234)
})

the timeout error points to the test definition only and the actual cause of expect.poll is unclear.

 FAIL  test/repro.test.ts > repro
Error: Test timed out in 2000ms.
If this is a long-running test, pass a timeout value as the last argument or configure it globally with "testTimeout".
 ❯ test/repro.test.ts:3:1
      1| import { expect, test } from 'vitest';
      2|
      3| test('repro', { timeout: 2000 }, async () => {
       | ^
      4|   await expect
      5|     .poll(

Reproduction

https://stackblitz.com/edit/vitest-dev-vitest-vmfmewqp?file=test%2Frepro.test.ts

System Info

Stackblitz
Vitest v4.1.4

Used Package Manager

npm

Validations

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions