An output block in Postman shows the results of your test scripts after running a request. It helps you see if your tests passed or failed.
Output block in Postman
// Example of test script output in Postman pm.test('Status code is 200', function () { pm.response.to.have.status(200); }); console.log('Test completed');
The output block shows results from pm.test() assertions and console.log() messages.
You can view the output block in the Postman app under the Test Results tab after running a request.
pm.test('Response time is less than 500ms', function () { pm.expect(pm.response.responseTime).to.be.below(500); });
pm.test('Response has JSON body', function () {
pm.response.to.be.json();
});console.log('Response status:', pm.response.code);This script runs two tests: one checks if the status code is 200, the other checks if the response JSON has a userId property. It also logs a message to the output block.
// Test script in Postman pm.test('Status code is 200', function () { pm.response.to.have.status(200); }); pm.test('Response body has userId', function () { const jsonData = pm.response.json(); pm.expect(jsonData).to.have.property('userId'); }); console.log('Tests finished');
Use pm.test() to create tests that show pass or fail in the output block.
Use console.log() to print helpful messages or variable values for debugging.
The output block updates only after you send the request and run the tests.
The output block shows test results and logs after running a request.
It helps you quickly see if your API tests passed or failed.
Use it to debug and verify your test scripts in Postman.
Practice
Output block in Postman primarily display after running a request?Solution
Step 1: Understand the purpose of the Output block
The Output block shows what happened after running a request, including test results and logs.Step 2: Identify what is NOT shown in the Output block
Settings, environments, or just headers are not shown here; only test results and logs appear.Final Answer:
The results of test scripts and any console logs -> Option DQuick Check:
Output block = test results + logs [OK]
- Confusing Output block with environment settings
- Thinking it shows only request headers
- Assuming it displays saved collections
Solution
Step 1: Recall JavaScript logging syntax in Postman
Postman test scripts use JavaScript, andconsole.log()is the standard way to log messages.Step 2: Identify incorrect logging functions
Functions likeprint(),log(), andecho()are not valid in Postman scripts.Final Answer:
console.log('Test passed') -> Option CQuick Check:
Use console.log() to log messages [OK]
- Using print() instead of console.log()
- Trying to use echo() which is not JavaScript
- Forgetting parentheses in console.log
pm.test('Status code is 200', () => {
pm.response.to.have.status(200);
});
console.log('Test completed');What will you see in the Output block after running the request if the response status is 200?
Solution
Step 1: Analyze the test script behavior
The test checks if the response status is 200. If true, the test passes.Step 2: Understand console.log output
The console.log prints 'Test completed' regardless of test result.Final Answer:
Test passed and 'Test completed' message -> Option BQuick Check:
Passing test + console.log message = Test passed and 'Test completed' message [OK]
- Assuming console.log only shows on failure
- Thinking test fails if console.log runs
- Ignoring test result messages
pm.test('Response time is less than 200ms', () => {
pm.expect(pm.response.responseTime).to.be.below(200);
});
console.log('Check complete');But after running, the Output block shows no test results or logs. What is the most likely problem?
Solution
Step 1: Check why Output block is empty
If no test results or logs appear, the script might not be running at all.Step 2: Confirm script attachment and saving
Scripts must be saved and attached to the request to run and show output.Final Answer:
The test script is not saved or attached to the request -> Option AQuick Check:
Unsaved script = no output [OK]
- Thinking console.log is unsupported
- Assuming Output block hides passing tests
- Believing test skips on exact boundary values
userId with value 5, and log 'User verified' only if the test passes. Which test script will correctly show this in the Output block?Solution
Step 1: Understand conditional logging requirement
pm.test callbacks always execute fully; assertions don't halt execution. Log only on pass requires a matching condition.Step 2: Analyze options
A: unconditional log after test - always logs.
B: log inside pm.test - executes even if assertion fails.
C: empty pm.test - no proper verification.
D: proper assertion test + matching if condition - logs only if userId === 5 (test passes).Final Answer:
pm.test('UserId is 5', () => { pm.expect(pm.response.json().userId).to.eql(5); }); if(pm.response.json().userId === 5) console.log('User verified'); -> Option AQuick Check:
if() matching test condition = log only on pass [OK]
- Putting console.log inside pm.test (runs on fail too)
- Logging unconditionally outside pm.test
- Using empty pm.test callback
Ready to prove it?
Pass the test and this pattern moves unknown
