Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorThomas Steur <thomas.steur@googlemail.com>2014-05-28 01:36:56 +0400
committerThomas Steur <thomas.steur@googlemail.com>2014-05-28 01:36:56 +0400
commit8ad283ef152e6b125f0685c641e11d45967e472f (patch)
treef0b70456118e3b699201418ce3629ca6593774e6 /tests
parentb2dc389d4ce722cb499b87f2f607a68342a62e48 (diff)
added possibility to compare against a previously captured screenshot if using selector
Diffstat (limited to 'tests')
-rw-r--r--tests/README.screenshots.md9
-rw-r--r--tests/lib/screenshot-testing/support/chai-extras.js27
2 files changed, 28 insertions, 8 deletions
diff --git a/tests/README.screenshots.md b/tests/README.screenshots.md
index b0189fe343..39648b1435 100644
--- a/tests/README.screenshots.md
+++ b/tests/README.screenshots.md
@@ -143,7 +143,14 @@ If you want to compare only parts (all content within an element / selector) of
page.load(url);
}, done);
});
-
+
+If you want to compare a screenshot against an already existing expected screenshot and capture a selector you can do the following:
+
+ it("should load correctly", function (done) {
+ expect.screenshot("screenshot_name").to.be.captureSelector("processed_screenshot_name", "#content", function (page) {
+ page.load(url);
+ }, done);
+ });
### Manipulating Pages Before Capture
diff --git a/tests/lib/screenshot-testing/support/chai-extras.js b/tests/lib/screenshot-testing/support/chai-extras.js
index 1a7da4a7c6..72112cad1b 100644
--- a/tests/lib/screenshot-testing/support/chai-extras.js
+++ b/tests/lib/screenshot-testing/support/chai-extras.js
@@ -140,22 +140,35 @@ function capture(screenName, compareAgainst, selector, pageSetupFn, done) {
}
}
-chai.Assertion.addChainableMethod('captureSelector', function (selector, pageSetupFn, done) {
- var screenName = this.__flags['object'];
+chai.Assertion.addChainableMethod('captureSelector', function () {
+ var compareAgainst = this.__flags['object'];
+
+ if (arguments.length == 3) {
+ var screenName = compareAgainst,
+ selector = arguments[0],
+ pageSetupFn = arguments[1],
+ done = arguments[2];
+ } else {
+ var screenName = app.runner.suite.title + "_" + arguments[0],
+ selector = arguments[1],
+ pageSetupFn = arguments[2],
+ done = arguments[3];
+ }
- capture(screenName, screenName, selector, pageSetupFn, done);
+ capture(screenName, compareAgainst, selector, pageSetupFn, done);
});
chai.Assertion.addChainableMethod('capture', function () {
var compareAgainst = this.__flags['object'];
+
if (arguments.length == 2) {
- var screenName = compareAgainst,
+ var screenName = compareAgainst,
pageSetupFn = arguments[0],
- done = arguments[1];
+ done = arguments[1];
} else {
- var screenName = app.runner.suite.title + "_" + arguments[0],
+ var screenName = app.runner.suite.title + "_" + arguments[0],
pageSetupFn = arguments[1],
- done = arguments[2];
+ done = arguments[2];
}
capture(screenName, compareAgainst, null, pageSetupFn, done);