vitest icon indicating copy to clipboard operation
vitest copied to clipboard

expect.poll.timeout not being respected

Open KieranP opened this issue 5 months ago • 6 comments

Describe the bug

Am using Vitest browser with Playwright runner, and rendering Svelte components. In vite.config.js, I have test.expect.poll.timeout set to 500ms and test.testTimeout set to 5000ms (5s).

When awaiting expect.element on a locator that doesn't match anything, instead of timing out within 500ms, it takes the full 5s to timeout.

I don't want to decrease test.testTimeout value because some tests take 1-2 seconds. Should test.expect.poll.timeout be working in this instance? Or am I misunderstanding how it operates?

Reproduction

vitest-issue-8308.zip

Download, extract, yarn, then yarn test results in timeout after 5s, not 500ms

System Info

System:
    OS: macOS 15.5
    CPU: (14) arm64 Apple M4 Pro
    Memory: 168.45 MB / 24.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.15.1 - ~/.asdf/installs/nodejs/22.15.1/bin/node
    Yarn: 4.9.2 - ~/.asdf/installs/nodejs/22.15.1/bin/yarn
    npm: 10.9.2 - ~/.asdf/plugins/nodejs/shims/npm
  Browsers:
    Brave Browser: 138.1.80.120
    Chrome: 138.0.7204.101
    Safari: 18.5
  npmPackages:
    @vitest/browser: ^3.2.4 => 3.2.4 
    @vitest/ui: ^3.2.4 => 3.2.4 
    playwright: ^1.54.1 => 1.54.1 
    vite: ^7.0.4 => 7.0.4 
    vitest: ^3.2.4 => 3.2.4 
    vitest-browser-svelte: ^1.0.0 => 1.0.

Used Package Manager

yarn

Validations

KieranP avatar Jul 15 '25 00:07 KieranP

Hello @KieranP. Please provide a minimal reproduction using a GitHub repository or StackBlitz (you can also use examples). Issues marked with needs reproduction will be closed if they have no activity within 3 days.

github-actions[bot] avatar Jul 15 '25 09:07 github-actions[bot]

You don't change expect.poll.timeout in your reproduction

sheremet-va avatar Jul 15 '25 09:07 sheremet-va

@sheremet-va I have updated the ticket description to include a Zip file of a minimal reproduction. If you unzip, run yarn, and then yarn test you will see that the test times out after 5s (test.testTimeout), when it should be timing out much sooner at 500ms (test.expect.poll.timeout).

KieranP avatar Jul 16 '25 02:07 KieranP

@sheremet-va Looks like this was closed automatically, even though I provided a reproduction as asked. Will this be reversed, or should I open a new issue?

KieranP avatar Jul 20 '25 00:07 KieranP

FWIW, I can also reproduce this when setting poll timeouts in vite.config.ts.

I made another repro for this bug before realising there's already an open issue with a repro: https://github.com/ezzatron/vitest-poll-timeout-repro

Still happening as of Vitest 4.0.15:

 RUN  v4.0.15 /path/to/ezzatron/vitest-poll-timeout-repro

 ❯  chromium  repro.test.tsx (4 tests | 4 failed) 61740ms
   × should fail expect.poll in 500ms because of local poll timeout 601ms
   × should fail expect.poll in 500ms because of config poll timeout 562ms
   × should fail expect.element in 500ms because of local poll timeout 582ms
   × should fail expect.element in 500ms because of config poll timeout 59994ms

ezzatron avatar Dec 11 '25 22:12 ezzatron