pm.test('Status code is 200', function () { pm.response.to.have.status(200); });
In Postman, pm.response.code holds the numeric status code. The correct Chai assertion to check equality is to.equal(200). Other options use incorrect property names or invalid assertion methods.
pm.test('Check success and count', function () { var jsonData = pm.response.json(); pm.expect(jsonData.success).to.be.true; pm.expect(jsonData.count).to.be.above(3); });
The JSON has success: true and count: 5. The assertions check if success is true and count is greater than 3, both conditions are met, so the test passes.
var jsonData = pm.response.json();
Option A correctly asserts that the 'profile' object has a property 'name'. Option A tries to access nested property as a string which is invalid. Option A checks existence of the value but not property presence. Option A uses wrong key syntax.
pm.test('Array length check', function () { var jsonData = pm.response.json(); pm.expect(jsonData.items.length).to.be.above(0); });
The error means jsonData.items is undefined, so accessing length fails. This usually happens if the response JSON does not have an 'items' property.
Postman uses the Expect style of Chai assertions by default. The 'should' and 'assert' styles are supported by Chai but not the default in Postman. 'Verify' style does not exist in Chai.