Test Overview
This test checks if the API response matches the expected JSON schema. It verifies the structure and data types of the response fields.
This test checks if the API response matches the expected JSON schema. It verifies the structure and data types of the response fields.
pm.test('Response matches JSON schema', () => { const schema = { type: 'object', properties: { id: { type: 'integer' }, name: { type: 'string' }, email: { type: 'string', format: 'email' }, isActive: { type: 'boolean' } }, required: ['id', 'name', 'email', 'isActive'], additionalProperties: false }; pm.response.to.have.jsonSchema(schema); });
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts | Postman test runner is ready to execute the test script | - | PASS |
| 2 | Send API request and receive response | Response received with JSON body containing id, name, email, and isActive fields | - | PASS |
| 3 | Validate response JSON against the defined schema using pm.response.to.have.jsonSchema | Response JSON is checked for correct types and required fields | Check that id is integer, name is string, email is valid email string, isActive is boolean, and no extra fields exist | PASS |
| 4 | Test completes with assertion result | Test runner shows test passed if schema validation succeeded | Schema validation passed | PASS |