I would like to test that the number of decimal places returned by a field in the response is equal to 5. Not sure if using regex is the best solution but this is what I have so far which does not seem to work:
pm.test("Check number of decimal place of my_variable field"), () => {
_.each(jsonData, (results) => {
if results.my_variable !== null){
pm.expect(results.my_variable).to.match(/\d{1}.\d{5}/);
}
})
}
Below is a sample response. Note that the test passes even if it does not match the regex
{
"my_variable": "0.0198970000000000",
}
Thanks!