how do i test arrays inside objects with different rquest?:
HI! im tryng to run this api that receives an object with multiple arrays and i want to make a test of each array:
i cant show u code cause its a mess, i do have a few ideas but none of them works cause everytime i try to take that object to the “pre-rquested script” i dont get the actual object i get “null” or empty arrays… im lost why cant i move the object to that place?
i saw a few answers but they always make a new array inside the pre-rquested script… but the json with the object creates on its own
pre-rquested script executes before the API call is sent, and test scripts execute after the API call is sent.
You won’t be able to assess a response body array until the API call has been sent and a response received back from the server.
You could potentially use pm.sendRequest(); to send the call inside the pre-req script. But generally speaking, asserting the response would be done inside the test tab.
Can you confirm what you are trying to achieve here?
When you get your code to work, it appears that you are writing some of the response information to global variables, and then using those in your tests.
Won’t that mean the tests will always pass? Following good practice, how will you make the test fail?