From f4d3ec946547d648d1ec8ea9ccf9369540255adf Mon Sep 17 00:00:00 2001 From: Jakub Freisler Date: Sun, 26 Mar 2023 17:00:02 +0200 Subject: [PATCH] fix: treat maxDiffThreshold 0 as valid value Signed-off-by: Jakub Freisler --- src/commands.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/commands.ts b/src/commands.ts index 010b4373..89bc832c 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -75,6 +75,11 @@ const getImagesDir = (options: Cypress.MatchImageOptions) => { export const getConfig = (options: Cypress.MatchImageOptions) => { const imagesDir = getImagesDir(options); + const maxDiffThreshold = + options.maxDiffThreshold ?? + (Cypress.env("pluginVisualRegressionMaxDiffThreshold") as + | number + | undefined); return { scaleFactor: @@ -94,11 +99,7 @@ export const getConfig = (options: Cypress.MatchImageOptions) => { (Cypress.env("pluginVisualRegressionImagesPath") as string | undefined) || "{spec_path}/__image_snapshots__", maxDiffThreshold: - options.maxDiffThreshold || - (Cypress.env("pluginVisualRegressionMaxDiffThreshold") as - | number - | undefined) || - 0.01, + typeof maxDiffThreshold === "number" ? maxDiffThreshold : 0.01, diffConfig: options.diffConfig || (Cypress.env("pluginVisualRegressionDiffConfig") as