Verify the response:
pm.test(âdata verificationnâ, function () {
let jsonData = pm.response.json();
pm.expect(jsonData.earnings.commissionLastWeek.amount).to.eql(Number(data.earningscommissionLastWeekamount));
});
I would try to better isolate the source of the error you are getting. It seems to me that the error is originating in the first expectation. (the one with .to.include), not in the second one, as you seem to think.
It looks like projectedPremierVolumeThisMonth is not an array or similar.
Could you drill down the assertion block one by one and get identify which response data gives the actual problem. If you want to validate the first part of the value as you described in your verification part. Try to store in a variable and split using dot operator then you can assert with your expected value. thanks
@vdespa@allenheltondev Any suggestion?
How I can verify in other ways?
How I can write value with decimal operator permanently in .csv file without format always?
I already tried with casting and and it got failed as above error message.
Yes, those are not exact same due to some restriction from .csv file hence we are using include/match chai assertion for verification.
Anyway I already gave casting script for them as above, Do you have any other solution.
Same an issue. @allenheltondev You might be missing something but let me give something important in nutshell. Lets connect over screen share if possible, If required.
Response contain value for earnings.commissionLastWeek.amount as â13490064.0000046â
where as In .csv file I am putting same value as â13490064.0000046â but unfortunately file save value only integer value(13490064), It will not include decimal part.
To overcome, In assertion we give âincludeâ but its throw error
pm.expect(jsonData.earnings.commissionLastWeek.amount).to.include(commissionLastWeek);
Where as If we give equal/eql assertion type, Throw the correct error as
pm.expect(jsonData.earnings.commissionLastWeek.amount).to.equal(commissionLastWeek);
Thanks @allenheltondev, Here is the my type of script and working fine without issues. pm.expect(Math.trunc(jsonData.earnings.commissionLastWeek.amount)).to.eql(data.earningscommissionLastWeekamount);
I will mark as solution but just for leaning and out of the postman related question who I can make .csv file data(100.45) with precision?
Issues with .csv file: In .csv file I am putting value as â13490064.0000046â but unfortunately file save value only integer value(13490064), It will not include decimal part.
Thought we can format it but once you close the file, values will reset and again no precision there.
Any suggestions?
It might have something to do with the program youâre using to manipulate the csv (like excel). But you could certainly try to surround the number in quotes to preserve the number as text, then you wouldnât get any data loss.
As @allenheltondev noted, this is likely due to the client you are using to view the csv data. CSV file type is somewhat primitive (although very useful), meaning there is no context behind the data inferred. The clients used infer that, and likely in this case, Excel infers it to be an integer.
Best bet it so use quotes and they should be inferred as strings, leaving you with the precision you are looking for. This should work but again its dependent on the client being used to consume the csv. Though if youâre looking to do any numeric manipulations on code, you will have to cast it to the appropriate type (float, double, etc).