Not getting value of variable in test result

pm.test(“Verify enabled field”, function () {
pm.response.to.have.status(200);
pm.expect(jsonData.data[0].isEnabled, "isEnabled value is not correct for {{$(jsonData.data[0].sku)}}" ).to.equal(pm.environment.get(“isEnabled”));

        }); 

I am not getting value of jsonData.data[0].sku in results if it fails. Could you please let me know what wrong am I doing?

Hey @svarshney2311

I replied on the GH Issue you raised but not sure if you saw this yet.

I think something like this will work - I’m not clear on your response body so i’m unsure about the different references you have:

pm.test("Verify enabled field", function () {
    pm.response.to.have.status(200);
    pm.expect(jsonData.data[0].isEnabled, `isEnabled value is not correct for ${(jsonData.data[0].sku)}`).to.equal(pm.environment.get("isEnabled"));
});
2 Likes

Thanks Danny. It worked the way I wanted.

1 Like