Skip to content

Commit

Permalink
Feature #16 Include Rectangles
Browse files Browse the repository at this point in the history
Implementation of new matching function
  • Loading branch information
burnpiro committed Dec 30, 2018
1 parent ee64d80 commit 9eea1d0
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ const ScreenTestFactory = function(
threshold = 0,
includeAA = false,
ignoreColors = false,
ignoreRectangles = [],
matchingBox = {
ignoreRectangles: [],
includeRectangles: []
},
errorSettings = {
errorColor: {
red: 255,
Expand All @@ -18,6 +21,13 @@ const ScreenTestFactory = function(
errorType: 'flat',
transparency: 0.7
}) {
if(Array.isArray(matchingBox)) {
console.error(`You're using old version of API, please refer to https://github.com/burnpiro/puppeteer-screenshot-tester/releases/tag/1.2.0`);
matchingBox = {
ignoreRectangles: matchingBox,
includeRectangles: []
}
}
resemble.outputSettings(errorSettings);
// get path to called directory
// cannot use __directory because it returns module directory instead of caller
Expand Down Expand Up @@ -55,8 +65,11 @@ const ScreenTestFactory = function(
if (ignoreColors) {
comparisonResult.ignoreColors()
}
if (ignoreRectangles.length > 0) {
comparisonResult.ignoreRectangles(ignoreRectangles)
if (Array.isArray(matchingBox.ignoreRectangles) && matchingBox.ignoreRectangles.length > 0) {
comparisonResult.ignoreRectangles(matchingBox.ignoreRectangles)
}
if (Array.isArray(matchingBox.includeRectangles) && matchingBox.includeRectangles.length > 0) {
comparisonResult.includeRectangles(matchingBox.includeRectangles)
}

// await for a comparison to be completed and return resolved value
Expand Down

0 comments on commit 9eea1d0

Please sign in to comment.