Skip to content

Helper Configuration

Philipp Stracker edited this page Aug 13, 2021 · 9 revisions

The only required option is the require value, which is always "codeceptjs-pixelmatchhelper". The other configuration values are optional. Here is a full list of supported items:

helpers: {
    PixelmatchHelper: {
        require:      "codeceptjs-pixelmatchhelper",  // Mandatory and static!
        dirExpected:  "./tests/screenshots/base/",    // Optional but recommended.
        dirDiff:      "./tests/screenshots/diff/",    // Optional but recommended.
        dirActual:    "./tests/output/",              // Optional.
        diffPrefix:   "Diff_",                        // Optional.
        tolerance:    2.5,                            // Optional.
        threshold:    0.05,                           // Optional.
        dumpIntermediateImage: true,                  // Optional.
        captureActual: true,                          // Optional.
        captureExpected: true                         // Optional.
    }
}

dirExpected

Folder that contains the expected base images. Those base images are usually generated once from a stable website/app and are rarely updated.

Defaults to "./tests/screenshots/base/"

dirDiff

Folder that receives the diff-images for all comparison where the matching fails. The diff-folder is an output folder; any files in this folder can potentially be overwritten. Only failed tests generate a diff-image.

You can globally disable generation of Diff-images by setting dirDiff to false.

Defaults to "./tests/screenshots/diff/"

dirActual

Folder that holds the actual screenshots that should be tested against an expected base images. The actual screenshots are usually generated fresh for every test.

Defaults to global.output_dir

diffPrefix

You can define a custom prefix for diff-images with this option.

Defaults to "Diff_"

tolerance

This is a default value that can be overwritten for a single comparison using the comparison options.

The default tolerance for all comparisons. The tolerance can be a float value between 0 and 100.

Defaults to 0

threshold

This is a default value that can be overwritten for a single comparison using the comparison options.

The default threshold for all comparisons. The tolerance can be a float value between 0 and 1.

Defaults to 0.1

dumpIntermediateImage

This is a default value that can be overwritten for a single comparison using the comparison options.

Whether to save the intermediate images to the global output folder, after applying the bounds and ignore-boxes.

This is useful for debugging your tests, but not recommended for production usage.

Defaults to false

captureActual

This is a default value that can be overwritten for a single comparison using the comparison options.

Whether to capture a new screenshot and use it as actual image, instead of loading the image from the dirActual folder. This happens before the image comparison.

The new screenshot is saved to the dirActual folder before comparison, and will replace an existing file with the same name!

Possible values: true will always capture the screenshot, false never captures the screenshot, "missing" captures the screenshot if the image file does not exist.

Default is "missing"

captureExpected

This is a default value that can be overwritten for a single comparison using the comparison options.

Whether to update the expected base image with a current screenshot before starting the comparison.

The new screenshot is saved to the dirExpected folder, and will replace an existing file with the same name!

Possible values: true will always capture the screenshot, false never captures the screenshot, "missing" captures the screenshot if the image file does not exist.

Default is "missing"


← Installation | Method: checkVisualDifferences() →