fix(core): webview expect() keeps polling when the element is not in the DOM yet - #358
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Essentials Run ID: 📒 Files selected for processing (5)
Included review availability: This review used your included allowance. 1 included review remains after this review. Your included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour. WalkthroughMatcher evaluation now returns a separate missing-element verdict for absent single elements while allowing empty results for array matchers. The locator uses that verdict when injected evaluation returns null. Tests cover missing-element assertion results, visibility polling, and ordinary assertion failures. Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to The change allows absent-element assertions to keep polling while preserving immediate success for appropriate missing-element checks. No concrete merge-blocking risk is established; Android validation remains unreported. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Fixes #357
Problem
expect(webLocator).toBeVisible()on an element that is not in the DOM yet threw immediately instead of polling:buildExpectEvaluatepassedelements[0]straight into the injectedexpect(). Since Playwright 1.62 the injected matcher no longer guards against a missing element; playwright-core moved that handling server-side intoFrame._expectInternal, which mobilewright does not run. The throw escaped_expect, so polling never started.Fix
nullwhen a single-element matcher finds no element. Array matchers (to.have.count,*.array) still receive the empty list.missingElementVerdict()inweb-expect-matcher.tsdecides that case, mirroring the no-element branch ofFrame._expectInternal:toBeHidden/toBeDetachedpass.not.toBeVisible/not.toBeAttached/not.toBeInViewportpass._runInjectedExpectapplies it, so both callers (Playwright'sexpectvia_expect, and mobilewright's ownexpect) are covered.Tests
_expectpolling on a missing elementnpm test— 822 passed, 1 skippednpm run lintassertions-missingconformance spec (element added to the DOM after 1.5 s,toBeHidden,toBeVisibletiming out as an ordinary failure)nodeTypeerror before the fix and passes after