Test producing a false pass when response body has a json value equal to something

I’m new to Postman so still learning the ropes.

I have a response body which contains the following:

"acccIndex": 13640,

"acccAcIndex": 1496270,

"acccDateCreated": "2012-01-13T16:11:35.277",

"acccDateUpdated": "2012-03-22T11:31:14.357",

"acccNotes": ""


In the test section I’m trying to write a test to check that acccAcIndex is present, I’m not bothered about a value just that that acccAcIndex is present.

Every test I’ve created seems to pass but then when I purposefully make it fail it still passes (add in an extra x after: acccAcIndexx.

I’ve tried the following:
Note these all purposefully should fail but they pass.

Any help / guidance appreciated.

Hello @farahziya

I’ve never used hasOwnProperty :sweat_smile:, but you can use the following example to check if the property is returning :point_down:

pm.test("Account field exists #test2", function() {



Hope this helps :grin:

Hey @farahziya, Welcome to the community :partying_face: !

I think this solution is similar to what you are looking for. Just tune it according to your requirements.

Hope it helps,
Good luck!

1 Like

That works, thanks :slight_smile:

1 Like

Hey, thanks :slight_smile:
That works, although it doesn’t quite flow naturally for me so for now I’ll stick to the first one (cmnazario). I will keep yours though as it may prove useful later

1 Like