-
Notifications
You must be signed in to change notification settings - Fork 39
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 filename to result #78
Conversation
@zinserjan Added the ability to return file data from the createReport call. Modified tests to account for this. All is green. Let me know what you think. |
package.json
Outdated
@@ -40,6 +40,7 @@ | |||
"lodash": "^4.13.1", | |||
"node-resemble-js": "0.0.5", | |||
"nodeclient-spectre": "^1.0.3", | |||
"phantomjs-prebuilt": "^2.1.16", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this move to a dependency?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. I think this happened when I used yarn to add it. I will switch.
Thanks for catching that, @emilyrohrbough. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your work. I like the idea, but I think this needs to be done in a different way to make this more generic. See my comments.
src/methods/BaseCompare.js
Outdated
@@ -126,8 +126,9 @@ export default class BaseCompare { | |||
return path.join(runtimeConfigPath, `${name}-${suffix}.json`); | |||
} | |||
|
|||
createResultReport(misMatchPercentage, isWithinMisMatchTolerance, isSameDimensions) { | |||
createResultReport(filePaths, misMatchPercentage, isWithinMisMatchTolerance, isSameDimensions) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Chaning the order of arguments is a breaking change for all guys who uses custom compare methods. I would like to avoid this. Moreover this is to inflexibel and only useful for file comparison. I suggest to replace filePaths with an object that wil be assigned via Object.assign to the returned object. Then custom or other compare methods can enhance the report with additional information.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zinserjan Would you rather I made it the last argument, then? That way, if I am remembering my JS correctly, the value would just be null for those who aren't using the functionality?
src/methods/LocalCompare.js
Outdated
@@ -25,6 +25,13 @@ export default class LocalCompare extends BaseCompare { | |||
|
|||
const referenceExists = await fs.exists(referencePath); | |||
|
|||
var fileNames; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use const and assign value directly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
src/methods/LocalCompare.js
Outdated
|
||
fileNames = { | ||
reference: referencePath, | ||
actual: screenshotPath |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- add diff property with value of null to make sure the property is always there
- replace key
actual
withscreenshot
to be consistent with thereferenceName
,screenshotName
anddiffName
option.
…om actual to screenshots for current taken screenshot. Added diff: null to response object.
@zinserjan I looked at the travis build and the failure seems a little funky. Passed on node 6 failed on 8. And it didn't have anything to do with test logic failing. Unfortunately, I can't rerun the tests to see if this was just a fluke failure. |
@zinserjan @emilyrohrbough Can someone rerun this? |
Is this PR still missing something? I believe all points in the review were addressed. @zinserjan @emilyrohrbough |
@silne30 I don't have privs to rerun tests. |
Gotcha. Thanks.
…On Thu, May 3, 2018, 6:08 PM Emily Rohrbough ***@***.***> wrote:
@silne30 <https://github.com/silne30> I don't have privs to rerun tests.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#78 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABXaDpUYtdhHDDo5O5qJ_ImILdDK76v3ks5tu3_kgaJpZM4TSlOs>
.
|
@silne30 just restarted the test. |
src/methods/Spectre.js
Outdated
diff: null | ||
}; | ||
|
||
return this.createResultReport(result.diff, result.pass, true, filenames); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove filesnames from spectre report. This method doesn't use any files.
src/methods/BaseCompare.js
Outdated
@@ -126,12 +126,13 @@ export default class BaseCompare { | |||
return path.join(runtimeConfigPath, `${name}-${suffix}.json`); | |||
} | |||
|
|||
createResultReport(misMatchPercentage, isWithinMisMatchTolerance, isSameDimensions) { | |||
createResultReport(misMatchPercentage, isWithinMisMatchTolerance, isSameDimensions, filePaths) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moreover this is to inflexibel and only useful for file comparison. I suggest to replace filePaths with an object that wil be assigned via Object.assign to the returned object. Then custom or other compare methods can enhance the report with additional information.
This method should be more generic like I already said. What I mean is the following:
createResultReport(misMatchPercentage, isWithinMisMatchTolerance, isSameDimensions, options = {}) {
return {
...options,
misMatchPercentage,
isWithinMisMatchTolerance,
isSameDimensions,
isExactSameImage: misMatchPercentage === 0,
};
}
This allows you to pass everything you want in and just merges this into the report object.
In your case you would call it the following for LocalCompare & SaveScreenshot. All other methods shouldn't be touched.
this.createResultReport(misMatchPercentage, true, isSameDimensions, {
filenames: {
reference: referencePath,
screenshot: screenshotPath,
diff: null,
},
});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. Thanks for that. Had to look into the spread operator in ES6 because I thought ...options was a typo. XD
@zinserjan I think this is more what you were looking for. ^_^ |
@zinserjan Is there anything else this needs? |
@emilyrohrbough @zinserjan I know you all are busy. Just making sure that there is nothing else that I can do on my end for this PR. |
src/methods/LocalCompare.js
Outdated
@@ -25,6 +25,15 @@ export default class LocalCompare extends BaseCompare { | |||
|
|||
const referenceExists = await fs.exists(referencePath); | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: extra line
src/methods/LocalCompare.js
Outdated
@@ -38,23 +47,25 @@ export default class LocalCompare extends BaseCompare { | |||
|
|||
const diffPath = this.getDiffFile(context); | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: extra line
src/methods/LocalCompare.js
Outdated
|
||
return this.createResultReport(misMatchPercentage, false, isSameDimensions); | ||
return this.createResultReport(misMatchPercentage, false, isSameDimensions, options); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: the var name options is misleading here as these are report results not config options.
This looks good to me. Can you explain the reason for the phantom dependency change? |
@emilyrohrbough |
src/methods/BaseCompare.js
Outdated
return { | ||
misMatchPercentage, | ||
isWithinMisMatchTolerance, | ||
isSameDimensions, | ||
isExactSameImage: misMatchPercentage === 0 | ||
isExactSameImage: misMatchPercentage === 0, | ||
...options |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: to be safe, wouldn't we want to spread options
first? In the future, we could potentially override the other object properties if we add duplicate properties to the passed in fileNames
object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yuderekyu Sorry. I am a bit new to ES6 and all of it's goodness. Can you explain to me what you mean by "spread options first"? First where?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return {
...options, //spread this first
misMatchPercentage,
isWithinMisMatchTolerance,
isSameDimensions,
isExactSameImage: misMatchPercentage === 0,
};
Just to be safe. If options
somehow contains any other keys (misMatchPercentage
, isWithinMismatchTolerance
, isSameDimensions
, isExactSameImage
), then spreading options
last would override those values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha.
@emilyrohrbough @yuderekyu @zinserjan We good now? |
Ummmm.....can this be merged now? |
?? |
@zinserjan I have many thumbs up here. Can this change be merged yet |
Thumbocracy 🤣 |
@zinserjan @emilyrohrbough @yuderekyu Is there anything I may have missed? |
@silne30 I do not have the permissions to merge this PR. I use the |
@zinserjan Hitting the 90 day mark since last fix was made. Anything else this needs? |
Hope everything is okay. Please approve if this works. Please give me a feedback if I need to change something. |
@zinserjan Anyone? |
Not sure if this project has nodded off. We are looking at almost 9 months since feedback from last commit. I am not even using this tool anymore but I am hoping the PR get's pulled for anyone else who may want the functionality. @zinserjan Are you still looking into this? |
Gonna go ahead and close this. If we need it, we can reopen it. We are going on a year without any update since the last code change. |
This PR adds the data for the filenames of the images that were created to the returned results. This is helpful when debugging test failures so you can output whatever exact image failed. If you have 5 different viewports, it can be helpful for displaying an image or pushing the image to some kind of cloud solution.