vitest-dev / vitest-dev/vitest
vi.waitFor should respect expect.poll.timeout configuration as its default timeout
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 17.1k
- Forks
- 2k
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 94
Description
Describe the bug
Currently, vi.waitFor uses its own hardcoded default timeout value, which is inconsistent with the configurable expect.poll.timeout setting. Since vi.waitFor and expect.poll serve a conceptually similar purpose — repeatedly retrying an assertion or callback until it passes or times out — it would make sense for vi.waitFor to fall back to the expect.poll.timeout configuration value when no explicit timeout is provided.
Reproduction
// vitest.config.ts
export default defineConfig({
test: {
expect: {
poll: {
timeout: 10_000,
},
},
},
});
// Despite the config above, vi.waitFor still uses its own default timeout (e.g., 1000ms)
// instead of respecting the 10,000ms configured for expect.poll.timeout
await vi.waitFor(() => {
expect(someValue).toBe(true);
});
System Info
System:
OS: Windows 11 10.0.26200
CPU: (8) x64 Intel(R) Core(TM) i3-10100F CPU @ 3.60GHz
Memory: 15.99 GB / 31.93 GB
Binaries:
Node: 22.21.1 - C:\Users\Micha\AppData\Local\mise\installs\node\22.21.1\node.EXE
Yarn: 4.9.2 - C:\Users\Micha\AppData\Local\mise\installs\node\22.21.1\yarn.CMD
npm: 11.10.1 - C:\Users\Micha\AppData\Local\mise\installs\node\22.21.1\npm.CMD
Browsers:
Chrome: 145.0.7632.111
Edge: Chromium (142.0.3595.69)
npmPackages:
@vitejs/plugin-react: ^5.1.4 => 5.1.4
@vitest/browser-playwright: ^4.0.18 => 4.0.18
@vitest/ui: ^4.0.18 => 4.0.18
playwright: ^1.58.2 => 1.58.2
vite: ^7.3.1 => 7.3.1
vitest: ^4.0.18 => 4.0.18
vitest-browser-react: ^2.0.5 => 2.0.5
Used Package Manager
yarn
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the TypeScript implementation of vi.waitFor and how expect.poll.timeout is loaded from vitest.config.ts. Add a regression test covering a configured poll timeout when vi.waitFor has no explicit timeout, and verify that an explicit timeout still takes precedence.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- testing-qa
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100