expect.poll.timeout not being respected
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
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
- [x] Follow our Code of Conduct
- [x] Read the Contributing Guidelines.
- [x] Read the docs.
- [x] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- [x] Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- [x] The provided reproduction is a minimal reproducible example of the bug.
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.
You don't change expect.poll.timeout in your reproduction
@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).
@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?
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