diff options
author | Thomas Steur <thomas.steur@gmail.com> | 2014-06-18 04:04:56 +0400 |
---|---|---|
committer | Thomas Steur <thomas.steur@gmail.com> | 2014-06-18 04:04:56 +0400 |
commit | 69b4a70048ea681bc62bca79abe7c763f2233a60 (patch) | |
tree | 070b876a73f9402664f624e73de74ed4165518f5 /tests/lib/screenshot-testing/support/chai-extras.js | |
parent | 031a2de96a2a3ec3f5f395977ee6c0c822b119b3 (diff) | |
parent | 02ffeeb228f88d6053edf777d094b34c47b086b4 (diff) |
Merge remote-tracking branch 'origin/master' into report_and_dimension_refactoring
Conflicts:
core/Tracker/Settings.php
core/Tracker/Visit.php
plugins/Actions/Widgets.php
plugins/CustomVariables/Widgets.php
plugins/DevicesDetection/DevicesDetection.php
plugins/DevicesDetection/Widgets.php
plugins/Events/Widgets.php
plugins/Provider/Widgets.php
plugins/UserCountry/Widgets.php
plugins/UserSettings/Widgets.php
plugins/VisitTime/Widgets.php
plugins/VisitorInterest/Widgets.php
Diffstat (limited to 'tests/lib/screenshot-testing/support/chai-extras.js')
-rw-r--r-- | tests/lib/screenshot-testing/support/chai-extras.js | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/tests/lib/screenshot-testing/support/chai-extras.js b/tests/lib/screenshot-testing/support/chai-extras.js index 1253f8fb13..f2c7f0544d 100644 --- a/tests/lib/screenshot-testing/support/chai-extras.js +++ b/tests/lib/screenshot-testing/support/chai-extras.js @@ -108,6 +108,14 @@ function capture(screenName, compareAgainst, selector, pageSetupFn, done) { done(error); }; + var pass = function () { + if (options['print-logs']) { + console.log(getPageLogsString(pageRenderer.pageLogs, " ")); + } + + done(); + }; + if (!testInfo.processed) { fail("Failed to generate screenshot to " + screenshotFileName + "."); return; @@ -121,16 +129,20 @@ function capture(screenName, compareAgainst, selector, pageSetupFn, done) { var expected = fs.read(expectedScreenshotPath), processed = fs.read(processedScreenshotPath); - if (expected != processed) { - fail("Processed screenshot does not match expected for " + screenshotFileName + "."); + if (processed == expected) { + pass(); return; } - if (options['print-logs']) { - console.log(getPageLogsString(pageRenderer.pageLogs, " ")); - } + // if the files are not exact, perform a diff to check if they are truly different + resemble("file://" + processedScreenshotPath).compareTo("file://" + expectedScreenshotPath).onComplete(function(data) { + if (data.misMatchPercentage != 0) { + fail("Processed screenshot does not match expected for " + screenshotFileName + "."); + return; + } - done(); + pass(); + }); }, selector); } catch (ex) { var err = new Error(ex.message); |