Postman Collection Run does not pause for setTimeout calls
Asked Answered
R

1

3

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.

Rauwolfia answered 7/4, 2021 at 15:11 Comment(0)
C
3

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

Centrifugal answered 7/4, 2021 at 16:8 Comment(4)
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.Rauwolfia
@Rauwolfia no it sends the request only after 20 secondCentrifugal
make sure you have saved the requestCentrifugal
I found my typo. Exactly as you said. Thank you!Rauwolfia

© 2022 - 2024 — McMap. All rights reserved.