1

I put a simple setTimeout(function(), 10000) call in the Tests section of a request.

Works fine when I run the step by itself.

When I do a Collection Run, the step just gets executed and Postman moves on without pausing.

Is this by design?

I'd rather not have to put a delay of X seconds for every step.

Guy
  • 666
  • 1
  • 10
  • 34

1 Answers1

2

it works as expected , check the console to see when was the request send

make sure request is saved:

enter image description here

THe orange indication shows that it is unsaved , you have to save it

use the below command in pre-request script.

  let moment = require("moment")
  console.log("before:", moment())

  setTimeout(function () { console.log("after:", moment()) }, 10000)

and check in console:

enter image description here

PDHide
  • 18,113
  • 2
  • 31
  • 46
  • I can check the console, but I assure you that even without doing that, when I set the timeout to 20 seconds, the step runs in less than one second. The timeout only has an effect when I run the step by itself, but not in a collection-run. – Guy Apr 08 '21 at 17:48
  • @Guy no it sends the request only after 20 second – PDHide Apr 08 '21 at 18:19
  • make sure you have saved the request – PDHide Apr 08 '21 at 18:20
  • 1
    I found my typo. Exactly as you said. Thank you! – Guy Apr 08 '21 at 19:05