I’m looking to create a K6 test which works through a sequence of requests to different endpoints, passing variables from some responses to subsequent steps.
I’ve been searching for a guide to doing this and was hoping someone could recommend one. Or an example of how to do this.
Thanks
@thedossone here are a few examples from the public guides. The last two are using both an access token and an ID of a created entity.
1 Like
@thedossone In the above examples, you may have noticed a mix of group
from the core k6 API and describe
from the k6chaijs library. The chai describe
is a wrapper of group
but they do not behave identically. When an internal exception occurs, describe
catches those, and continues the execution outside of the describe function with the exception.
When variables must be passed, that introduces dependencies between requests. While the script can be written to handle the happy path, errors may only appear under load, so you may need an if condition on the expected variable to handle a possible undefined variable exception. Basically this would be deciding if you want the script to always continue to those subsequent steps or abort the current iteration and begin a new iteration.
Here are some other articles to review, including others that compare and contrast group
with describe
: