Hi everyone, I am trying to run collection with written test, here, when z == true, postman just ignore my if() and send request to “Make Bet”.
Hey @nar13 Welcome to the community!
postman.setNextRequest()
does not call/execute the request immediately. It only let’s postman know which request to run after the current one finishes.
Check an earlier answer on Postman community for more details: setNextRequest() doesn't work - #7 by amit
In your case, since the control falls to the last if..else
block, and likely y
is less than 2
hence postman.setNextRequest('Make Bet');
gets executed, overriding the earlier instruction to run the Unable Bonus
request.
you can change your control flow as follows, which should make sure that only one postman.setNextRequest() is excuted, setting the right request to be executed, post completion of the current one
if (z === true) {
...
} else if ( y < 2)
...
} else {
}
PS: For future, it is advisable to post scripts/code as text/code-blocks, makes it easier for others to test your code
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.