0
0
Postmantesting~10 mins

Response headers in Postman - Test Execution Trace

Choose your learning style9 modes available
Test Overview

This test sends a GET request to a sample API endpoint and verifies that the response headers contain the expected Content-Type and Cache-Control values.

Test Code - Postman
Postman
pm.test("Response headers contain expected values", function () {
    pm.response.to.have.header("Content-Type");
    pm.expect(pm.response.headers.get("Content-Type")).to.include("application/json");
    pm.response.to.have.header("Cache-Control");
    pm.expect(pm.response.headers.get("Cache-Control")).to.eql("no-cache");
});
Execution Trace - 7 Steps
StepActionSystem StateAssertionResult
1Test startsPostman is ready to send the request-PASS
2Send GET request to the API endpointRequest sent, waiting for response-PASS
3Receive response with headersResponse received with headers including Content-Type and Cache-Control-PASS
4Check if response has header 'Content-Type'Headers available in responseVerify 'Content-Type' header existsPASS
5Verify 'Content-Type' header value includes 'application/json'Header value is 'application/json; charset=utf-8'Check header value contains 'application/json'PASS
6Check if response has header 'Cache-Control'Headers available in responseVerify 'Cache-Control' header existsPASS
7Verify 'Cache-Control' header value equals 'no-cache'Header value is 'no-cache'Check header value equals 'no-cache'PASS
Failure Scenario
Failing Condition: Response does not include the expected 'Content-Type' or 'Cache-Control' headers or their values do not match expected
Execution Trace Quiz - 3 Questions
Test your understanding
What does the test verify about the 'Content-Type' header?
AIt checks that the header exists and includes 'application/json'
BIt checks that the header is exactly 'text/html'
CIt checks that the header is missing
DIt checks that the header value is empty
Key Result
Always verify both the presence and the exact expected value of response headers to ensure the API behaves as intended.