Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(browser): fail playwright timeouts earlier than a test timeout #7565

Merged
merged 14 commits into from
Mar 7, 2025

Conversation

sheremet-va
Copy link
Member

@sheremet-va sheremet-va commented Feb 26, 2025

Description

Closes #7309
Related #7559

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. If the feature is substantial or introduces breaking changes without a discussion, PR might be closed.
  • Ideally, include a test that fails without this PR but passes with it.
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.

Tests

  • Run the tests with pnpm test:ci.

Documentation

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs command.

Changesets

  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.

Copy link

netlify bot commented Feb 26, 2025

Deploy Preview for vitest-dev ready!

Name Link
🔨 Latest commit 8082868
🔍 Latest deploy log https://app.netlify.com/sites/vitest-dev/deploys/67c071d835039b00086fdb72
😎 Deploy Preview https://deploy-preview-7565--vitest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@sheremet-va sheremet-va requested a review from hi-ogawa February 27, 2025 14:08
Copy link
Contributor

@hi-ogawa hi-ogawa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! I was worrying about test.concurrent breaking getWorkerState().current state, but it's probably fine since people wouldn't use concurrent tests with dom interaction/assertions.

@@ -91,7 +91,7 @@ export function createExpectPoll(expect: ExpectStatic): ExpectStatic['poll'] {
const rejectWithCause = (cause: any) => {
reject(
copyStackTrace(
new Error(`Matcher did not succeed in ${timeout}ms`, {
new Error('Matcher did not succeed in time.', {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any reason for removing ${timeout}ms from the error message?

Copy link
Member Author

@sheremet-va sheremet-va Mar 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mostly because the new timeout value is now irrelevant - it's set by Vitest and equal to basically random numbers (to the user) - like 3542ms, 2323ms. I don't think they are worth printing out and just confusing

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I didn't realize expect.element is doing processTimeoutOptions. It looks good to me 👍
If I remember correctly, playwright doesn't change the error message when they patch timeout, so they are lying 😄

sheremet-va and others added 2 commits March 6, 2025 16:04
Co-authored-by: Hiroshi Ogawa <hi.ogawa.zz@gmail.com>
@sheremet-va sheremet-va merged commit 5eb4cd1 into vitest-dev:main Mar 7, 2025
13 checks passed
@sheremet-va sheremet-va deleted the fix/browser-timeout-error branch March 7, 2025 08:54
return options_
}
const currentTest = getWorkerState().current
const startTime = currentTest?.result?.startTime
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might not be a good idea. The current will return the test even if it runs beforeEach and afterEach, and the timeout there must be different!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Interacting with page.getBy*non-existing element hangs instead of throwing
2 participants