diff --git a/src/config.js b/src/config.js index 65f6a1e3..b613f66a 100644 --- a/src/config.js +++ b/src/config.js @@ -20,6 +20,7 @@ const DEFAULT_SCREENSHOT_CONFIG = Object.freeze({ const DEFAULT_IMAGE_CONFIG = Object.freeze({ createDiffImage: true, resizeDevicePixelRatio: true, + pixelmatchThreshold: 0.01, threshold: 0.1, thresholdType: 'percent', // can be 'percent' or 'pixel' }); diff --git a/src/utils/tasks/imageSnapshots.js b/src/utils/tasks/imageSnapshots.js index d1d5dfa9..984ff344 100644 --- a/src/utils/tasks/imageSnapshots.js +++ b/src/utils/tasks/imageSnapshots.js @@ -106,7 +106,7 @@ function compareImages(expected, actual, diffFilename, config) { const imageConfig = merge({}, DEFAULT_IMAGE_CONFIG, config); const pixelmatchConfig = { - threshold: 0.01, + threshold: imageConfig.pixelmatchThreshold, }; const imageWidth = actual.image.width; diff --git a/types/index.d.ts b/types/index.d.ts index 8c92b89e..bd865879 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -20,6 +20,7 @@ declare namespace Cypress { toMatchImageSnapshot(options?: Partial<{ imageConfig: Partial<{ createDiffImage: boolean, + pixelmatchThreshold: number, threshold: number, thresholdType: "percent" | "pixels", resizeDevicePixelRatio: boolean