Skip to content

Commit 22eaf76

Browse files
zbyczgarris
authored andcommitted
Add option to use resemble`s ignoreAntialiasing() (#629)
1 parent 5241ad5 commit 22eaf76

File tree

6 files changed

+24
-7
lines changed

6 files changed

+24
-7
lines changed

README.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ clickSelector // Click the specified DOM element prior to screen shot
154154
postInteractionWait // Wait for a selector after interacting with hoverSelector or clickSelector (optionally accepts wait time in ms. Idea for use with a click or hover element transition. available with default onReadyScript)
155155
selectors // Array of selectors to capture. Defaults to document if omitted. Use "viewport" to capture the viewport size. See Targeting elements in the next section for more info...
156156
selectorExpansion // See Targeting elements in the next section for more info...
157-
misMatchThreshold // Around of change before a test is marked failed
157+
misMatchThreshold // Percentage of different pixels allowed to pass test
158158
requireSameDimensions // If set to true -- any change in selector size will trigger a test failure.
159159
```
160160

@@ -700,7 +700,9 @@ optional parameters
700700

701701
### Modifying output settings of image-diffs
702702

703-
By specifying `resembleOutputOptions` in your backstop.json file you can modify the image-diffs transparency, errorcolor, etc. (See [Resemble.js outputSettings](https://github.com/Huddle/Resemble.js) for the full list.
703+
By specifying `resembleOutputOptions` in your backstop.json file you can modify the image-diffs transparency, errorcolor, etc. (See [Resemble.js outputSettings](https://github.com/Huddle/Resemble.js) for the full list.)
704+
705+
Instead of calling resemble`s ignoreAntialiasing(), you may set it as a property in the config. (See [example](examples/simpleReactApp/backstop.json))
704706
```json
705707
"resembleOutputOptions": {
706708
"errorColor": {
@@ -709,7 +711,8 @@ By specifying `resembleOutputOptions` in your backstop.json file you can modify
709711
"blue": 255
710712
},
711713
"errorType": "movement",
712-
"transparency": 0.3
714+
"transparency": 0.3,
715+
"ignoreAntialiasing": true
713716
}
714717
```
715718

core/util/compare/compare-resemble.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,17 @@ var resemble = require('node-resemble-js');
33
module.exports = function (referencePath, testPath, misMatchThreshold, resembleOutputSettings, requireSameDimensions) {
44
return new Promise(function (resolve, reject) {
55
resemble.outputSettings(resembleOutputSettings || {});
6-
resemble(referencePath).compareTo(testPath).onComplete(data => {
6+
var comparison = resemble(referencePath).compareTo(testPath);
7+
8+
if (resembleOutputSettings && resembleOutputSettings.ignoreAntialiasing) {
9+
comparison.ignoreAntialiasing();
10+
}
11+
12+
comparison.onComplete(data => {
713
if ((requireSameDimensions === false || data.isSameDimensions === true) && data.misMatchPercentage <= misMatchThreshold) {
814
return resolve(data);
915
}
10-
reject(data)
16+
reject(data);
1117
});
1218
});
1319
};

examples/simpleReactApp/assets/css/styles.css

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
h1 {
88
margin-bottom: 20px;
9+
text-shadow: 0 0 1px rgba(120, 120, 120, 19);
910
}
1011

1112
#geocoding_form {
@@ -41,7 +42,7 @@ h1 {
4142
line-height: 1.4;
4243
}
4344

44-
.current-location .glyphicon-star,
45+
.current-location .glyphicon-star,
4546
.current-location .glyphicon-star-empty {
4647
display: inline-block;
4748
margin-left: 10px;

examples/simpleReactApp/backstop.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
],
2828
"readyEvent": "gmapResponded",
2929
"delay": 100,
30-
"misMatchThreshold" : 1,
30+
"misMatchThreshold" : 0,
3131
"onBeforeScript": "onBefore.js",
3232
"onReadyScript": "onReady.js"
3333
}
@@ -42,5 +42,8 @@
4242
"casperFlags": [],
4343
"engine": "phantomjs",
4444
"report": ["browser"],
45+
"resembleOutputOptions": {
46+
"ignoreAntialiasing": true
47+
},
4548
"debug": false
4649
}

examples/simpleReactApp/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"private": true,
77
"scripts": {
88
"test": "echo \"Error: no test specified\" && exit 1",
9+
"dev-backstop-test": "node ../../cli/index.js test",
910
"watch": "watchify -v -d -t [ reactify --es6 ] main.js -o compiled.js",
1011
"build": "NODE_ENV=production browserify -t [ reactify --es6 ] main.js | uglifyjs > compiled.js && backstop test"
1112
},

examples/simpleReactApp/readme.md

+3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ then Build...
1111

1212
Then open index.html in your browser.
1313

14+
**Note:** ignore antialiasing is used here.
15+
See backstop.json: `"resembleOutputOptions": {"ignoreAntialiasing": true}`
16+
1417
---
1518

1619
**A BackstopJS test configuration file has already been added to this project.**

0 commit comments

Comments
 (0)