Complete the code to assert that the response status is 200.
pm.test('Status code is 200', function () { pm.response.to.have.status([1]); });
The correct status code for a successful HTTP response is 200. Using pm.response.to.have.status(200) asserts this.
Complete the code to assert that the response body contains the string 'success'.
pm.test('Body contains success', function () { pm.expect(pm.response.text()).to.include([1]); });
The assertion checks if the response text includes the word 'success'. This confirms the expected message is present.
Fix the error in the assertion to check that the JSON response has a property 'id'.
pm.test('Response has id property', function () { pm.expect(pm.response.json()).to.have.[1]('id'); });
The correct Chai assertion to check for a property in an object is to.have.property('id').
Fill both blanks to assert that the response JSON array length is greater than 0.
pm.test('Array length is positive', function () { pm.expect(pm.response.json().length).to.be.[1](0).[2](0); });
Chai uses to.be.above(0) or to.be.greaterThan(0) to check if a number is greater than zero. Here, above and greaterThan are chained.
Fill all three blanks to assert that the response JSON object's 'name' property equals 'John'.
pm.test('Name is John', function () { pm.expect(pm.response.json().[1]).[2].[3]('John'); });
The correct assertion accesses the 'name' property, then uses to.equal('John') to check its value.