Repository navigation
Conversation
expect(locator).toBeInViewport({ ratio?, timeout? }) waits for the one
match to be shown with at least `ratio` of its box inside the viewport of
a screen observation, so it works on every engine that reports node
boxes. Negated, it passes for a hidden, absent, or off-screen match.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Read a shown node without a box as outside the viewport, allow Playwright's 1e-9 tolerance on the ratio, refuse `ratio: null`, print the unrounded ratio, and document where engines cut a box to its container. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Group the clipping limits in the reference entry, drop semicolons from the JSDoc and changeset, link the Detox row to the reference instead of repeating the Android limit, and phrase the migration rows as steps. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
satya164
marked this pull request as draft
November 23, 2026 15:19
Contributor
🟢 e2e web: 95 passedAll 95 tests in 43 files
Tested by e2e 0.24.0 · 1m 3s · web · run artifacts |
Contributor
🟢 e2e web agent: 34 passed35 agent steps · 26 replayed from cache · 26 model calls · 142.6k tokens (93% cached) · $0.0061 All 34 tests in 5 files
Tested by e2e 0.24.0 · 1m 37s · web · run artifacts |
Contributor
🟢 e2e android agent: 20 passed24 agent steps · 15 replayed from cache · 49 model calls · 370.1k tokens (85% cached) · $0.0225 All 20 tests in 1 file
Tested by e2e 0.24.0 · 5m 57s · android-emulator · run artifacts |
Member
|
I am closing this one in favor of #2011 |
Contributor
🟢 e2e ios: 59 passed, 1 skippedAll 60 tests in 7 files
Tested by e2e 0.24.0 · 7m 7s · ios-simulator · run artifacts |
Contributor
🟢 e2e android: 60 passed, 1 skippedAll 61 tests in 7 files
Tested by e2e 0.24.0 · 9m 14s · android-emulator · run artifacts |
Contributor
🟢 e2e ios agent: 21 passed, 1 skipped25 agent steps · 12 replayed from cache · 55 model calls · 391.8k tokens (84% cached) · $0.0245 All 22 tests in 1 file
Tested by e2e 0.24.0 · 7m 55s · ios-simulator · run artifacts |
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.
Adds
expect(locator).toBeInViewport({ ratio?, timeout? }). It's Playwright's matcher for checking that a node is inside the viewport.toBeVisible()passes for an off-screen pager page or content scrolled out of view, so tests had to pollboundingBox()against the viewport size instead.Replaces #2111. GitHub closed it when its branch was renamed.
rectis compared with the viewport size of a screen observation (session.observe), so web, iOS, and Android don't need an engine change. The screen is observed only when the node is shown and has a box (sample()inpackages/e2e/src/expect/async.ts).boxShareInViewportinpackages/core/src/internal/geometry.ts). The check passes when the share is above 0 and at leastratio, with Playwright's1e-9tolerance.reference/expect.mdxand the Playwright guide. Playwright uses anIntersectionObserver, so a part clipped off by a scrolling container counts as outside. Here, the box is checked against the viewport only, so a pager page inside a narroweroverflowcontainer can still read as in view. When a box is already cut to its container (on the web for iframes, on Android for list rows), the cut-off part doesn't count.reference/expect.mdxhas an entry and the type.boundingBox()workaround is removed from the Playwright guide.ratio.skills/e2eand accepted byrun_code.Error codes the new API can throw. None of them is new, so
reference/errors.mdxdoesn't change:INVALID_ARGUMENTratioisn't a number from 0 to 1 (null,NaN, a string), or an option isn't supported. It's thrown before any readASSERTION_FAILEDhidden,no box, orno nodeLOCATOR_AMBIGUOUSENGINE_FAILURE,OPERATION_TIMEOUT, ...)Verified
Ran it locally: yes, on Chromium. Firefox: no, see below.
Testbed with the built CLI, a scratch test on
/scroll(not committed):node node_modules/e2e/dist/cli/bin.js run tests/zz-in-viewport.e2e.ts --video. Before a wheel scroll,toBeInViewport({ ratio: 1 })passes on the heading. After the scroll:toBeVisible()still passes on the heading.not.toBeInViewport()passes on the heading.The deliberate failure prints:
packages/e2e/tests/integration/web-in-viewport.test.tsruns a suite on the web engine in Chromium. It covers:scrollIntoViewratio: 0.5, fails0.6withobserved: viewport ratio 0.5)packages/e2e/tests/unit/expect-in-viewport.test.tscovers:Firefox: not run. Playwright's Firefox (
firefox-1572) doesn't start on this Mac, even from a barefirefox.launch()outside the runner:Could not find profile foldersandbox_extension_issue_file_to_process ... Operation not permittedThe matcher doesn't have any browser-specific code. On every browser,
rectand the viewport come from the same in-page reader in the web engine.iOS and Android: not run on a device. The matcher doesn't need an engine change. On Android, a list row's bounds are already cut to the list, as a reviewer found in the golden snapshots in
packages/mobile/tests/fixtures/snapshots/android/. That limit is in the docs, but it isn't confirmed on a device.🤖 Generated with Claude Code