-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test script passes in Postman but fails in Newman with Numbers in double quotes #1100
Comments
Body Response: Where ever numbers are coming with double quotes are failing. |
@kunagpal : Is there any progress on this? |
This isn't being worked on right now, but I'll update this thread once work starts. 😄 |
Hi Newman Team, If I load a CSV data file like this:
I expect the ValueA to be treated as a number and give 5, and ValueB to be treated as a string and give 05. Instead, they are both treated as numbers and return 5. This works correctly in Postman itself, and I believe this bug was introduced by the fix for issue #1054. Please help us to resolve this. We are building an automation suite based on Postman/Newman and much of our data uses IDs that start with leading zeros. Thank you |
Hi Team, For example, we are seeing that all three of these IDs are treated as the same number in Newman:
This is causing the wrong data to be retrieved by the API. The difficulty for us is that it's impossible to check for the issue pragmatically and correct it in the code because it occurs during the CSV load, so the data is lost even before it even gets to our JS code. Thank you for you help! |
Hi Team, Is there any movement on this issue? Like some of the users above, my company uses a lot of numeric strings. As mentioned before, these work fine in collection runner but fail in Newman. |
Hi Team |
@vijaygroovey I have not heared anything. But as a work around, I added a tilde (~) in front of each number in my csv. This way, Newman reads it as a string and I wrote a function to strip the ~ from it and store it into an environment variable with different name, so there's no chance of using the wrong value. Example:
|
This issue is with the underlying @biplabpramanik007 @TheCoderGuyVlad @davefreireich @vijaygroovey as a temporary fix you can quote the numbers within single quotes ( |
Thanks @saswatds ! And thanks for the single quote suggestion! |
@biplabpramanik007 @TheCoderGuyVlad @davefreireich @vijaygroovey a fix has been added in #1609 which will be rolled out with the v4 release. You can test this using v4.0.0-beta.2. |
@biplabpramanik007 @TheCoderGuyVlad @davefreireich @vijaygroovey This has been fixed in Newman v4.0.0. |
-->OS: Windows 10
--> CLI
-->Expected Behaviour: The test should pass in newman with numbers in double quotes. Numbers without quotes in response are working but when numbers are coming in double quotes its not working.
Test Scripts:
var jsonData = JSON.parse(responseBody);
tests["Last4Digit of Car Passed"] = jsonData.vehicles[0].last4VinDigits===data.last;
console.log(responseBody);
Data File:
plate,cust,manufacturerYear,product,last
AMT210,45156841,1987,FORD,"7747"
Command:
newman -run Testrunner.json -e environment.json -d data.csv
Result:
newman
NewRunner
→ CheckRego
GET https://api-it1.testservicensw.net/v1/me/registrations/roads/reports/eligibility?plateNumber=AMT210 [200 OK, 967B, 611ms]
┌
│ '{"vehicles":[{"vehicleID":"66027145","vehicleModel":{
│ "manufacturer":{"code":"FORD","description":"FORD"},"m
│ anufactureYear":1987,"manufactureMonth":1,"model":{"co
│ de":"MONDEO","description":"MONDEO"},"bodyShape":{"cod
│ e":"SED","description":"SEDAN"}},"last4VinDigits":"774
│ 7","primaryColour":{"code":"20","description":"BLACK"}
│ ,"plate":{"plateNumber":"AMT210","plateType":"O"}}],"c
│ ustomer":{"customerName":{"givenName":"SNSW","familyNa
│ me":"DATA","customerNameText":"Snsw DATA"}},"messages"
│ :[{"code":"SUCCESS","message":"Success","severity":"SU
│ CCESS","category":"BUSINESS"}]}'
└
√ Body matches vehicleID
√ Status code is 200
√ vehicle id value
√ Plate Number matches
√ Manufaturer Passed
┌─────────────────────────┬──────────┬──────────┐
│ │ executed │ failed │
├─────────────────────────┼──────────┼──────────┤
│ iterations │ 1 │ 0 │
├─────────────────────────┼──────────┼──────────┤
│ requests │ 1 │ 0 │
├─────────────────────────┼──────────┼──────────┤
│ test-scripts │ 1 │ 0 │
├─────────────────────────┼──────────┼──────────┤
│ prerequest-scripts │ 0 │ 0 │
├─────────────────────────┼──────────┼──────────┤
│ assertions │ 6 │ 1 │
├─────────────────────────┴──────────┴──────────┤
│ total run duration: 751ms │
├───────────────────────────────────────────────┤
│ total data received: 326B (approx) │
├───────────────────────────────────────────────┤
│ average response time: 611ms │
└───────────────────────────────────────────────┘
failure detail
at assertion:6 in test-script
inside "CheckRego"
The text was updated successfully, but these errors were encountered: