Need to verify the body value from CSV file

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’

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:

1 Like

Please add the code you used , as @bpricilla mentioned it’s comparing number vs string , you haven’t used Number(data[‘grossPremiumPrice’])