-
-
Notifications
You must be signed in to change notification settings - Fork 729
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
Set unique screenshot name for failed tests #299
Conversation
pull master
Can you provide an example of hashed filename? |
Here is an example Please, share your thoughts, if you have any idea how we can set unique name for screenshot so that we will be able to understand to which test does screenshot belong. |
How about prepending testname? Just to know what it is
|
If we will add testname in the screenshot name then this point will not be included to this feature: |
Yep. That would be ok. |
if (this.options.hashCodeScreenshotsNames) | ||
fileName = hashCode(test.title) + '-' + hashCode(test.file) + '.failed.png'; | ||
else | ||
fileName = test.title.replace(/ /g, '_') + '.failed.png'; |
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.
wouldn't it be more readable if you would use ${string interpolation}
?
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, few more changes from me and it is ready to be merged
@@ -194,6 +194,7 @@ class WebDriverIO extends Helper { | |||
waitForTimeout: 1000, // ms | |||
desiredCapabilities: {}, | |||
restart: true, | |||
hashCodeScreenshotsNames: false, |
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.
better to name it uniqueScreenshotNames
or uniqueScreenshots
@@ -288,7 +288,11 @@ class WebDriverIO extends Helper { | |||
} | |||
|
|||
_failed(test) { | |||
let fileName = test.title.replace(/ /g, '_') + '.failed.png'; | |||
let fileName = ''; | |||
if (this.options.hashCodeScreenshotsNames) |
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.
{ }
- are important in if
@@ -1216,4 +1220,16 @@ function withStrictLocator(locator) { | |||
} | |||
} | |||
|
|||
function hashCode(str) { |
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.
pleease move that to lib/utils
with some comments about how the hashing is done and for what purpose. Because it would be hard to understand that for later users
let fileName = test.title.replace(/ /g, '_') + '.failed.png'; | ||
let fileName = ''; | ||
if (this.options.hashCodeScreenshotsNames) | ||
fileName = hashCode(test.title) + '-' + hashCode(test.file) + '.failed.png'; |
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.
can this be test.title.substring(0,10)
or smth like that?
@DavertMik please check the changes after review and merge them :) |
Thanks, looks good now. I will try it locally then I will release a new version |
Hi!
During working I was faced with two issues with failed screenshots:
So I add new option for WebdriverIO to use hashCode of title of scenario and file name for screenshot name