Playwright locator timeout is too high
Describe the bug
From what I see, the timeout I get when a locator doesn't match is 30 seconds, which is a lot.
As a reference, the default timeout in playwright itself seems to be 15 sec, and when using the webdriver.io provider, it seems to be reduced to 5 seconds which seems good enough to me.
Also I couldn't find the place to configure it.
Reproduction
Please tell me if you need a reproduction for this.
System Info
System:
OS: Linux 6.7 Debian GNU/Linux 12 (bookworm) 12 (bookworm)
CPU: (16) x64 11th Gen Intel(R) Core(TM) i9-11900H @ 2.50GHz
Memory: 36.15 GB / 62.54 GB
Container: Yes
Shell: 5.2.15 - /bin/bash
Binaries:
Node: 24.8.0 - /home/julien/.nvm/versions/node/v24.8.0/bin/node
Yarn: 1.22.22 - /usr/bin/yarn
npm: 11.6.0 - /home/julien/.nvm/versions/node/v24.8.0/bin/npm
pnpm: 10.9.0 - /home/julien/.local/share/pnpm/pnpm
bun: 1.0.29 - /home/julien/.bun/bin/bun
Deno: 2.0.0 - /home/julien/.cargo/bin/deno
Watchman: 4.9.0 - /usr/bin/watchman
Browsers:
Chrome: 142.0.7444.175
Chromium: 142.0.7444.175
Firefox: 140.5.0esr
Firefox Developer Edition: 140.5.0esr
npmPackages:
@vitest/browser: ^4.0.14 => 4.0.14
@vitest/browser-playwright: ^4.0.14 => 4.0.14
vitest: ^4.0.14 => 4.0.14
Used Package Manager
npm
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.
Playwright locators don't actually have a timeout. They timeout when the test timeouts (this is also how it works in playwright). Default timeout for tests is 30 seconds in browser mode. Funnily enough, the docs are wrong about the number which was 15 at one point: https://vitest.dev/config/testtimeout.html
Seems like it was changed in https://github.com/vitest-dev/vitest/pull/8705 - maybe by accident?
Ah interesting, I thought the matcher was producing the error because the error string isn't a generic one like "test timeout" but rather:
VitestBrowserElementError: Cannot find element with locator: getByRole('heading', { name: 'Usrs', level: 1 })
...
Caused by: Error: Matcher did not succeed in time.
Yes, it's done for better DX. The timeout itself is dynamic and based on the time left until the test timeout
So to configure it you can change the testTimeout value or set a static value via actionTimeout:
export default defineConfig({
test: {
testTimeout: 15_000,
browser: {
provider: playwright({ actionTimeout: 5_000 }),
},
},
})
Thanks!
I tried adding actionTimeout: 5_000, but it seems to be about 2 seconds, no matter the value I use... Isn't it weird?
Seems like it was changed in #8705 - maybe by accident?
Yes, this seems like a rebase/merge conflict mistake. Not intended.