fix(expect): honour the locator's own wait options#92
Merged
Conversation
A locator built with a custom timeout — locator(driver, sel, { timeout:
60_000 }) — had it respected by tap()/waitFor()/check() (which merge
this.options) but silently dropped by every expect(...) matcher, which
built its wait from the call-site options only and fell back to the 10s
default. Locator.options was private, so expect could not reach it.
Locator now exposes a public waitOptions getter, and expect's check()
merges { ...locator.waitOptions, ...callSiteOptions } — call-site still
wins, matching how interactions already resolve their options.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
locator(driver, sel, { timeout: 60_000 })— had them honoured bytap()/waitFor()/check()/setChecked()(which all mergethis.options) but silently dropped by everyexpect(locator)matcher, which assembled its wait from the call-site options only and fell back to the 10s default. So the same locator waited 60s for an interaction but 10s for an assertion — a confusing, undocumented inconsistency.Locator.optionswasprivate, soexpectcould not reach it.Locatorexposes a publicwaitOptionsgetter, andexpect'scheck()now merges{ ...locator.waitOptions, ...callSiteOptions, sleep }— the call-site option still wins, exactly as interactions already resolve theirs.Proof
npm run checkfix/expect-honors-locator-waitoptions:Checked 48 files in 22ms. No fixes applied.npm testintervalflows todriver.pause(), so the matcher's poll intervals equal the locator's7ms— the old code used the250msdefault — and a call-siteintervalstill overrides it).Risk
{}the merge is a no-op and behaviour is identical. Call-site options keep precedence.Notes
PR Proof Law
.agents/DEFINITION_OF_DONE.mdand.agents/skills/pr-inline-screenshot-proof/SKILL.md., or the proof section saysNot applicablewith the technical reason.