Using busy wait Javascript is a good hack, but it makes your processor hot and the application is not responding. I understood this solution using the postman echo.
Assuming you want to add a long delay between Request_A and Request_B.
First, in the Request_A test script, set env var to mark the beginning.
environment.delayTimerStart = new Date();
Then create a GET request at creation (here it is called โDelay 10 sโ). It does a GET at https://postman-echo.com/delay/10 (returns in 10 seconds)
In your test case add
var curDate = new Date(); if (curDate - environment.delayTimerStart < delay_time_in_sec*1000) { postman.setNextRequest('Delay 10s'); } else { postman.setNextRequest("Request_B"); }
This way you can add a delay of any length.
Note: 10 seconds is the maximum value that the postman echo accepts. If you just need a little delay, just GET https://postman-echo.com/delay/[1~10] .
source share