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

Incorrect documentation and examples about HTTP's function and beforeScenario/afterScenario hooks #3336

Open
peterhalicky opened this issue Sep 12, 2024 · 2 comments

Comments

@peterhalicky
Copy link

Documentation about function and beforeScenario/afterScenario hooks of the HTTP engine states that the hooks receive two parameters - context and events. Also some examples only specify those two.

I've just spent an hour or so scratching my head why aren't my tests working when I just added an empty beforeScenario hook function in my test, until I found another example where those functions receive the 3rd argument next and I need to call it to let the scenario continue.

beforeRequest and afterResponse doc seems to have the same problem.

@hassy
Copy link
Member

hassy commented Sep 12, 2024

thanks for taking the time to open an issue @peterhalicky! We need to make it clearer in the docs that functions have to be async. It's tucked away elsewhere in the docs at the moment and is not easy to find.

@peterhalicky
Copy link
Author

OK, looks like it's more complicated than I initially thought. Documentation says that hooks can be async. Installing @types/artillery brings in the type definitions, but those say that the hooks are supposed to return void -- but async functions will return Promise<void> which isn't the same thing, so you get a warning in the IDE and also artillery (nodejs) complains ("DeprecationWarning: Calling promisify on a function that returns a Promise is likely a mistake.").

In fact, as I just found, if a function is async, the next() call isn't needed -- but I still get those deprecation warnings above.

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

No branches or pull requests

2 participants