Complete the code to send a GET request in Postman test script.
pm.sendRequest({ url: '[1]', method: 'GET' }, function (err, res) { pm.test('Status code is 200', function () { pm.expect(res.code).to.eql(200); }); });The URL must be a valid endpoint string to send the GET request.
Complete the code to check if the response JSON has a 'userId' property.
pm.test('Response has userId', function () { const jsonData = pm.response.json(); pm.expect(jsonData).to.have.[1]('userId'); });
The 'property' assertion checks if the JSON object has the specified key.
Fix the error in the test that checks if response time is less than 200ms.
pm.test('Response time is fast', function () { pm.expect(pm.response.responseTime) [1] 200; });
The less than operator '<' correctly checks if response time is under 200ms.
Fill both blanks to check if the response JSON array length is greater than 0.
pm.test('Response array is not empty', function () { const jsonData = pm.response.json(); pm.expect(jsonData.[1]).to.be.[2](0); });
'length' gets the array size, and 'above' asserts it is greater than 0.
Fill all three blanks to test if the response header 'Content-Type' includes 'json'.
pm.test('Content-Type is JSON', function () { pm.expect(pm.response.headers.get('[1]')).to.[2]('[3]'); });
'Content-Type' is the header name, 'include' is the assertion method, and 'json' is the expected substring.