Currently, Postman saves all environment variables as strings.
This is really annoying when asserting values in a response and comparing it with the saved Postman Variable.
Assuming I have saved a Postman Env Variable that was an integer. called ‘customerReturnId’.
In the below test, I want to confirm the correct value is returned in the response by comparing it to my saved variable.
Notice how I have to parseInt() the postman variable to convert it from a string BACK to an int, in order to prevent the test from failing.
const body = JSON.parse(responseBody);
pm.test("Expects the 'customer_return_id' to be present", function() {
pm.expect(body.data).to.have.property("customer_return_id");
const customerReturnId = parseInt(pm.environment.get("customerReturnId"));
pm.expect(body.data.customer_return_id).to.equal(customerReturnId);
});