Test Overview
This test checks if a local variable set within a Postman request script is correctly assigned and used in an assertion to verify the response status code.
This test checks if a local variable set within a Postman request script is correctly assigned and used in an assertion to verify the response status code.
pm.test("Status code is 200", function () { let expectedStatus = 200; // local variable pm.response.to.have.status(expectedStatus); });
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test script starts execution | Postman request has completed and response is available | - | PASS |
| 2 | Local variable 'expectedStatus' is assigned the value 200 | Variable 'expectedStatus' holds 200 within the test function scope | - | PASS |
| 3 | Assertion checks if response status equals 'expectedStatus' (200) | Response status code is 200 | pm.response.to.have.status(expectedStatus) | PASS |
| 4 | Test completes successfully | Test result recorded as pass | - | PASS |