Issue #11132 - adding hookName to beforeHook and afterHook#11148
Issue #11132 - adding hookName to beforeHook and afterHook#11148christian-bromann merged 14 commits intowebdriverio:mainfrom
Conversation
| string, | ||
| number | ||
| number, | ||
| string? |
There was a problem hiding this comment.
From what I can tell, this isn't optional and is always passed
There was a problem hiding this comment.
i'm leaving this optional, since runSpec in testInterfaceWrapper calls it as well, and then we'll add an unused argument (origFn.name is it)
| ) { | ||
| const retries = { attempts: 0, limit: repeatTest } | ||
| const beforeArgs = beforeFnArgs(this) | ||
| if (type !== 'Test') { |
There was a problem hiding this comment.
Let's explicitly add it to the functions we want instead of adding it to everything but Test
There was a problem hiding this comment.
i'm not sure if i understood what you meant, or know how implement.
do you mean that i'll need to remove the if, so it would work with type==='Test' as well? or that when we push to this to afterArgs/beforeArgs the hookName will be inserted as well, as part of line 70.
if it's the second one, i'm a bit stumped here, since i can't quite understand how to do this (help wanted 🙂)
There was a problem hiding this comment.
changed the comparison to look for Hook, since we want to implement this on all hooks
erwinheitzman
left a comment
There was a problem hiding this comment.
Left another comment.
We also have to update the docs and templates with the new argument
fix according to comment Co-authored-by: Erwin Heitzman <15839059+erwinheitzman@users.noreply.github.com>
|
#11148 (review) |
christian-bromann
left a comment
There was a problem hiding this comment.
It would be nice to have a test for this to ensure we verify this functionality!
christian-bromann
left a comment
There was a problem hiding this comment.
One comment on the position of the argument in the afterHook interface. Also, I still would like to see a smoke test that verifies this feature exist.
packages/wdio-types/src/Services.ts
Outdated
| */ | ||
| afterHook?(test: Test, context: any, result: TestResult): unknown | Promise<unknown> | ||
| */ | ||
| afterHook?(test: Test, context: any, hookName: string, result: TestResult): unknown | Promise<unknown> |
There was a problem hiding this comment.
This could be a potentially breaking change for user that access the result object, how about we also add it as last argument?
There was a problem hiding this comment.
const emitHookEvent = (
fnName: string,
eventType: string
) => (
_test: never,
_context: never,
{ error }: { error?: jasmine.FailedExpectation } = {},
_hookName: never
There was a problem hiding this comment.
Just leave out the _hookName parameter
There was a problem hiding this comment.
Small reminder to update the docs/templates since the argument is now last
|
Ping @HananArgov |
|
sorry, i've been on vacation abroad for a while, and came back today. |
|
any idea on why the tests failed? i'm not sure if they are related to the changes i've made |
|
@HananArgov it seems that the coverage dropped, feel free to update the branch coverage to |
|
@christian-bromann i'm now getting this issue: I can't understand what to do here. |
Sure, please feel free to block a slot in the Open Office Hours. |

Proposed changes
Adding hookName to
beforeHookandafterHookper issue #11132Types of changes
Checklist
Further comments
as seen in the issue, this will able us to see which hook is referred in
beforeHookandafterHookReviewers: @webdriverio/project-committers