Repository navigation
Conversation
🦋 Changeset detectedLatest commit: 885cb8e The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
plum117
marked this pull request as ready for review
October 10, 2026 14:30
plum117
marked this pull request as draft
October 10, 2026 14:30
Contributor
Author
|
Keeping draft until @wswebcreation approval |
|
plum117
added a commit
to plum117/visual-testing
that referenced
this pull request
Oct 10, 2026
…ges of failed attempts Greptile review of webdriverio#1323: - toMatchElementSnapshot resolves the element once. When the page renders it again, the check command sends the old element id and fails with a stale element error. Within the wait time the matcher now calls an element command, which WebdriverIO uses to find the element again (it updates the element id), and checks again. The new e2e test fails without this with "stale element reference: stale element not found in the current frame". - With alwaysSaveActualImage: false a failed attempt saves the actual and diff images. When a later attempt matches, the images that it did not write again (same write time) are removed. - The e2e fixture no longer changes on a timer after the load: the test starts the change (setBox), so a slow runner can not miss the first state. - New tests: .not with wait through the Jasmine adapter (match, then mismatch), and a multiremote element whose instances match at different attempts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
plum117
force-pushed
the
feat/matcher-wait
branch
from
October 10, 2026 17:34
b7e5b34 to
001e5c4
Compare
…erval) A page or an element is not always in its final state when the test checks it, for example during an animation, and an other condition to wait for is not always available (webdriverio#690). The visual matchers accept `wait` (default 0) and `interval` (default 100) in milliseconds, with the same names and meaning as in the expect-webdriverio matchers. With `wait`, the matcher runs the check again until the result is the expected one: the image matches, or with `.not` it does not match (`isNot` of the matcher context; the Jasmine adapter now gives it too). It always checks at least once, and a failure message tells how often and how long it checked. The 2 options are not passed to the check commands. Each attempt is a full check, and the files and the JSON report of a check have the same names, so the last attempt stays. Without `wait`, a matcher checks once, as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ges of failed attempts Greptile review of webdriverio#1323: - toMatchElementSnapshot resolves the element once. When the page renders it again, the check command sends the old element id and fails with a stale element error. Within the wait time the matcher now calls an element command, which WebdriverIO uses to find the element again (it updates the element id), and checks again. The new e2e test fails without this with "stale element reference: stale element not found in the current frame". - With alwaysSaveActualImage: false a failed attempt saves the actual and diff images. When a later attempt matches, the images that it did not write again (same write time) are removed. - The e2e fixture no longer changes on a timer after the load: the test starts the change (setBox), so a slow runner can not miss the first state. - New tests: .not with wait through the Jasmine adapter (match, then mismatch), and a multiremote element whose instances match at different attempts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…in the page yet
`expect($('#chart')).toMatchElementSnapshot('chart', { wait: 3000 })` failed at once with "Unsupported type: function"
when the chart was not in the page yet: WebdriverIO keeps an element that it did not find without an element id, and
the check commands need that id. With `wait`, the matcher now waits for such an element, at most for the rest of the
wait time, and lets an element command of WebdriverIO set its element id (also for each instance of a multiremote
element). At the end of the wait time, the error of `waitForExist` tells which element is missing. Without `wait`,
nothing changes.
The feature is in 11.1.0, not in 11.0.0: the section in the v11 migration guide is removed, and the changeset tells
that `wait` is opt-in (`0` by default), unlike the other WebdriverIO matchers.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
plum117
marked this pull request as ready for review
October 11, 2026 01:16
plum117
force-pushed
the
feat/matcher-wait
branch
from
October 11, 2026 01:16
001e5c4 to
c035793
Compare
…eep images that a failed attempt did not write - The missing elements of a multiremote element were each waited for with the full rest of the wait time, one after the other, so the matcher could wait longer than `wait`. The instances now share one deadline. - With `alwaysSaveActualImage: false` and a `saveAboveTolerance` above the threshold, a failed attempt does not save an actual image, but the matcher remembered the image that an earlier check had saved under that name and removed it after a later match. Only a file that the failed attempt wrote (written after the attempt started) is removed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
plum117
marked this pull request as draft
October 11, 2026 01:42
This branch has not been deployed
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.
Fixes #690
Why
A page or an element is not always in its final state when the test checks it, for example during an animation, and another condition to wait for is not always available. The visual matchers checked once, so the test failed. The reporter of #690 proposed to run the check again until it matches, as the other WebdriverIO matchers do.
What
toMatchScreenSnapshot(),toMatchFullPageSnapshot(),toMatchElementSnapshot()andtoMatchTabbablePageSnapshot()accept 2 new options, with the same names and meaning as in theexpect-webdriveriomatchers (butwaitis0by default, so it is opt-in):wait(milliseconds, default0): check again until the image matches, or with.notuntil it does not match;interval(milliseconds, default100): the time between 2 checks.wait, a matcher checks once, as before (a failing check does not take longer, and the screenshot is not repeated)..notusesisNotof the matcher context. The Jasmine adapter now givesisNottoo (compareandnegativeCompare).waitandintervalare not passed to the check commands; an invalid value (negative, not a number) throws a clear error.toMatchElementSnapshot(): an element that the page renders again (stale) is found again, and an element that is not in the page yet is waited for, at most for the rest of the wait time (the instances of a multiremote element share that time) (before, it failed at once withUnsupported type: function). At the end of the wait time, the error tells which element is missing.WdioMatcherWaitOptions, added to the options of the 4 matchers. A changeset (minor). The feature ships after 11.0.0, so it is not in the v11 migration guide; the options need a line in the WebdriverIO docs (matchers).Test
tests/matcher.test.ts, with fake timers): one check withoutwait, check again until it matches, stop at the wait time (4 checks at 0, 100, 200 and 300 ms, with the message), options not passed to the check,.not, element and multiremote (2 instances that match at different attempts), a stale element, an element that is not in the page yet (found, not found in time, no wait), the images of failed attempts with real files, full page and tabbable, invalid values;tests/jasmine.test.ts:isNotforcompareandnegativeCompare.tests/fixtures/v10/delayed-change.html):tests/specs/v10.browsingContexts.spec.ts(Mocha: the box gets its final color later, the page renders the box again, the box is not in the page yet) andtests/specs/v10.jasmine.spec.ts(Jasmine, also.notwithwait). Each new e2e test fails without its fix.expectof the test runner (local Chrome, withalwaysSaveActualImageon and off, 16 cells): the 4 matchers with a page or element that changes after 1.5 s; never matches (message and duration); nowait(one check);.notwithwaitin Mocha (a match, then no match; always matches); an asymmetric matcher; a number as the expected result; an element that comes after 1.5 s and one that never comes; an invalid value; an interval longer than the wait. All pass, and after a match no diff (and withalwaysSaveActualImage: falseno actual image) of a failed attempt stays; the JSON report has the result of the last attempt.test.local.chrome.v10,.jasmine,.emulation,test.local.desktop.multi) pass.Known and not changed here: without
wait,toMatchElementSnapshot()on an element that is not in the page fails withUnsupported type: function(also onmain), which does not tell that the element is missing.🤖 Generated with Claude Code