From 2fa4bc9810aeab1583e6bf1b56fe7054e5d873dd Mon Sep 17 00:00:00 2001 From: Ryan David Sheasby Date: Thu, 30 May 2019 12:57:01 +0200 Subject: [PATCH] Add ability to change looks-same threshold The reason I want to add this is to get around some issues I (and likely others) am having with image antialiasing setting off false positives. Running the exact same protractor test 2 times in a row can get different results because of slight rendering differences. Allowing people to tune the threshold would be useful. --- screenshot_helper/screenshot_helper.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/screenshot_helper/screenshot_helper.ts b/screenshot_helper/screenshot_helper.ts index 5bf91f1..8c4fd5e 100644 --- a/screenshot_helper/screenshot_helper.ts +++ b/screenshot_helper/screenshot_helper.ts @@ -32,7 +32,7 @@ let looksSame: LooksSame = require('looks-same'); * saved. */ -export async function compareScreenshot(data, golden, outputFolder = undefined): Promise { +export async function compareScreenshot(data, golden, outputFolder = undefined, compareTolerance = 2.5): Promise { return new Promise(async (resolve, reject) => { const tempFolder = createTempFolder(); const screenshotPath = await writeScreenshot(tempFolder, data); @@ -46,7 +46,7 @@ export async function compareScreenshot(data, golden, outputFolder = undefined): const goldenName = path.basename(golden); looksSame(screenshotPath, golden, { strict: false, - tolerance: 2.5, + tolerance: compareThreshold, }, async (error, equal) => { if (error) { reject("There has been an error. Error: " + error);