I have response in array and need to check that value for “color” = value {{$color}} from environment variable only for that object where “id” = value {{$id}} from environment variable.
My response looks like:
I need to check, that for object which has “id”= “string2”, color is “color”: “352f58”
How I found the problem:
let jsonData = pm.response.json();
let connectionId = pm.environment.get(“connectionId”);
let color = pm.environment.get(“color”);
pm.test(“Color is changed”, function () {
jsonData.forEach(function(element)){
if jsonData.id = connectionId
pm.test("Color is changed", function () {
pm.expect(jsonData.color).to.eql(pm.environment.get("color"))
})
}
})
I receive an error in console, test does not work.
How can I fixed it?