Testcase is Pass for Invalid condition on forEach loop

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)
});
});

My issue is resolved. I changed the assertion to pm.expect(element.AccountID).is.not.oneOf([null, undefined]);

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.