-
-
Notifications
You must be signed in to change notification settings - Fork 730
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
better hooks handling by submitting where test.failed occur #4782
Conversation
DavertMik
commented
Jan 25, 2025
- Minor debug improvements to Playwright
- Added hookInfo to event if test failed in a hook
- fixed screenshot and stepByStep plugin to work in Before/After hooks
lib/plugin/screenshotOnFail.js
Outdated
if (test.ctx?._runnable.title.includes('hook: ')) { | ||
output.plugin('screenshotOnFail', 'BeforeSuite/AfterSuite do not have any access to the browser, hence it could not take screenshot.') | ||
event.dispatcher.on(event.test.failed, (test, _err, hookName) => { | ||
if (hookName == 'BeforeSuite' || hookName == 'AfterSuite') { |
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.
I guess it shall be ===, shall not it?
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.
it doesn't matter but yes, can be
lib/plugin/screenshotOnFail.js
Outdated
if (test.ctx?._runnable.title.includes('hook: ')) { | ||
output.plugin('screenshotOnFail', 'BeforeSuite/AfterSuite do not have any access to the browser, hence it could not take screenshot.') | ||
event.dispatcher.on(event.test.failed, (test, _err, hookName) => { | ||
if (hookName == 'BeforeSuite' || hookName == 'AfterSuite') { |
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.
Shall we also print something to acknowledge users that there is no browser available at this stage
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.
no, I think this information is not important
it would be valuable if user does some actions in a browser and wants screenshots to be stored
it would be confusing in this case to see that some screenshots are missing
(btw it is current behavior)
but as they can't do actions in AfterSuite, they don't expect screenshots to be added
lib/plugin/stepByStepReport.js
Outdated
if (test.ctx._runnable.title.includes('hook: ')) { | ||
output.plugin('stepByStepReport', 'BeforeSuite/AfterSuite do not have any access to the browser, hence it could not take screenshot.') | ||
event.dispatcher.on(event.test.failed, (test, _err, hookName) => { | ||
if (hookName == 'BeforeSuite' || hookName == 'AfterSuite') { |
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.
Same aforementioned question