Recall & Review
beginner
What is a response body array assertion in API testing?
It is a check to confirm that the response from an API contains an array and that this array meets certain conditions like length, content, or structure.
Click to reveal answer
beginner
How do you check if the response body contains an array with at least 3 items in Postman?
Use the assertion: pm.expect(pm.response.json()).to.be.an('array').with.lengthOf.at.least(3);
Click to reveal answer
intermediate
Why is it important to assert the type of response body elements in an array?
To ensure the API returns data in the expected format, which helps avoid errors in later processing or display of data.
Click to reveal answer
intermediate
Show how to assert that every item in a response array has a property 'id' in Postman.
Use: pm.response.json().forEach(item => pm.expect(item).to.have.property('id'));
Click to reveal answer
intermediate
What does the assertion pm.expect(pm.response.json()).to.include.members([1, 2]) check in a response array?
It checks that the response array includes the members 1 and 2 somewhere in its elements.
Click to reveal answer
Which Postman assertion checks if the response body is an array?
✗ Incorrect
Option D correctly checks that the response body parsed as JSON is an array.
How do you assert that every object in a response array has a 'name' property?
✗ Incorrect
Option A loops through each item and asserts the 'name' property exists.
What does this assertion check? pm.expect(pm.response.json()).to.have.lengthOf(5);
✗ Incorrect
It checks the array length is exactly 5.
Which assertion verifies that the response array includes the number 10?
✗ Incorrect
Option B checks that the array includes the member 10.
Why should you assert the response array structure in API testing?
✗ Incorrect
Asserting structure ensures data is correct and usable.
Explain how to write assertions in Postman to verify that a response body contains an array with specific properties in each item.
Think about using pm.response.json(), array methods, and pm.expect() assertions.
You got /4 concepts.
Describe why it is important to assert the length and content of an array in an API response.
Consider what happens if the array is empty or missing expected elements.
You got /4 concepts.