I have a accounts object which is an array in response. While trying to validate for the array fields I am seeing the test script is Passed even for incorrect condition. Can someone please guide what is wrong here in the script for forEach loop?
Sample Response:
"data": {
"accounts": [
{
"accountId": "c3d7d3f1-eb51-47cd-82f7-a4d30315d6e7",
"accountNumber": "TESTACCT-15",
"accountValue": 11400,
"pctCash": 100,
"accountName": "Test Account 15",
"cashBalance": 11400,
"newMoney": 11400
}
]
}
Even if i provide the condition as below the test is a Pass
pm.test(“Validate required fields are not null”, function () {
jsonData.data.accounts.forEach(function(account) {
pm.expect(account.dummy!=null)
});
});