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. We use pm.response.to.have.status(200) to check this.
Complete the code to check if the response body contains the word 'success'.
pm.test("Body contains success", function () { pm.expect(pm.response.text()).to.include([1]); });
We check if the response text includes the string "success" by passing it as a string with quotes.
Fix the error in the code to check if the response header 'Content-Type' is 'application/json'.
pm.test("Content-Type is JSON", function () { pm.expect(pm.response.headers.get([1])).to.eql('application/json'); });
The header name must be passed as a string with correct case and quotes. 'Content-Type' with single quotes is correct.
Fill both blanks to check if the response time is less than 500 milliseconds.
pm.test("Response time is fast", function () { pm.expect(pm.response.responseTime) [1] [2]; });
We check if the response time is less than 500 ms by using pm.response.responseTime < 500.
Fill all three blanks to create a test that checks if the JSON response has a property 'status' equal to 'success'.
pm.test("Status is success", function () { const jsonData = pm.response.json(); pm.expect(jsonData.[1]).to.eql([2]); });
We access the 'status' property and check if it equals the string 'success' using quotes.