Quantcast
Viewing all articles
Browse latest Browse all 3

Answer by Nguyen Quoc Dung for Postman API testing: Unable to assert a value is true

Root cause:Your result is an array but your test is verifying an object. Thus, the postman will throw the exception since it could not compare.

Solution:Use exactly value of an item in the list with if else command to compare.

var arr = pm.response.json(); console.log(arr.length) for (var i = 0; i < arr.length; i++){     if(arr[i].Verified === true){        pm.test("Verified should be true", function () {            pm.expect(arr[i].Verified).to.be.true;        });    }    if(arr[i].Verified === false){        pm.test("Verified should be false", function () {            pm.expect(arr[i].Verified).to.be.false;        });    }     }

Hope it help you.


Viewing all articles
Browse latest Browse all 3

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>