Assertion without decimals

Your question may already have an answer on the community forum. Please search for related topics, and then read through the guidelines before creating a new topic.

Hi there,

I’m pretty much new to the Postman,
How to do assertion without decimals ?
API and expected value using different types of rounding .

Thanks for your help)

Hi @kostatskay Welcome to the community :slight_smile:

You can try the below approach :slight_smile:

function round_val(value, decimals) {
return Number(Math.round(value+‘e’+decimals)+‘e-’+decimals);
}

var value = -58.6152296;
var rounded_Value = round_val(value, 2);
pm.expect(-58.62).to.eql(rounded_Value );

To have a better understanding on this rounding function, pls check the below link it will helpful

Thank you thats work

1 Like

Good to know that :slight_smile: