-
Notifications
You must be signed in to change notification settings - Fork 4
Comparison Results
Both methods checkVisualDifferences()
and getVisualDifferences()
return a Promise that resolves to the following "comparison results" object:
(boolean) - Whether the differences are within the allowed tolerance level.
(string) - Filename of the diff-file.
(int) - Absolute count of different pixels.
(int) - Absolute count of all pixels inside the image.
(int) - Absolute count of pixels, that are not ignored and inside the bounds-area.
(float) - Relative difference between both images. The percentage is calculated from the diffPixels
and relevantPixels
values.
(string) - Stores the variation-suffix of the match. Only used, when multiple base images are present for the comparison.
(Array of Comparison Results) - Contains details about all variations. Only used, when multiple base images are present for the comparison.
const res = await I.getVisualDifferences("dashboard");
console.log('Match: ', res.match);
console.log('Diff-Image: ', res.diffImage);
console.log('Diff Pixels: ', res.diffPixels);
console.log('Total Pixels: ', res.totalPixels);
console.log('Relevant Pixels: ', res.relevantPixels);
console.log('Difference: ', res.difference);
When running a test using multiple base images, then the comparison result object contains details about the best match. That is the match with the least amount of different pixels.
You can still analyze all comparison results by inspecting the variations
property of the result object.
Sample
const res = await I.getVisualDifferences("dashboard");
console.log(`Variations tested: ${res.variations.length}`);
for (let i = 0; i < res.variations.length; i++) {
const v = res.variations[i];
console.log(`Variation ${i} has suffix "${v.variation} and difference of ${v.diffPixels} Pixels`);
}
Manual
Methods
Data Structures
Appendix
Development