@wdio/image-comparison-core 2.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/dist/base.interfaces.d.ts +2 -2
- package/dist/helpers/constants.js +1 -1
- package/dist/helpers/options.interfaces.d.ts +4 -2
- package/dist/helpers/options.interfaces.d.ts.map +1 -1
- package/dist/helpers/options.test.js +16 -1
- package/dist/methods/images.executeImageCompare.test.js +21 -0
- package/dist/pixelmatch/compareImages.d.ts.map +1 -1
- package/dist/pixelmatch/compareImages.js +14 -9
- package/dist/pixelmatch/compareImages.test.js +11 -6
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# @wdio/image-comparison-core
|
|
2
2
|
|
|
3
|
+
## 2.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 8cbb294: fix: wire ignoreAntialiasing to pixelmatch AA forgiveness toggle
|
|
8
|
+
|
|
9
|
+
In v10 the pixelmatch engine always ran with anti-aliasing forgiveness enabled, even when `ignoreAntialiasing` was `false`. The option had no effect on comparison behaviour.
|
|
10
|
+
|
|
11
|
+
**What changed**
|
|
12
|
+
|
|
13
|
+
- `ignoreAntialiasing` now toggles pixelmatch's AA handling: `true` forgives anti-aliased pixels, `false` counts them as mismatches.
|
|
14
|
+
- The default is now `ignoreAntialiasing: true`, matching the forgiving pixelmatch behaviour users already get in v10.
|
|
15
|
+
- `ignoreLess` and `ignoreNothing` keep their own threshold behaviour; AA forgiveness is controlled independently via `ignoreAntialiasing`.
|
|
16
|
+
|
|
17
|
+
**Migration**
|
|
18
|
+
|
|
19
|
+
- No action needed if you rely on the current forgiving defaults, comparison behaviour stays the same.
|
|
20
|
+
- If you explicitly set `ignoreAntialiasing: true` today, that remains redundant but harmless.
|
|
21
|
+
- Set `ignoreAntialiasing: false` when you need strict comparison where anti-aliased pixels count as differences.
|
|
22
|
+
|
|
23
|
+
### Committers: 1
|
|
24
|
+
|
|
25
|
+
- Wim Selles ([@wswebcreation](https://github.com/wswebcreation))
|
|
26
|
+
|
|
3
27
|
## 2.0.0
|
|
4
28
|
|
|
5
29
|
### Major Changes
|
|
@@ -90,8 +90,8 @@ export interface BaseImageCompareOptions {
|
|
|
90
90
|
*/
|
|
91
91
|
ignoreAlpha?: boolean;
|
|
92
92
|
/**
|
|
93
|
-
* Compare images and
|
|
94
|
-
* @default
|
|
93
|
+
* Compare images and forgive anti-aliasing differences
|
|
94
|
+
* @default true
|
|
95
95
|
*/
|
|
96
96
|
ignoreAntialiasing?: boolean;
|
|
97
97
|
/**
|
|
@@ -120,7 +120,9 @@ export interface ClassOptions {
|
|
|
120
120
|
*/
|
|
121
121
|
ignoreAlpha?: boolean;
|
|
122
122
|
/**
|
|
123
|
-
*
|
|
123
|
+
* Forgive anti-aliasing differences when comparing images.
|
|
124
|
+
* Defaults to `true` so sub-pixel rendering noise is ignored out of the box.
|
|
125
|
+
* Set to `false` for strict pixel comparison where AA pixels count as mismatches.
|
|
124
126
|
*/
|
|
125
127
|
ignoreAntialiasing?: boolean;
|
|
126
128
|
/**
|
|
@@ -347,7 +349,7 @@ export interface CompareOptions {
|
|
|
347
349
|
*/
|
|
348
350
|
ignoreAlpha: boolean;
|
|
349
351
|
/**
|
|
350
|
-
*
|
|
352
|
+
* Forgive anti-aliasing differences when comparing images.
|
|
351
353
|
*/
|
|
352
354
|
ignoreAntialiasing: boolean;
|
|
353
355
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.interfaces.d.ts","sourceRoot":"","sources":["../../src/helpers/options.interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAA;AAEzE,MAAM,WAAW,YAAY;IAKzB;;;OAGG;IACH,uBAAuB,CAAC,EAAE,MAAM,CAAC;IAEjC;;OAEG;IACH,iBAAiB,CAA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IACH,eAAe,EAAE,OAAO,CAAC;IAEzB;;OAEG;IACH,eAAe,EAAE,eAAe,CAAC;IAEjC;;OAEG;IACH,oBAAoB,EAAE,MAAM,CAAC;IAE7B;;OAEG;IACH,kBAAkB,EAAE,OAAO,CAAC;IAE5B;;;OAGG;IACH,qBAAqB,EAAE,OAAO,CAAC;CAClC;AAED,MAAM,WAAW,cAAc;IAC3B;;;OAGG;IACH,eAAe,EAAE,OAAO,CAAC;IAEzB;;;OAGG;IACH,iBAAiB,EAAE,OAAO,CAAC;IAE3B;;;OAGG;IACH,eAAe,EAAE,OAAO,CAAC;IAEzB;;;OAGG;IACH,qBAAqB,EAAE,OAAO,CAAC;IAE/B;;;;;;OAMG;IACH,6BAA6B,EAAE,MAAM,CAAC;IAEtC;;OAEG;IACH,WAAW,EAAE,OAAO,CAAC;IAErB;;OAEG;IACH,kBAAkB,EAAE,OAAO,CAAC;IAE5B;;OAEG;IACH,YAAY,EAAE,OAAO,CAAC;IAEtB;;;OAGG;IACH,UAAU,EAAE,OAAO,CAAC;IAEpB;;;OAGG;IACH,aAAa,EAAE,OAAO,CAAC;IAEvB;;OAEG;IACH,qBAAqB,EAAE,OAAO,CAAC;IAE/B;;OAEG;IACH,oBAAoB,EAAE,OAAO,CAAC;IAE9B;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAE5B;;OAEG;IACH,qBAAqB,EAAE,OAAO,CAAC;CAClC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { defaultOptions, methodCompareOptions, screenMethodCompareOptions, createBeforeScreenshotOptions, buildAfterScreenshotOptions } from './options.js';
|
|
2
|
+
import { defaultOptions, methodCompareOptions, screenMethodCompareOptions, createBeforeScreenshotOptions, buildAfterScreenshotOptions, prepareIgnoreOptions } from './options.js';
|
|
3
3
|
describe('options', () => {
|
|
4
4
|
describe('defaultOptions', () => {
|
|
5
5
|
it('should return the default options when no options are provided', () => {
|
|
@@ -426,4 +426,19 @@ describe('options', () => {
|
|
|
426
426
|
expect(result.platformName).toBe('iOS');
|
|
427
427
|
});
|
|
428
428
|
});
|
|
429
|
+
describe('prepareIgnoreOptions', () => {
|
|
430
|
+
it('includes antialiasing when ignoreAntialiasing is true', () => {
|
|
431
|
+
expect(prepareIgnoreOptions({ ignoreAntialiasing: true })).toEqual(['antialiasing']);
|
|
432
|
+
});
|
|
433
|
+
it('omits antialiasing when ignoreAntialiasing is false', () => {
|
|
434
|
+
expect(prepareIgnoreOptions({ ignoreAntialiasing: false })).toEqual([]);
|
|
435
|
+
});
|
|
436
|
+
it('collects multiple enabled ignore flags', () => {
|
|
437
|
+
expect(prepareIgnoreOptions({
|
|
438
|
+
ignoreAlpha: true,
|
|
439
|
+
ignoreAntialiasing: true,
|
|
440
|
+
ignoreLess: true,
|
|
441
|
+
})).toEqual(['alpha', 'antialiasing', 'less']);
|
|
442
|
+
});
|
|
443
|
+
});
|
|
429
444
|
});
|
|
@@ -806,6 +806,27 @@ describe('executeImageCompare', () => {
|
|
|
806
806
|
}
|
|
807
807
|
});
|
|
808
808
|
});
|
|
809
|
+
it('should pass antialiasing ignore when ignoreAntialiasing is enabled', async () => {
|
|
810
|
+
const optionsWithAntialiasing = {
|
|
811
|
+
...mockOptions,
|
|
812
|
+
compareOptions: {
|
|
813
|
+
...mockOptions.compareOptions,
|
|
814
|
+
method: {
|
|
815
|
+
ignoreAntialiasing: true,
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
};
|
|
819
|
+
await executeImageCompare({
|
|
820
|
+
isViewPortScreenshot: true,
|
|
821
|
+
isNativeContext: false,
|
|
822
|
+
options: optionsWithAntialiasing,
|
|
823
|
+
testContext: mockTestContext
|
|
824
|
+
});
|
|
825
|
+
expect(compareImagesPixelmatch.default).toHaveBeenCalledWith(expect.any(Buffer), expect.any(Buffer), {
|
|
826
|
+
ignore: ['antialiasing'],
|
|
827
|
+
scaleToSameSize: true
|
|
828
|
+
});
|
|
829
|
+
});
|
|
809
830
|
it('should handle ignore options from compareOptions', async () => {
|
|
810
831
|
const optionsWithIgnore = {
|
|
811
832
|
...mockOptions,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compareImages.d.ts","sourceRoot":"","sources":["../../src/pixelmatch/compareImages.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAA0B,MAAM,yBAAyB,CAAA;
|
|
1
|
+
{"version":3,"file":"compareImages.d.ts","sourceRoot":"","sources":["../../src/pixelmatch/compareImages.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAA0B,MAAM,yBAAyB,CAAA;AA4ErG,wBAA8B,aAAa,CACvC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,iBAAiB,GAC3B,OAAO,CAAC,WAAW,CAAC,CA0HtB"}
|
|
@@ -10,15 +10,20 @@ function toPixelmatchOptions(ignoreList) {
|
|
|
10
10
|
if (ignoreList.includes('nothing')) {
|
|
11
11
|
return { threshold: 0, includeAA: true };
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
const forgivesAA = ignoreList.includes('antialiasing');
|
|
14
|
+
const threshold = ignoreList.includes('less')
|
|
15
|
+
? 0.063
|
|
16
|
+
: forgivesAA
|
|
17
|
+
// Resemble's ignoreAntialiasing uses 32/255 per-channel tolerance which
|
|
18
|
+
// corresponds to ~0.13 in YIQ perceptual distance.
|
|
19
|
+
? 0.13
|
|
20
|
+
// Default strict tolerance: 16/255 per channel maps to ~6.3% of max YIQ distance.
|
|
21
|
+
: 0.063;
|
|
22
|
+
return {
|
|
23
|
+
threshold,
|
|
24
|
+
// pixelmatch includeAA=true disables AA forgiveness; false enables it.
|
|
25
|
+
includeAA: !forgivesAA,
|
|
26
|
+
};
|
|
22
27
|
}
|
|
23
28
|
function grayscalePixels(pixels, totalPixels) {
|
|
24
29
|
for (let i = 0; i < totalPixels * 4; i += 4) {
|
|
@@ -137,27 +137,32 @@ describe('pixelmatch adapter - compareImages', () => {
|
|
|
137
137
|
await compareImages(Buffer.from('img1'), Buffer.from('img2'), { ignore: 'nothing' });
|
|
138
138
|
expect(pixelmatchFn).toHaveBeenCalledWith(expect.anything(), expect.anything(), expect.anything(), expect.any(Number), expect.any(Number), expect.objectContaining({ threshold: 0, includeAA: true }));
|
|
139
139
|
});
|
|
140
|
-
it('passes threshold=0.063 and includeAA=
|
|
140
|
+
it('passes threshold=0.063 and includeAA=true for ignore: less', async () => {
|
|
141
141
|
pixelmatchFn.mockImplementation(() => 0);
|
|
142
142
|
await compareImages(Buffer.from('img1'), Buffer.from('img2'), { ignore: 'less' });
|
|
143
|
-
expect(pixelmatchFn).toHaveBeenCalledWith(expect.anything(), expect.anything(), expect.anything(), expect.any(Number), expect.any(Number), expect.objectContaining({ threshold: 0.063, includeAA:
|
|
143
|
+
expect(pixelmatchFn).toHaveBeenCalledWith(expect.anything(), expect.anything(), expect.anything(), expect.any(Number), expect.any(Number), expect.objectContaining({ threshold: 0.063, includeAA: true }));
|
|
144
144
|
});
|
|
145
145
|
it('passes threshold=0.13 and includeAA=false for ignore: antialiasing', async () => {
|
|
146
146
|
pixelmatchFn.mockImplementation(() => 0);
|
|
147
147
|
await compareImages(Buffer.from('img1'), Buffer.from('img2'), { ignore: 'antialiasing' });
|
|
148
148
|
expect(pixelmatchFn).toHaveBeenCalledWith(expect.anything(), expect.anything(), expect.anything(), expect.any(Number), expect.any(Number), expect.objectContaining({ threshold: 0.13, includeAA: false }));
|
|
149
149
|
});
|
|
150
|
-
it('passes threshold=0.
|
|
150
|
+
it('passes threshold=0.063 and includeAA=true when no ignore option is given', async () => {
|
|
151
151
|
pixelmatchFn.mockImplementation(() => 0);
|
|
152
152
|
await compareImages(Buffer.from('img1'), Buffer.from('img2'), {});
|
|
153
|
-
expect(pixelmatchFn).toHaveBeenCalledWith(expect.anything(), expect.anything(), expect.anything(), expect.any(Number), expect.any(Number), expect.objectContaining({ threshold: 0.
|
|
153
|
+
expect(pixelmatchFn).toHaveBeenCalledWith(expect.anything(), expect.anything(), expect.anything(), expect.any(Number), expect.any(Number), expect.objectContaining({ threshold: 0.063, includeAA: true }));
|
|
154
154
|
});
|
|
155
|
-
it('accepts ignore as an array and uses
|
|
155
|
+
it('accepts ignore as an array and uses less threshold with antialiasing forgiveness', async () => {
|
|
156
156
|
pixelmatchFn.mockImplementation(() => 0);
|
|
157
157
|
await compareImages(Buffer.from('img1'), Buffer.from('img2'), {
|
|
158
158
|
ignore: ['antialiasing', 'less']
|
|
159
159
|
});
|
|
160
|
-
expect(pixelmatchFn).toHaveBeenCalledWith(expect.anything(), expect.anything(), expect.anything(), expect.any(Number), expect.any(Number), expect.objectContaining({ threshold: 0.063 }));
|
|
160
|
+
expect(pixelmatchFn).toHaveBeenCalledWith(expect.anything(), expect.anything(), expect.anything(), expect.any(Number), expect.any(Number), expect.objectContaining({ threshold: 0.063, includeAA: false }));
|
|
161
|
+
});
|
|
162
|
+
it('passes threshold=0.063 and includeAA=true for ignore: alpha without antialiasing', async () => {
|
|
163
|
+
pixelmatchFn.mockImplementation(() => 0);
|
|
164
|
+
await compareImages(Buffer.from('img1'), Buffer.from('img2'), { ignore: 'alpha' });
|
|
165
|
+
expect(pixelmatchFn).toHaveBeenCalledWith(expect.anything(), expect.anything(), expect.anything(), expect.any(Number), expect.any(Number), expect.objectContaining({ threshold: 0.063, includeAA: true }));
|
|
161
166
|
});
|
|
162
167
|
});
|
|
163
168
|
describe('pixel transformations', () => {
|
package/package.json
CHANGED