Delay test result until process completes

I use a POST request to initiate a flow which calls several APIs. The POST request returns a progress URL in its body, and that progress URL has a JSON key, “state”, which indicates whether all the APIs have been called successfully.

The value of “state” is initially “RETRY”, but after a minute or two resolves to either “SUCCESS” or “FAILURE”. As such, a test that immediately checks whether “state” === “SUCCESS” will always fail.

I have tried things such as setTimeout to try and delay the check to “state”, and have also tried do/while loops where “state” is checked repeatedly until it resolves to either “SUCCESS” or “FAILURE”.

Both of these types of approaches ends up crashing my Postman app; at best, I receive an error message: “There was an error in evaluating the test script: Error: sandbox: execution interrupted, bridge disconnecting.”.

I appreciate any help anyone can offer. I’m running the latest Postman App on a Windows 10 PC.

Thank you!

Hey @hpack, welcome to the Postman community.

I posted the above thread a while ago, let me know if it helps you out at all.

From what I remember, I believe I’m using a POST request to create a customer, and then using a GET customers endpoint to confirm if that customer now exists. But it may take a few seconds for that customer to exist, this scenario will obviously fail when the test is ran via the collection runner.

So I basically, keep hitting the GET customers endpoint x times until the record is there. If after X times the customer record is still now there then we go “Ok, we’ve tried enough times now and the customer record is still not there. Let’s mark this as failed and move onto the next request”

Hopefully the thread can give you some value even though my solution sounds a little messy/hacky :slight_smile: