Hi I have a test which should test if returned id exists and if its integer. But I am getting this error which does not make sense to me. AssertionError: expected 104 to be an integer
var id = data.id ? data.id : null;
pm.test('Required id test', function() {
pm.expect(id).to.be.an('integer');
});
All of that magic and functionality within the pm.expect() function comes directly from the Chai Js library.
Having a number keyword is how the creators/maintainers of that library have implemented that functionality. I wouldn’t really be able to provide any reasoning behind that decision.
When hit with issues like this, Postman is using JavaScript under the hood so searching the web including “JavaScript” in the search terms will usually give you a few hits and point you in the right direction.
Number.isInteger() is the recommended way of checking if a number is an integer.
I like the custom message that you included in that article. I’ll have to remember that exists so you don’t just get a bland “expected false to be true” message.