Skip to content

Fix: Before hook does not run with async callback returning Promise#4380

Open
ac-mmi wants to merge 12 commits into
nightwatchjs:mainfrom
ac-mmi:fix/before-hook
Open

Fix: Before hook does not run with async callback returning Promise#4380
ac-mmi wants to merge 12 commits into
nightwatchjs:mainfrom
ac-mmi:fix/before-hook

Conversation

@ac-mmi

@ac-mmi ac-mmi commented Feb 15, 2025

Copy link
Copy Markdown

In file _basehook.js here in this line const invocationResult = this.context.invokeMethod(this.key, client, argsCount they weren't
handling async results properly—if a hook returned a promise. Now, I added a check: if result is a promise, it then() waits for it and catches any errors. If it’s not a promise, it works the same way as before.

Fixes #4379

@ac-mmi ac-mmi closed this Feb 15, 2025
@ac-mmi ac-mmi reopened this Feb 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

before hook does not run with async callback returning Promise<undefined>.

1 participant