Hi team, below is my response body & test code
I need to verify the “grossPremiumPrice” value from Csv file, since quoatation is missing for the price in the body (659.56,). i am getting an error saying value is mismatch. how to add value in the csv file when there is quoatation is missing in the body value
[
{
“endDate” : “2021-10-01”
grossPremiumPrice" : 659.56,
}]
my request test :
pm.test(“grossPremiumPrice matches the csv value”, function (){
pm.expect(response.grossPremiumPrice).eql(’${pm.iterationData.get(“grossPremiumPrice”)}’);
});
You can use Number function to convert string to number ,
${Number(pm.iterationData.get(“grossPremiumPrice”))}
You can also define the row as number in csv instead of text . This will remove double quotes from number in csv
So that you don’t have to convert the value to number explicitly
. Also note, you can access data values simply as
data['grossPremiumPrice']
instead of pm.iterationData.get
@praveendvd
Hi Praveen, thanks for your reply. i tried that still getting below error.
AssertionError: expecyed 659.56 to deeply equal to ‘659.56’
bpricilla
(Pricilla B)
January 11, 2021, 10:12am
4
Hi @jayaveljays this is because you are comparing a number Vs string.
May be we can try using toString();
something like in the below link:
Hi @gagan.4345 and welcome to the community.
I just took a look at what I think you are attempting to do and it appears to be working for me in both v.7.15 and v.7.16 of the application.
This is a snippet of what I am trying based on what I think you are attempting to do as well:
pm.test("Verify status",function(){
var jsonData = pm.response.json();
pm.expect(jsonData[pm.info.iteration].id.toString()).to.equal(pm.iterationData.get("number").toString());
});
Let me know if this is not t…
1 Like
Please add the code you used , as @bpricilla mentioned it’s comparing number vs string , you haven’t used Number(data[‘grossPremiumPrice’])