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