PM Tests passing even when response body is incorrect

Hi,
I am looking to drill down into an XML response to check that a data type returned in not null. I am using the below to check the value but even then this data is not in the response, the tests are passing each time? Can anyone help me out, maybe I need to go deeper in the pm.response. section to check the value of a data field within the XML elements?

pm.expect(pm.response.vehicleheight).to.be.not.null;

Hey @aidan.mccarthy

Welcome to the community! :star:

You may need to expand on the context here a little bit - without the XML response body and the rest of the code you have in the Tests sandbox, it’s difficult to see what’s going on here.

I see you have pm.response.vehicleheight in the expect statement, that would probably return undefined so the test would pass.

pm.response.json() would parse a JSON body but as you mentioned XML this would probably fail with a script error, if used correctly.

Adding some logging here can help you out too -console.log(pm.response.vehicleheight) would show you in the Postman Console what that value resolves too.

You could also take a look at this awesome tutorial from @vdespa - https://youtu.be/UjQpUNPCvy4

Without all the extra details though it’s hard to know for sure, it’s just making folks guess what’s going on rather than seeing what’s happening.

1 Like

hi Danny,

This is exactly right, the value is returning as undefined.
The values I am looking to test are returned within the below structure;
SOAP:Envolope --> –>: values

Can I drill down deeper on the pm.response to get into the xml element to track the values deeper in the response?

I included a link to a tutorial that might answer some of your questions.

pm.response.text() is the function you would use to get the response body, you would need to convert this using the information in the video to drill down to what you need.