Friends, From this situation I am taking the following error response:
FAIL Check value is either 1 or 2 | TypeError: Cannot read properties of undefined (reading 'gender')
FAIL Check value fullName | TypeError: Cannot read properties of undefined (reading 'fullName')
const response = pm.response.json();
pm.test("Check value is either 1 or 2", function() {
pm.expect(response.naturalPerson.gender).to.be.oneOf([1, 2]);
});
pm.test("Check value fullName", function() {
pm.expect(response.naturalPerson.fullName).to.eql("Bia Teste");
});
{
"party":{
"partyId":1555,
"partyExternalId":"0",
"partyType":1,
"partyIdentification":{
"partyIdentificationType":1,
"documentNumber":"16250560017"
},
"naturalPerson":{
"fullName":"Bia Teste",
"gender":2,
"pronoun":1,
"maritalStatus":{
"maritalStatusSituation":2
},
"filiation":{
"fullNameFirstFiliation":"Ana Souza",
"firstFiliationType":1,
"fullNameSecondFiliation":"João Souza",
"secondFiliationType":2
},
You forgot the party
in your JSON path, the following will do:
pm.test("Check value is either 1 or 2", function() {
pm.expect(response.party.naturalPerson.gender).to.be.oneOf([1, 2]);
});
pm.test("Check value fullName", function() {
pm.expect(response.party.naturalPerson.fullName).to.eql("Bia Teste");
});