Skip to content

fix: respect alwaysSaveActualImage: false for checkScreen methods (#1115)#1116

Open
wswebcreation wants to merge 10 commits intomainfrom
ws/fix-1115
Open

fix: respect alwaysSaveActualImage: false for checkScreen methods (#1115)#1116
wswebcreation wants to merge 10 commits intomainfrom
ws/fix-1115

Conversation

@wswebcreation
Copy link
Member

@wswebcreation wswebcreation commented Feb 6, 2026

Summary

Fixes #1115

When using browser.checkScreen() directly with alwaysSaveActualImage: false, actual images were still being saved when there was any mismatch > 0%, even if the user's assertion considered it acceptable.

Root Cause

The saveAboveTolerance option defaulted to 0 in DEFAULT_COMPARE_OPTIONS. This meant any mismatch > 0% would trigger saving the actual image, regardless of the user's threshold expectation.

The matchers (toMatchScreenSnapshot, etc.) worked correctly because they explicitly pass saveAboveTolerance to the core based on the threshold provided.

The Fix

  • Removed saveAboveTolerance: 0 from DEFAULT_COMPARE_OPTIONS so it remains undefined unless explicitly set
  • Updated executeImageCompare to only save actual images when saveAboveTolerance is explicitly provided

New Behavior

Scenario Result
alwaysSaveActualImage: true Always save actual images
alwaysSaveActualImage: false (no saveAboveTolerance) Never save actual images
alwaysSaveActualImage: false + saveAboveTolerance: X Save when mismatch > X
Matchers (toMatchScreenSnapshot, etc.) Work correctly (they set saveAboveTolerance internally)

Test plan

  • Added integration test in desktop.spec.ts to verify actual images are not saved when alwaysSaveActualImage: false
  • Added unit tests for the new behavior
  • Updated snapshots
  • All existing tests pass

@changeset-bot
Copy link

changeset-bot bot commented Feb 6, 2026

🦋 Changeset detected

Latest commit: 8ad8d62

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@wdio/image-comparison-core Patch
@wdio/visual-service Patch

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

wswebcreation and others added 9 commits February 6, 2026 07:08
This fixes the TypeScript error that occurred after removing
saveAboveTolerance from DEFAULT_COMPARE_OPTIONS.

Co-authored-by: Cursor <cursoragent@cursor.com>
The test now:
1. Saves a baseline with enableLayoutTesting: true (no visible text)
2. Checks against it with enableLayoutTesting: false (text visible)
3. Verifies there's a mismatch but within threshold
4. Verifies actual image was NOT saved (the fix)

Co-authored-by: Cursor <cursoragent@cursor.com>
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.

alwaysSaveActualImage: false does not respect browser.checkElement/Screen/FullPageScreen

1 participant