Complete the code to check if the response status is 200.
pm.test("Status code is 200", function () { pm.response.to.have.status([1]); });
The status code 200 means the request was successful. The assertion checks this to validate the response.
Complete the code to assert the response body contains the key 'success'.
pm.test("Response has success key", function () { pm.expect(pm.response.json()).to.have.property([1]); });
The assertion checks if the JSON response has the key 'success'. This confirms the response structure.
Fix the error in the assertion that checks if the response time is less than 200ms.
pm.test("Response time is fast", function () { pm.expect(pm.response.responseTime).to.be.[1](200); });
The correct assertion method is lessThan to check if response time is under 200ms.
Fill both blanks to assert the response header 'Content-Type' is 'application/json'.
pm.test("Content-Type is JSON", function () { pm.response.to.have.header([1]); pm.expect(pm.response.headers.get([2])).to.equal('application/json'); });
Headers are case-insensitive but best practice is to use 'Content-Type' exactly. Both blanks need this header name.
Fill all three blanks to assert the response JSON has a 'data' object with a 'userId' equal to 5.
pm.test("User ID is 5", function () { const jsonData = pm.response.json(); pm.expect(jsonData[1][2]).to.eql([3]); });
The code accesses jsonData['data']['userId'] and checks if it equals 5.