My question:
In a test script I want to validate a response is within a given range, but the problem is the number format is Brazilian, (1,1 instead of 1.1) and is so surrounded by ββ and treated like text.
My Code Attempt:
pm.test(βTest_07 AI % is in range 3,5 to 4,5β, function () {
var annualMode = pm.response.json();
pm.expect(annualMode.recScheme.incPctAnMode).is.lessThan(β5,0β);
Obviously this fails. AssertionError: expected β3,7β to be a number or a date
First you will need to change the string from 1,1 to 1.1. You can do this with simple javascript string replace text.replace(",", β.β).
Then you will need to convert the text to an integer again with simple javascript. parseInt(text).
So your test should look like thisβ¦
pm.test(βTest_07 AI % is in range 3,5 to 4,5β, function () {
var annualMode = pm.response.json();
var value = annualMode.recScheme.incPctAnMode.replace(β,β,β.β) // Setting new value and replacing the character.
pm.expect(parseInt(value)).is.lessThan(5.0);