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ā€™])