Bird
Raised Fist0
Postmantesting~20 mins

Delay between requests in Postman - Practice Problems & Coding Challenges

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Challenge - 5 Problems
🎖️
Delay Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
Understanding Delay Between Requests in Postman

What is the primary reason to add a delay between requests in a Postman collection run?

ATo simulate real user behavior and avoid hitting API rate limits
BTo speed up the test execution by sending requests faster
CTo automatically retry failed requests without manual intervention
DTo reduce the size of the response payloads
Attempts:
2 left
💡 Hint

Think about how APIs handle many requests in a short time.

Predict Output
intermediate
2:00remaining
Postman Script Delay Output

What will be the output behavior when running this Postman pre-request script?

Postman
const delay = ms => new Promise(resolve => setTimeout(resolve, ms));

pm.test('Delay 2 seconds before request', async function () {
  await delay(2000);
  pm.expect(true).to.be.true;
});
AThe request will wait 2 seconds before sending, then pass the test
BThe request will send immediately, test will fail due to async error
CThe request will wait 2 seconds but test will timeout and fail
DThe script will cause a syntax error and stop the request
Attempts:
2 left
💡 Hint

Consider how async/await works in Postman scripts.

assertion
advanced
2:00remaining
Assertion on Delay Duration in Postman Tests

Which assertion correctly verifies that a delay of at least 3 seconds occurred before the request was sent?

Postman
const startTime = pm.environment.get('startTime');
const endTime = Date.now();
const elapsed = endTime - startTime;
Apm.test('Delay at least 3 seconds', () => pm.expect(elapsed).to.equal(3000));
Bpm.test('Delay at least 3 seconds', () => pm.expect(elapsed).to.be.lte(3000));
Cpm.test('Delay at least 3 seconds', () => pm.expect(elapsed).to.be.gte(3000));
Dpm.test('Delay at least 3 seconds', () => pm.expect(elapsed).to.be.below(3000));
Attempts:
2 left
💡 Hint

Think about how to check if elapsed time is greater than or equal to 3000 milliseconds.

🔧 Debug
advanced
2:00remaining
Debugging Delay Implementation in Postman Collection Runner

Given this Postman collection runner setup, why does the delay between requests not work as expected?

pm.test('Wait 1 second', () => {
  setTimeout(() => {}, 1000);
  pm.expect(true).to.be.true;
});
AThe delay value 1000 is too small to be noticed by Postman
BsetTimeout is asynchronous and does not block execution, so delay is ignored
Cpm.expect is called inside setTimeout, causing the test to fail
DsetTimeout requires a callback function with parameters to delay properly
Attempts:
2 left
💡 Hint

Consider how JavaScript handles setTimeout in synchronous code.

framework
expert
2:30remaining
Implementing Delay Between Requests in Postman Collection Runner

Which method correctly implements a 2-second delay between requests when running a Postman collection?

AAdd a <code>postman.setNextRequest(null)</code> and manually rerun requests with delay externally
BAdd a <code>delay</code> property in the request body to instruct the server to wait
CUse the <code>setTimeout</code> function inside the pre-request script without async/await
DUse an async pre-request script with <code>await new Promise(resolve =&gt; setTimeout(resolve, 2000))</code>
Attempts:
2 left
💡 Hint

Think about how to pause execution in Postman scripts.

Practice

(1/5)
1. What is the main purpose of adding a delay between requests in Postman?
easy
A. To change the request URL dynamically
B. To speed up the test execution
C. To skip some requests automatically
D. To simulate real user behavior and avoid server overload

Solution

  1. Step 1: Understand delay usage in Postman

    Delays are used to mimic real user wait times and prevent sending too many requests too fast.
  2. Step 2: Identify the correct purpose

    Speeding up tests or skipping requests are not related to delays; delays help simulate real scenarios and protect servers.
  3. Final Answer:

    To simulate real user behavior and avoid server overload -> Option D
  4. Quick Check:

    Delay purpose = simulate real use and avoid overload [OK]
Hint: Delays mimic real users and protect servers from overload [OK]
Common Mistakes:
  • Thinking delays speed up tests
  • Confusing delay with skipping requests
  • Assuming delay changes request data
2. Which of the following is the correct way to add a 2-second delay between requests in Postman using JavaScript?
easy
A. delay(2000); postman.setNextRequest('Request2');
B. postman.setNextRequest('Request2', 2000);
C. setTimeout(() => postman.setNextRequest('Request2'), 2000);
D. setTimeout(postman.setNextRequest('Request2'), 2000);

Solution

  1. Step 1: Recall correct setTimeout syntax

    setTimeout takes a function and delay in milliseconds: setTimeout(function, delay).
  2. Step 2: Check usage with postman.setNextRequest

    postman.setNextRequest must be called inside a function passed to setTimeout to delay execution.
  3. Final Answer:

    setTimeout(() => postman.setNextRequest('Request2'), 2000); -> Option C
  4. Quick Check:

    Use setTimeout with function and delay [OK]
Hint: Wrap setNextRequest in a function inside setTimeout [OK]
Common Mistakes:
  • Passing setNextRequest call directly to setTimeout
  • Using non-existent delay function
  • Trying to pass delay as second argument to setNextRequest
3. Given this Postman test script snippet, what will happen?
setTimeout(() => postman.setNextRequest('Login'), 3000);
console.log('Request scheduled');
medium
A. The 'Login' request will run immediately, and 'Request scheduled' logs after 3 seconds
B. 'Request scheduled' logs immediately, and 'Login' request runs after 3 seconds
C. Both 'Login' request and log happen immediately
D. Neither 'Login' request nor log will run

Solution

  1. Step 1: Understand setTimeout behavior

    setTimeout delays the function call (postman.setNextRequest) by 3000 ms, but console.log runs immediately.
  2. Step 2: Determine order of execution

    console.log('Request scheduled') runs first; after 3 seconds, the 'Login' request is set to run next.
  3. Final Answer:

    'Request scheduled' logs immediately, and 'Login' request runs after 3 seconds -> Option B
  4. Quick Check:

    console.log immediate, setNextRequest delayed [OK]
Hint: console.log runs immediately; setNextRequest delayed by setTimeout [OK]
Common Mistakes:
  • Assuming setNextRequest runs immediately
  • Thinking console.log waits for delay
  • Confusing order of asynchronous calls
4. You wrote this Postman script to delay the next request by 1 second, but the delay does not work. What is wrong?
setTimeout(postman.setNextRequest('NextRequest'), 1000);
medium
A. postman.setNextRequest should be inside a function passed to setTimeout
B. Delay time should be in seconds, not milliseconds
C. setTimeout cannot be used in Postman scripts
D. postman.setNextRequest does not accept request names

Solution

  1. Step 1: Analyze setTimeout usage

    setTimeout expects a function as first argument, but here postman.setNextRequest is called immediately.
  2. Step 2: Correct usage for delay

    Wrap postman.setNextRequest call inside a function (e.g., arrow function) to delay execution properly.
  3. Final Answer:

    postman.setNextRequest should be inside a function passed to setTimeout -> Option A
  4. Quick Check:

    Pass function to setTimeout, not direct call [OK]
Hint: Wrap setNextRequest call in a function for setTimeout delay [OK]
Common Mistakes:
  • Passing direct call instead of function to setTimeout
  • Confusing milliseconds with seconds
  • Believing setTimeout is unsupported in Postman
5. You want to run three requests in sequence with a 1-second delay between each in Postman. Which script correctly implements this in the Tests tab of the first request?
hard
A. setTimeout(() => { postman.setNextRequest('Request2'); setTimeout(() => postman.setNextRequest('Request3'), 1000); }, 1000);
B. setTimeout(() => postman.setNextRequest('Request2'), 1000);
C. postman.setNextRequest('Request2'); setTimeout(() => postman.setNextRequest('Request3'), 1000);
D. postman.setNextRequest('Request2'); postman.setNextRequest('Request3');

Solution

  1. Step 1: Understand sequential delays

    Each request must be delayed before triggering the next; nested setTimeout calls create sequential delays.
  2. Step 2: Analyze options

    setTimeout(() => { postman.setNextRequest('Request2'); setTimeout(() => postman.setNextRequest('Request3'), 1000); }, 1000); nests setTimeout calls to delay Request2 by 1s, then Request3 by another 1s, correctly sequencing requests with delays.
  3. Final Answer:

    setTimeout(() => { postman.setNextRequest('Request2'); setTimeout(() => postman.setNextRequest('Request3'), 1000); }, 1000); -> Option A
  4. Quick Check:

    Nested setTimeouts create sequential delays [OK]
Hint: Use nested setTimeouts to delay multiple requests sequentially [OK]
Common Mistakes:
  • Calling setNextRequest multiple times without delay
  • Not nesting delays causing immediate requests
  • Assuming one setTimeout delays all requests