Verify API response status and body using pm.test() in Postman Tests tab
Preconditions (2)
Step 1: Open Postman and create a new GET request
Step 2: Enter the URL https://jsonplaceholder.typicode.com/posts/1
Step 3: Go to the Tests tab below the request URL field
Step 4: Write pm.test() scripts to check the response status is 200
Step 5: Write pm.test() scripts to check the response body contains userId equal to 1
Step 6: Send the request by clicking the Send button
Step 7: Observe the test results in the Tests tab output
✅ Expected Result: The response status code is 200 and the test passes. The response body contains userId equal to 1 and the test passes. Both tests show as passed in the Tests tab.