I’m not sure why you would need to use forEach()
here - Is it returning an array of objects?
Wouldn’t that work?
pm.test("Validate response code 400", function () {
pm.response.to.have.status(400);
});
const jsonData = pm.response.json();
pm.test("Check response description is as defined", () => {
pm.expect(jsonData).to.be.an("object");
pm.expect(jsonData.length).to.be.greaterThan(0);
pm.expect(jsonData).to.have.property("description");
pm.expect(jsonData.description).to.be.a("string");
pm.expect(jsonData.description).to.equal("Cannot create 'xxx' without 'xxx'");
});