My question: Hey I have a single json object that is returned and I want to be able to test that only the allowed keys are returned in that object, since the data will be different each time I only want to check the keys
Here is the object structure
[
{
“Id”: “75725702-50d8-41a8-963d-4aaaaaaaaaaa”,
“Number”: “500200”,
“Key”: 565465454,
“CategoryId”: 5,
“Option”: “5”,
“CreatedByUserId”: “4127”,
“CreatedDate”: “2020-08-04T00:38:44.988+12:00”,
“LastModifiedByUserId”: “4127”,
“LastModifiedDate”: “2020-08-04T00:38:44.988+12:00”
}
]
Here is the test progress I have so far - not much
pm.test(“Object only contains allowed keys”, () => {
var notesJsonStructure = [‘Id’, ‘Number’, ‘Key’, ‘CategoryId’, ‘Option’, ‘CreatedByUserId’, ‘CreatedDate’, ‘LastModifiedByUserId’, ‘LastModifiedDate’];
var responseObj = pm.response.json();
console.log(responseObj);
_.each(responseObj.response, (item) => {
console.log("Test" + item);
pm.expect(item).to.be.oneOf(notesJsonStructure);
});
});
The line of console.log(“Test” + item); never outputs, so makes me think I am not even hitting that far
Thanks