pm.test('Status code is 200', function () {
pm.response.to.have.status(200);
});
pm.test('Response has user id 123', function () {
const jsonData = pm.response.json();
pm.expect(jsonData.id).to.eql(123);
});
pm.test('Response has required keys', function () {
const jsonData = pm.response.json();
pm.expect(jsonData).to.have.all.keys('id', 'name', 'email');
});The first test checks if the response status code is 200, which means the request was successful.
The second test parses the JSON response and verifies the user id is exactly 123.
The third test ensures the response JSON contains the keys 'id', 'name', and 'email', confirming the expected data structure.
All tests use Postman's pm and pm.expect APIs for clear and reliable assertions.