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?