Expect array property test failing

Here’s my repsonse:

    "data": {
        "statusItem": [
                "ID": 53,
                "cost": 0,
                "discountType": 0,
                "discountValue": 0,
                "flags": 96,
                "flags3": 256,
                "flags4": 0,
                "flags5": 0,
                "futureBreakID": 0,
                "group": 4,
                "highlightColor": 0,
                "inActive": 0,
                "miscItemID": 0,
                "name": "Acct Correction",
                "notificationID": 0,
                "overrideRejectMins": false,
                "POReturnReasonID": 0,
                "priority": 0,
                "rejectStatusMins": 0,
                "seqNum1": 0,
                "seqNum2": 8192,
                "userOrGroupID": 0

I’m trying to expect that just the property ID is in the response.

When I try this:


I get the following error:
Test array properties | AssertionError: object tested must be an array, a map, an object, a set, a string, or a weakset, but object given

This does work


I understand that the array contains objects, but I don’t know how to isolate the property in the object.

Is there a reason that you have gone for include over something else?

Maybe keys or property might work better:


Yeah, I found that like 5 minutes ago…

Is there a way to chain those together so it’s kind of like a poor man’s schema validation?


Is there a way to make this less verbose?

I’ve tried a few different ways with and and it fails.


Have you tried any other method from the chaiJS link, like maybe keys:

Yes I have.
This test


Gives this error

Test array properties | AssertionError: expected { Object (ID, cost, ...) } to have key 'ID'

@robmcec This should work better:

If you want to check all properties, you can use all instead of any.

Is there a way to check only some keys?

Say I want to check for only ID and Cost I do this:


If I do that with this:


It works, but so does this:


Because ID and that’s considered “any”.

Is there a way to say


I know that syntax is wrong, but “any” keys still only helps me if only one is correct. I need a way to list the keys that I want to check on (not all of them, just some) and return a fail if that key\property doesn’t exist.


I haven’t tried but looking at the documentation a combination of include and keys should do the trick! :slightly_smiling_face:

I’d also recommend that cheat-sheet, it came in very handy a few times for me: