Complete the code to check if the response status code is 200.
pm.test("Status code is 200", function () { pm.response.to.have.status([1]); });
The status code 200 means the request was successful. We use pm.response.to.have.status(200) to assert this.
Complete the code to assert that the JSON response has a key named 'name'.
pm.test("Response has 'name' key", function () { pm.expect(pm.response.json()).to.have.property([1]); });
We check if the JSON response has the key "name" using to.have.property("name").
Fix the error in the code to assert that the 'age' value equals 30.
pm.test("Age is 30", function () { pm.expect(pm.response.json().age).to.be.[1](30); });
The correct Chai assertion method is equal to check value equality.
Fill both blanks to assert that the response JSON array 'users' has length 5.
pm.test("Users array length is 5", function () { pm.expect(pm.response.json().[1]).to.have.length[2](5); });
We access the 'users' array and use lengthOf to check its length.
Fill all three blanks to assert that the 'status' key in JSON equals 'success' and is a string.
pm.test("Status is success string", function () { pm.expect(pm.response.json().[1]).to.be.a([2]).and.to.equal([3]); });
We check the 'status' key, assert its type is 'string', and its value equals 'success'.