Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ build
# folders
.tmp
.pixelmatch-tmp/
/*/*-pixelmatch/
/__snapshots__/
.idea/
localBaseline/
Expand Down
2 changes: 1 addition & 1 deletion packages/image-comparison-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"watch:tsc": "pnpm run build:tsc -w"
},
"dependencies": {
"jimp": "^1.6.1",
"fast-png": "^8.0.0",
"pixelmatch": "^7.2.0",
"@wdio/logger": "^9.18.0",
"@wdio/types": "^9.27.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ exports[`BaseClass > initializes default options correctly 1`] = `
"blockOutSideBar": true,
"blockOutStatusBar": true,
"blockOutToolBar": true,
"compareEngine": "resemble",
"createJsonReportFiles": false,
"diffPixelBoundingBoxProximity": 5,
"ignoreAlpha": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ exports[`options > defaultOptions > should return the default options when no op
"blockOutSideBar": true,
"blockOutStatusBar": true,
"blockOutToolBar": true,
"compareEngine": "resemble",
"createJsonReportFiles": false,
"diffPixelBoundingBoxProximity": 5,
"ignoreAlpha": false,
Expand Down Expand Up @@ -144,7 +143,6 @@ exports[`options > defaultOptions > should return the provided options when opti
"blockOutSideBar": true,
"blockOutStatusBar": true,
"blockOutToolBar": true,
"compareEngine": "resemble",
"createJsonReportFiles": true,
"diffPixelBoundingBoxProximity": 123,
"ignoreAlpha": true,
Expand Down
1 change: 0 additions & 1 deletion packages/image-comparison-core/src/helpers/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export const DEFAULT_COMPARE_OPTIONS = {
blockOutSideBar: true,
blockOutStatusBar: true,
blockOutToolBar: true,
compareEngine: 'resemble' as const,
createJsonReportFiles: false,
diffPixelBoundingBoxProximity: 5,
ignoreAlpha: false,
Expand Down
16 changes: 0 additions & 16 deletions packages/image-comparison-core/src/helpers/options.interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,15 +205,6 @@ export interface ClassOptions {
*/
scaleImagesToSameSize?: boolean;

/**
* The image comparison engine to use.
* 'pixelmatch' is a beta alternative that uses the YIQ color space and is
* more robust against font rendering noise and anti-aliasing differences.
* Prefer setting this inside compareOptions.
* @default 'resemble'
*/
compareEngine?: 'resemble' | 'pixelmatch';

/**
* Options object passed to the underlying image comparison engine.
*/
Expand Down Expand Up @@ -491,12 +482,5 @@ export interface CompareOptions {
* Scale images to the same size before comparing them.
*/
scaleImagesToSameSize: boolean;
/**
* The image comparison engine to use.
* 'pixelmatch' is a beta alternative that uses the YIQ color space and is
* more robust against font rendering noise and anti-aliasing differences.
* @default 'resemble'
*/
compareEngine?: 'resemble' | 'pixelmatch';
}

17 changes: 3 additions & 14 deletions packages/image-comparison-core/src/helpers/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type { MethodImageCompareCompareOptions, ScreenMethodImageCompareCompareO
import type { BeforeScreenshotOptions, BeforeScreenshotResult } from './beforeScreenshot.interfaces.js'
import type { AfterScreenshotOptions } from './afterScreenshot.interfaces.js'
import type { InstanceData } from '../methods/instanceData.interfaces.js'
import type { ComparisonIgnoreOption } from '../resemble/compare.interfaces.js'
import type { ComparisonIgnoreOption } from '../pixelmatch/compare.interfaces.js'
import {
logAllDeprecatedCompareOptions,
isStorybook,
Expand Down Expand Up @@ -58,17 +58,9 @@ export function defaultOptions(options: ClassOptions): DefaultOptions {
waitForFontsLoaded: options.waitForFontsLoaded ?? true,
alwaysSaveActualImage: options.alwaysSaveActualImage ?? true,

/**
* Compare options (merged sequentially):
* 1. Default options (fallback)
* 2. Root compareOptions (deprecated but supported)
* 3. Root-level compareEngine shorthand (convenience alias)
* 4. User-provided compareOptions (highest precedence)
*/
compareOptions: {
...DEFAULT_COMPARE_OPTIONS,
...logAllDeprecatedCompareOptions(options),
...(options.compareEngine ? { compareEngine: options.compareEngine } : {}),
...options.compareOptions,
},

Expand Down Expand Up @@ -272,13 +264,10 @@ export function buildAfterScreenshotOptions({
return afterOptions
}

/**
* Prepare ignore options for resemble.js comparison
*/
export function prepareIgnoreOptions(imageCompareOptions: MethodImageCompareCompareOptions): ComparisonIgnoreOption[] {
const resembleIgnoreDefaults: ComparisonIgnoreOption[] = ['alpha', 'antialiasing', 'colors', 'less', 'nothing']
const ignoreDefaults: ComparisonIgnoreOption[] = ['alpha', 'antialiasing', 'colors', 'less', 'nothing']

return resembleIgnoreDefaults.filter((option) =>
return ignoreDefaults.filter((option) =>
Object.keys(imageCompareOptions).find(
(key: keyof typeof imageCompareOptions) => key.toLowerCase().includes(option) && imageCompareOptions[key],
),
Expand Down
Loading
Loading