@wdio/image-comparison-core 1.1.1 → 1.1.2
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
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @wdio/image-comparison-core
|
|
2
2
|
|
|
3
|
+
## 1.1.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 0a2b6d0: ## #1111 Respect saveAboveTolerance when deciding to save actual images when alwaysSaveActualImage is false.
|
|
8
|
+
|
|
9
|
+
When `alwaysSaveActualImage` is `false`, the actual image is no longer written to disk if the mismatch is below the configured tolerance, avoiding extra actuals when the comparison still passes.
|
|
10
|
+
|
|
11
|
+
# Committers: 1
|
|
12
|
+
|
|
13
|
+
- Wim Selles ([@wswebcreation](https://github.com/wswebcreation))
|
|
14
|
+
|
|
3
15
|
## 1.1.1
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -646,6 +646,72 @@ describe('executeImageCompare', () => {
|
|
|
646
646
|
});
|
|
647
647
|
expect(fsPromises.writeFile).toHaveBeenCalledWith('/mock/actual/test.png', Buffer.from(base64Image, 'base64'));
|
|
648
648
|
});
|
|
649
|
+
it('should not save base64 actual when diff is below saveAboveTolerance', async () => {
|
|
650
|
+
const base64Image = Buffer.from('base64-image').toString('base64');
|
|
651
|
+
const optionsWithTolerance = {
|
|
652
|
+
...mockOptions,
|
|
653
|
+
folderOptions: {
|
|
654
|
+
...mockOptions.folderOptions,
|
|
655
|
+
alwaysSaveActualImage: false,
|
|
656
|
+
},
|
|
657
|
+
compareOptions: {
|
|
658
|
+
...mockOptions.compareOptions,
|
|
659
|
+
wic: {
|
|
660
|
+
...mockOptions.compareOptions.wic,
|
|
661
|
+
saveAboveTolerance: 0.1,
|
|
662
|
+
},
|
|
663
|
+
},
|
|
664
|
+
};
|
|
665
|
+
vi.mocked(compareImages.default).mockResolvedValue({
|
|
666
|
+
rawMisMatchPercentage: 0.05,
|
|
667
|
+
misMatchPercentage: 0.05,
|
|
668
|
+
getBuffer: vi.fn().mockResolvedValue(Buffer.from('diff-image-data')),
|
|
669
|
+
diffBounds: { left: 0, top: 0, right: 0, bottom: 0 },
|
|
670
|
+
analysisTime: 10,
|
|
671
|
+
diffPixels: []
|
|
672
|
+
});
|
|
673
|
+
await executeImageCompare({
|
|
674
|
+
isViewPortScreenshot: true,
|
|
675
|
+
isNativeContext: false,
|
|
676
|
+
options: optionsWithTolerance,
|
|
677
|
+
testContext: mockTestContext,
|
|
678
|
+
actualBase64Image: base64Image,
|
|
679
|
+
});
|
|
680
|
+
expect(fsPromises.writeFile).not.toHaveBeenCalled();
|
|
681
|
+
});
|
|
682
|
+
it('should save base64 actual when diff exceeds saveAboveTolerance', async () => {
|
|
683
|
+
const base64Image = Buffer.from('base64-image').toString('base64');
|
|
684
|
+
const optionsWithTolerance = {
|
|
685
|
+
...mockOptions,
|
|
686
|
+
folderOptions: {
|
|
687
|
+
...mockOptions.folderOptions,
|
|
688
|
+
alwaysSaveActualImage: false,
|
|
689
|
+
},
|
|
690
|
+
compareOptions: {
|
|
691
|
+
...mockOptions.compareOptions,
|
|
692
|
+
wic: {
|
|
693
|
+
...mockOptions.compareOptions.wic,
|
|
694
|
+
saveAboveTolerance: 0.1,
|
|
695
|
+
},
|
|
696
|
+
},
|
|
697
|
+
};
|
|
698
|
+
vi.mocked(compareImages.default).mockResolvedValue({
|
|
699
|
+
rawMisMatchPercentage: 0.2,
|
|
700
|
+
misMatchPercentage: 0.2,
|
|
701
|
+
getBuffer: vi.fn().mockResolvedValue(Buffer.from('diff-image-data')),
|
|
702
|
+
diffBounds: { left: 0, top: 0, right: 0, bottom: 0 },
|
|
703
|
+
analysisTime: 10,
|
|
704
|
+
diffPixels: []
|
|
705
|
+
});
|
|
706
|
+
await executeImageCompare({
|
|
707
|
+
isViewPortScreenshot: true,
|
|
708
|
+
isNativeContext: false,
|
|
709
|
+
options: optionsWithTolerance,
|
|
710
|
+
testContext: mockTestContext,
|
|
711
|
+
actualBase64Image: base64Image,
|
|
712
|
+
});
|
|
713
|
+
expect(fsPromises.writeFile).toHaveBeenCalledWith('/mock/actual/test.png', Buffer.from(base64Image, 'base64'));
|
|
714
|
+
});
|
|
649
715
|
it('should update baseline using base64 when visual baseline is updated', async () => {
|
|
650
716
|
const base64Image = Buffer.from('base64-image').toString('base64');
|
|
651
717
|
vi.mocked(utils.updateVisualBaseline).mockReturnValueOnce(true);
|
package/dist/methods/images.js
CHANGED
|
@@ -316,7 +316,7 @@ export async function executeImageCompare({ isViewPortScreenshot, isNativeContex
|
|
|
316
316
|
const { diffBoundingBoxes, storeDiffs } = await generateAndSaveDiff(data, imageCompareOptions, ignoredBoxes, diffFilePath, rawMisMatchPercentage);
|
|
317
317
|
// 6a. Save actual image on failure if alwaysSaveActualImage is false
|
|
318
318
|
const saveAboveTolerance = imageCompareOptions.saveAboveTolerance ?? 0;
|
|
319
|
-
const hasFailure = rawMisMatchPercentage >
|
|
319
|
+
const hasFailure = rawMisMatchPercentage > saveAboveTolerance;
|
|
320
320
|
if (useBase64Image && hasFailure && actualBase64Image) {
|
|
321
321
|
// Save the actual image only when comparison fails
|
|
322
322
|
await saveBase64Image(actualBase64Image, actualFilePath);
|
package/package.json
CHANGED