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
Recall & Review
beginner
What are the main types of scripts in Postman that control the execution order?
Pre-request scripts and Test scripts. Pre-request scripts run before the request is sent. Test scripts run after the response is received.
Click to reveal answer
intermediate
In what order do Postman scripts execute when running a collection?
First, the Pre-request script of the collection runs, then the Pre-request script of the folder (if any), then the Pre-request script of the request. After the request is sent and response received, the Test script of the request runs, then the Test script of the folder, then the Test script of the collection.
Click to reveal answer
beginner
Why is understanding script execution order important in Postman?
Because it helps you organize setup and cleanup tasks properly. For example, setting environment variables before a request or validating responses after. It ensures scripts run at the right time for reliable tests.
Click to reveal answer
intermediate
What happens if you set a variable in a Pre-request script at the collection level and then overwrite it in the request Pre-request script?
The variable set in the request Pre-request script will overwrite the collection level variable for that request execution, because request scripts run after collection scripts.
Click to reveal answer
intermediate
Can Test scripts modify variables that affect subsequent requests in the same collection run?
Yes. Test scripts can set or update variables that will be used by later requests in the collection run, allowing dynamic data flow between requests.
Click to reveal answer
Which script runs first when executing a request in Postman?
ACollection Pre-request script
BRequest Test script
CRequest Pre-request script
DFolder Test script
✗ Incorrect
The Collection Pre-request script runs first, before folder and request Pre-request scripts.
After a request is sent and response received, which script runs immediately next?
ARequest Pre-request script
BRequest Test script
CCollection Test script
DFolder Pre-request script
✗ Incorrect
The Request Test script runs immediately after the response is received.
If you want to set a variable before any request runs in a collection, where should you put the script?
ACollection Pre-request script
BRequest Test script
CFolder Test script
DRequest Pre-request script
✗ Incorrect
Collection Pre-request scripts run before any requests, so they are ideal for setting variables globally.
Which script can update variables for use in later requests during a collection run?
APre-request scripts only
BNeither
CTest scripts only
DBoth Pre-request and Test scripts
✗ Incorrect
Both Pre-request and Test scripts can set or update variables that affect later requests.
What is the correct order of Test scripts execution after a request?
AFolder, Request, Collection
BCollection, Folder, Request
CRequest, Folder, Collection
DRequest, Collection, Folder
✗ Incorrect
Test scripts run in this order: Request Test script, then Folder Test script, then Collection Test script.
Explain the order in which Pre-request and Test scripts run in Postman when executing a collection.
Think about scripts running from broadest scope to narrowest before the request, then from narrowest to broadest after.
You got /7 concepts.
Describe how variable setting in different script levels affects their values during a collection run.
Consider the script execution order and scope hierarchy.
You got /4 concepts.
Practice
(1/5)
1. In Postman, which script runs first when you send a request? Collection Pre-request Script, Folder Pre-request Script, or Request Pre-request Script?
easy
A. Collection Pre-request Script
B. Folder Pre-request Script
C. Request Pre-request Script
D. Test Script
Solution
Step 1: Understand script types in Postman
Pre-request scripts run before sending the request. They can be set at collection, folder, or request level.
Step 2: Identify execution order of pre-request scripts
Postman runs pre-request scripts starting from the collection level, then folder, then request level.
Final Answer:
Collection Pre-request Script -> Option A
Quick Check:
Pre-request scripts run top-down: Collection first [OK]
Hint: Pre-request scripts run from collection to request level [OK]
Common Mistakes:
Thinking request pre-request script runs first
Confusing test scripts with pre-request scripts
Assuming folder scripts run before collection scripts
2. Which of the following is the correct syntax to add a test script in Postman that checks if the response status is 200?
easy
A. test('Status is 200', () => response.status === 200);
B. pm.check('Status is 200', () => pm.response.status === 200);
C. pm.assert('Status is 200', pm.response.statusCode == 200);
D. pm.test('Status is 200', function () { pm.response.to.have.status(200); });
Solution
Step 1: Recall Postman test script syntax
Postman uses pm.test() with a callback function to define tests.
Step 2: Verify correct assertion method
pm.response.to.have.status(200) is the correct way to check status code 200.
Final Answer:
pm.test('Status is 200', function () { pm.response.to.have.status(200); }); -> Option D
Quick Check:
Use pm.test() and pm.response.to.have.status() [OK]
Hint: Use pm.test() with pm.response.to.have.status() [OK]
Common Mistakes:
Using pm.check() which does not exist
Using test() without pm namespace
Using pm.assert() which is invalid
3. Given these scripts in Postman: Collection Pre-request Script: sets variable var1 = 'A' Folder Pre-request Script: sets var1 = 'B' Request Pre-request Script: sets var1 = 'C' After sending the request, what is the value of var1 in the test script?
medium
A. 'C'
B. 'B'
C. Undefined
D. 'A'
Solution
Step 1: Understand script execution order for pre-request scripts
Pre-request scripts run in order: collection, then folder, then request. Each can overwrite variables.
Step 2: Trace variable assignment
Collection sets var1='A', folder overwrites var1='B', request overwrites var1='C'. Final value is 'C'.
Final Answer:
'C' -> Option A
Quick Check:
Last pre-request script sets final variable [OK]
Hint: Last pre-request script overwrites variables [OK]
Common Mistakes:
Assuming collection script value remains
Thinking folder script overwrites request script
Forgetting scripts run before request
4. You wrote a test script in Postman but it never runs after sending the request. Which is the most likely reason?
medium
A. You forgot to save the request
B. The request URL is invalid
C. You placed the script in the Pre-request Script tab instead of Tests tab
D. You did not enable the collection runner
Solution
Step 1: Understand when test scripts run
Test scripts run after the response is received, and must be placed in the Tests tab.
Step 2: Identify script placement error
If the script is in Pre-request Script tab, it runs before sending request, not after response, so test code won't run as expected.
Final Answer:
You placed the script in the Pre-request Script tab instead of Tests tab -> Option C
Quick Check:
Tests run only in Tests tab after response [OK]
Hint: Put test code in Tests tab, not Pre-request tab [OK]
Common Mistakes:
Confusing pre-request and test script tabs
Assuming saving request affects script execution
Thinking collection runner is needed for tests
5. You have a collection with a pre-request script setting a variable token. A folder inside the collection has a pre-request script that updates token only if it is empty. The request inside the folder has a test script that checks if token is set. Which script execution order ensures the test script sees the updated token?
hard
A. Request test script runs before folder pre-request script
B. Collection pre-request script runs first, then folder pre-request script, then request test script
C. Folder pre-request script runs before collection pre-request script
D. Request pre-request script runs after test script
Solution
Step 1: Recall Postman script execution order
Pre-request scripts run in order: collection, folder, request. Test scripts run after response.
Step 2: Understand variable update flow
Collection sets token, folder updates if empty, then request test script runs after response to check token.
Step 3: Confirm correct order
This order ensures token is set and updated before test script checks it.
Final Answer:
Collection pre-request script runs first, then folder pre-request script, then request test script -> Option B
Quick Check:
Pre-request scripts run before tests in order [OK]
Hint: Pre-request scripts run before tests, top-down order [OK]
Common Mistakes:
Thinking test scripts run before pre-request scripts
Assuming folder scripts run before collection scripts
Believing request pre-request scripts run after tests