My question:
I created tests for my API under Windows10 in Postman.
The tests are running great in Postman on Windows and directly on the Linux-Server with Newman.
The only thing which is making trouble is the Newman-Test in Windows. It gives me a “TypeError in test-script”. The reason: I have a variable which I want to convert into a number, but newman can’t handle it. I tried the follwing:
- let limit = pm.variables.get(‘myVar’).toNumber();
Result:
TypeError in test-script
- let limit = Number(pm.variables.get(‘myVar’));
Result:
NaN
- let limit = parseInt(pm.variables.get(‘myVar’),10);
Result:
NaN
- let limit = +pm.variables.get(‘myVar’);
Result:
NaN
- let limit = Math.floor(pm.variables.get(‘myVar’));
Result:
NaN
- let limit = pm.environment.get(‘myVar’);
Result:
undefined
(but I defined it in the environment to test this)
- let limit = 1000;
Result:
1000
Only idea #7 works.
I really don’t understand what is going on there. I thought it could be a Newman-Bug, but it’s working great on Linux with Newman.
Does anybody has an idea?