Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to use resemble`s ignoreAntialiasing() #629

Merged
merged 1 commit into from
Jan 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ clickSelector // Click the specified DOM element prior to screen shot
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)
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...
selectorExpansion // See Targeting elements in the next section for more info...
misMatchThreshold // Around of change before a test is marked failed
misMatchThreshold // Percentage of different pixels allowed to pass test
requireSameDimensions // If set to true -- any change in selector size will trigger a test failure.
```

Expand Down Expand Up @@ -700,7 +700,9 @@ optional parameters

### Modifying output settings of image-diffs

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.
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.)

Instead of calling resemble`s ignoreAntialiasing(), you may set it as a property in the config. (See [example](examples/simpleReactApp/backstop.json))
```json
"resembleOutputOptions": {
"errorColor": {
Expand All @@ -709,7 +711,8 @@ By specifying `resembleOutputOptions` in your backstop.json file you can modify
"blue": 255
},
"errorType": "movement",
"transparency": 0.3
"transparency": 0.3,
"ignoreAntialiasing": true
}
```

Expand Down
10 changes: 8 additions & 2 deletions core/util/compare/compare-resemble.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,17 @@ var resemble = require('node-resemble-js');
module.exports = function (referencePath, testPath, misMatchThreshold, resembleOutputSettings, requireSameDimensions) {
return new Promise(function (resolve, reject) {
resemble.outputSettings(resembleOutputSettings || {});
resemble(referencePath).compareTo(testPath).onComplete(data => {
var comparison = resemble(referencePath).compareTo(testPath);

if (resembleOutputSettings && resembleOutputSettings.ignoreAntialiasing) {
comparison.ignoreAntialiasing();
}

comparison.onComplete(data => {
if ((requireSameDimensions === false || data.isSameDimensions === true) && data.misMatchPercentage <= misMatchThreshold) {
return resolve(data);
}
reject(data)
reject(data);
});
});
};
3 changes: 2 additions & 1 deletion examples/simpleReactApp/assets/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

h1 {
margin-bottom: 20px;
text-shadow: 0 0 1px rgba(120, 120, 120, 19);
}

#geocoding_form {
Expand Down Expand Up @@ -41,7 +42,7 @@ h1 {
line-height: 1.4;
}

.current-location .glyphicon-star,
.current-location .glyphicon-star,
.current-location .glyphicon-star-empty {
display: inline-block;
margin-left: 10px;
Expand Down
5 changes: 4 additions & 1 deletion examples/simpleReactApp/backstop.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
],
"readyEvent": "gmapResponded",
"delay": 100,
"misMatchThreshold" : 1,
"misMatchThreshold" : 0,
"onBeforeScript": "onBefore.js",
"onReadyScript": "onReady.js"
}
Expand All @@ -42,5 +42,8 @@
"casperFlags": [],
"engine": "phantomjs",
"report": ["browser"],
"resembleOutputOptions": {
"ignoreAntialiasing": true
},
"debug": false
}
1 change: 1 addition & 0 deletions examples/simpleReactApp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"private": true,
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dev-backstop-test": "node ../../cli/index.js test",
"watch": "watchify -v -d -t [ reactify --es6 ] main.js -o compiled.js",
"build": "NODE_ENV=production browserify -t [ reactify --es6 ] main.js | uglifyjs > compiled.js && backstop test"
},
Expand Down
3 changes: 3 additions & 0 deletions examples/simpleReactApp/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ then Build...

Then open index.html in your browser.

**Note:** ignore antialiasing is used here.
See backstop.json: `"resembleOutputOptions": {"ignoreAntialiasing": true}`

---

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