Complete the code to create a test that checks if the response status code is 200.
pm.test('Status code is 200', function () { pm.response.to.have.status([1]); });
The test checks if the response status code equals 200, which means success.
Complete the code to test if the response body contains the string 'success'.
pm.test('Body contains success', function () { pm.expect(pm.response.text()).to.include([1]); });
The test checks if the response body text includes the word 'success'.
Fix the error in the test code to correctly 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'); });
HTTP headers are case-insensitive but Postman expects the exact header name 'Content-Type' to get the value correctly.
Fill both blanks to test if the JSON response has a property 'success' set to true.
pm.test('Response success is true', function () { pm.expect(pm.response.json().[1]).to.be.[2]; });
The test accesses the 'success' property in the JSON response and checks if it is true.
Fill all three blanks to test if the response JSON has a property 'data' which is an array with length greater than 0.
pm.test('Data array is not empty', function () { pm.expect(pm.response.json().[1]).to.be.an('[2]').and.have.length.[3](0); });
The test checks that the 'data' property is an array and its length is above 0, meaning it is not empty.