I am writing a test for an Async GET request. This test needs to retry every 5 seconds for up to 120 seconds before it fails and moves on to the next request.
At the moment as a quick fix, I keep retrying without a limiter and that means it would keep retrying forever until it sees an expected outcome in the response.
Find my code below:
var jsonData = pm.response.json();
tests["Assert id is a string"] = typeof(jsonData.id) === "string";
if (jsonData._async.status !== "done" &&
globals.async_inv_byAddress == jsonData.id){
postman.setNextRequest("E2E get_Async_current_request");
} else {
pm.test("Async Test Passed");
postman.setNextRequest("E2E post_Async_next_request")
}
The code above can lead to a runtime of hours without failing.
I need to find a way of failing the test if it cannot find the expected output within 120 seconds and it needs to retry after every 5 seconds