// This test logs the number of starships returned in the server response
pm.test("Number of starships returned", function () {
// Parse the response body as JSON
const response = pm.response.json();
// Get the count of starships from the response
const starshipsCount = response.count;
// Log the count of starships
console.log("Number of starships returned: " + starshipsCount);
// Assert that the count is greater than or equal to 0
pm.expect(response.starshipsCount).to.be.at.least(0);
});
// Test to verify the status code is 200
pm.test("Status code is 200", function () {
pm.response.to.have.status(200);
});
I added this statement under the Tests tab to display the number of ships returned in the server response, which I subsequently saved. but level of question 3 where we ask to write another script to check the status 200 when I send I get test errors.
I think that i havenโt write a good test script is the raison that I have a false result but Iโm not sure please help me to have a solution to this part:
I didnโt actually physically check that request or the response from it - just made an assumption
The full suite of Postman badges cover about 70+ different individual requests and Iโm not 100% familiar with all of them off the top of my head
One of the best things to do here is to always share the full URL to the public workspace and not just static screen shots. It makes it so much more easier to see what you have in the requests.
ok thanks for your suggestion. but I have a preocupation please how can I write the instruction that will permite to me to show the number of starships returned in the server response??