-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Pass scenario to hook as a second argument #143
Conversation
Allows to determine scenario name and so make hooks more useful and scenario-oriented.
For example, I want to create a hook that will save a screenshot after each scenario. |
Thanks @vectart. I think we should follow the conventions and keep our callback as the last argument. I know this will not be backward-compatible but we're still on 0.x, right? |
@jbpros You're absolutely right—backward compatibly was a reason why I kept that order. |
Thank you. I'll merge it and bump the version to 0.4 in the next release. I was thinking maybe we could inspect the hook function signature and conditionally pass the scenario object to it. The only issue with that people won't be able to do this.Before(function () {
arguments[1](); // <- calls back
}); Or they still can if we inspect the function and pass the scenario objects in all cases except when exactly one parameter is exposed on its signature: if (code.length === 1)
code.call(world, callback);
else
code.call(world, scenario, callback); It seems pretty good to me and would stay backward-compatible for most (all?) people. WDYT? |
@jbpros I like your solution and committed the improvement. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Allows to determine scenario name and so make hooks more useful and
scenario-oriented.