Try console.log() for each variable created and check the values through console and see what is going south here.
Also, in the last line, expect syntax, I wonder if it is pm.expect(pm.responseBody.incomeassert).to.eql(null); instead of pm.expect(pm.responseBody.incomeassert()).to.eql(null);
I’m trying to come up with a way to check if the parse succeeded and if the script was able to assign a non-null value to a variable.
If it was not possible to assign a non-zero value to a variable, then I would like to receive information about this.
Now I can only check the status of the code, but there are times when the system returns an empty value (just closed tag), because there was no receipt for the object.
Here my typical script when im trying to query some info about obj in systems
pm.test("Regnum assert", function () {
postman.setNextRequest(null);
pm.response.to.have.status(200);
postman.setNextRequest();
var responseJson = xml2Json(responseBody);
console.log(responseJson);
var Regnum = responseJson['soap:Envelope']['soap:Body']['QueryStatus']['SummaryList']['Summary']['registrationNumber'];
pm.collectionVariables.set("Regnum ", Regnum );
});
var responseJson1 = xml2Json(pm.response.text());
console.log(responseJson1);
pm.expect(pm.response.text()).to.include("sometext or tagname");
pm.expect(pm.response.text()).to.include(pm.variables.replaceIn('{{somevalue}}'));
If you want to write tests for xml response, you should convert response to text, then you will able to search for the necessary words/tags/data in the text.
If you want to parse xml response and write data to variables, it will be easier for you to convert response to json.