compares two sets of images.
provide it folders, refDir
& runDir
, where both folders contain png
files. images are compared by basename. that is, /refDir/test-image.png
would be compared to /runDir/test-image.png
.
the comparisons use blink-diff to compare images.
var ImageSetDiffer = require('webjerk-image-set-diff')
var refDir = '/reference-images'
var runDir = '/test-run-images'
var idr = new ImageSetDiffer({
refDir,
runDir,
report: true, // generate a report?
allowNewImages: true, // allow new images into the ref set
approveChanges: false // appove run images as new refs. migrate run/ images to ref/
})
var diffs = await idr.run() // blinkDifference objects
when mismatches are detected, ImageSetDiffer::run
throws.
-
err.code
will equal'EIMAGEDIFFS'
-
err.differences
will have an array of blink difference data attached to the failing image
console.log(err.differences)
// => [{ basename, blinkDiff, message }, ..., for, each, image, mismatch]
some settings may be set from the env:
-
WEBJERK_ALLOW_NEW_IMAGES
, set to allow new images not found in the reference set -
WEBJERK_APPROVE_CHANGES
, set to approve all image changes