How to replace postman.setNextRequest in K6 scripts?

I have a postman collection that has 7 requests.
In my collection I need to execute the requests 5,6,7 depending on a specific response I get after executing request 4.
We are doing this in postman using postman.setNextRequest.
From the K6 documentation that I have looked at it says that the setNextRequest is not supported after postman collections are converted into K6 scripts using the postman-to-k6 converter.
Wondering if anybody has implemented a workaround for this.

Any help / guidance is appreciated.

Hi @ballari.maitra, Welcome to the forum, and sorry for the slow reply :(.

Given that what postman-to-k6 produces is a script you can just go in the code and add that condition after the 4th request , like in .

// request 1,2,3,4
if (!<condition here>) {
   return; // this will cut the iteration short as the condition to execute request 5,6 and 7 wasn't met
}
// request 5,6,7

If you give us at least some of the produced script I guess I can try to give you a more specific code sample but yeah :wink:

Hope this helps you and sorry again for the late reply

Hi @mstoykov,
I ended up doing the same! thanks for your advice and help.