Test Overview
This test checks if the Postman collection runs the next request conditionally based on the response of the current request. It verifies that setNextRequest correctly directs the flow.
This test checks if the Postman collection runs the next request conditionally based on the response of the current request. It verifies that setNextRequest correctly directs the flow.
pm.test("Check response status and set next request", function () { pm.response.to.have.status(200); const jsonData = pm.response.json(); if (jsonData.success === true) { pm.setNextRequest("Request B"); } else { pm.setNextRequest(null); // stops the run } });
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts and sends 'Request A' to the server | Postman sends HTTP request 'Request A' and waits for response | - | PASS |
| 2 | Postman receives response for 'Request A' | Response status 200 and JSON body received | Check response status is 200 | PASS |
| 3 | Test script parses JSON response and checks if 'success' is true | JSON parsed, 'success' field evaluated | - | PASS |
| 4 | Based on condition, setNextRequest is called with 'Request B' | Postman sets next request to 'Request B' | - | PASS |
| 5 | Postman sends 'Request B' as next request | Request B sent to server | - | PASS |