Skip to content

getVisualDifferences

Philipp Stracker edited this page Aug 12, 2021 · 4 revisions
getVisualDifferences(imageName[, options])

Compares the specified current image with an expected base image. Returns a Promise that resolves to an object with comparison results, but does not run any assertions. This method can be used, if you want to only inspect the differences between images.

For the test, there must be an image with the specified name inside the dirActual folder (usually output/) and dirExpected folder (usually screenshots/base/). Both images can be generated using the takeScreenshot() method.

Tip: The method signature and comparison behavior is identical to checkVisualDifferences

Parameters

imageName

Name of an existing image. The .png extension is optional. An image with that filename must exist inside the dirActual folder, and the dirExpected folder.

options

Optional. Custom comparison options for this check. If no options are defined, the defaults from the helper configuration are used.

Comparison Options.

Returns

Always returns a Promise that resolves to the comparison results.

Comparison Results

Samples

const res = await I.getVisualDifferences("dashboard");

if (res.match) {
    // Identical enough. Difference is 0%
    I.say(`Identical enough. Difference is ${res.difference}%`);
} else {
    // Too different. Difference is 1.2345% - review Diff_dashboard.png for details!
    I.say(`Too different. Difference is ${res.difference}% - review ${res.diffImage} for details!`);
}

← Method: checkVisualDifferences() | Method: takeScreenshot() →