From 83326cd494e81ead428caabf1b797632507fded0 Mon Sep 17 00:00:00 2001 From: muhammad khan Date: Fri, 17 Feb 2023 17:52:20 +0000 Subject: [PATCH 1/2] added image threshold tolerance --- lib/matchers.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/matchers.ts b/lib/matchers.ts index 944aaf60..cc789961 100644 --- a/lib/matchers.ts +++ b/lib/matchers.ts @@ -14,7 +14,7 @@ declare global { } } -export const toMatchBaseline = (latestPath: string) => { +export const toMatchBaseline = (latestPath: string, threshold?: number) => { const platform = process.env.OWL_PLATFORM as Platform; const screenshotsDir = path.join(path.dirname(latestPath), '..', '..'); const baselinePath = path.join( @@ -56,7 +56,8 @@ export const toMatchBaseline = (latestPath: string) => { latestImage.data, diffImage.data, baselineImage.width, - baselineImage.height + baselineImage.height, + { threshold } ); if (diffPixelsCount === 0) { From 42b54c1c228af501ff7453d717f7c6c712f5f988 Mon Sep 17 00:00:00 2001 From: muhammad khan Date: Mon, 20 Feb 2023 12:19:04 +0000 Subject: [PATCH 2/2] rename to options --- lib/matchers.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/matchers.ts b/lib/matchers.ts index cc789961..5edaf551 100644 --- a/lib/matchers.ts +++ b/lib/matchers.ts @@ -14,7 +14,10 @@ declare global { } } -export const toMatchBaseline = (latestPath: string, threshold?: number) => { +export const toMatchBaseline = ( + latestPath: string, + options?: { threshold?: number } +) => { const platform = process.env.OWL_PLATFORM as Platform; const screenshotsDir = path.join(path.dirname(latestPath), '..', '..'); const baselinePath = path.join( @@ -57,7 +60,7 @@ export const toMatchBaseline = (latestPath: string, threshold?: number) => { diffImage.data, baselineImage.width, baselineImage.height, - { threshold } + { threshold: options?.threshold } ); if (diffPixelsCount === 0) {