Skip to content
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

Merged
merged 6 commits into from
Jan 27, 2025

Conversation

DavertMik
Copy link
Contributor

  • 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

@DavertMik DavertMik requested a review from kobenguyent January 25, 2025 22:17
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') {
Copy link
Collaborator

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?

Copy link
Contributor Author

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

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') {
Copy link
Collaborator

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

Copy link
Contributor Author

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

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') {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same aforementioned question

@DavertMik DavertMik merged commit ba64d2c into 3.x Jan 27, 2025
12 checks passed
@DavertMik DavertMik deleted the fix/hook-fail branch January 27, 2025 01:21
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants