Test Overview
This test checks how mocking an API in Postman allows frontend and backend teams to work at the same time without waiting for the real API to be ready.
This test checks how mocking an API in Postman allows frontend and backend teams to work at the same time without waiting for the real API to be ready.
pm.test("Mock API returns expected data", function () { pm.response.to.have.status(200); const jsonData = pm.response.json(); pm.expect(jsonData).to.have.property('userId'); pm.expect(jsonData.userId).to.eql(1); });
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts by sending a request to the mocked API endpoint in Postman. | Postman sends request to mock server URL, which returns predefined JSON data. | - | PASS |
| 2 | Postman receives response with status 200 and JSON body containing userId = 1. | Response visible in Postman with status 200 and body {"userId":1}. | Check response status is 200. | PASS |
| 3 | Test script parses JSON response and checks if 'userId' property exists. | JSON parsed successfully from response body. | Verify response JSON has property 'userId'. | PASS |
| 4 | Test script asserts that 'userId' equals 1 as defined in the mock. | Value of userId is 1 as expected. | Assert userId === 1. | PASS |
| 5 | Test completes successfully, confirming mock API behaves as expected. | Test report shows all assertions passed. | - | PASS |