Skip to content
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

Newman_undefined_while assertion {"bla":"12332105910416"} like this from JSON #1308

Closed
sebokgabor84 opened this issue Nov 28, 2017 · 2 comments

Comments

@sebokgabor84
Copy link

postman
Version and environment information:
-->

  1. Newman Version (can be found via newman -v): 3.8.3
  2. OS details (type, version, and architecture): Win 10
  3. Are you using Newman as a library, or via the CLI? CLI
  4. Did you encounter this recently, or has this bug always been there: recently
  5. Expected behaviour: instead of undefined, display the and ahandle the value
  6. Command / script used to run Newman:
  • this is a internal API it is not possible to access it from the internet
  1. Sample collection, and auxilliary files (minus the sensitive details):
  2. Screenshots (if applicable):

Situation:
I'm using javascript tests inside the postman and thay will not fail if I execute it in the Runner as you can see in the screenshots, but if I do "newman run ..." in the CLI those tests are failing where newman tries to parse and assert an string that includes number like this:
{ "dispatchingWarehouse": "12", ---> this will fail
"modeMappingResult": "NORMAL" } ---> this not

I'm Using booth old and new test syntax, like this, for booth the behavior is the same as described before:
// instance the variable that holds the hole json esponse
//new Syntax:
var response = pm.response.json();
//old syntax:
//var response = JSON.parse(responseBody);

pm.test("response.dispatchingWarehouse has the correct value", function () {
pm.expect("12").to.eql(response.dispatchingWarehouse);
});

tests ["response.dispatchingWarehouse === 12"] = response.dispatchingWarehouse === "12";
console.log("response.dispatchingWarehouse" + response.dispatchingWarehouse);

I will get from newman if I do a console.log() this:

'response.dispatchingWarehouse undefined'
failure detail
6. AssertionFailure response.dispatchingWarehouse === 12
at assertion:14 in test-script
inside "Hermes_14_with_pre-request_and_tests"

I think the problem is that the "dispatchingWarehouse" is a string but it includes numbers and newman is not able to assert it corretly.
but Postman Runner is able to handle it correct.

newman

@kunagpal
Copy link
Contributor

kunagpal commented Dec 14, 2017

@sebokgabor84 Apologies for the delay. Could you confirm that this behaviour persists with v5.5.0 of the app and Newman v3.9.1 as well? Also, could you add the following statement above your failing tests so that we may get more context?

console.log(pm.response.json(), JSON.parse(responseBody));

@kunagpal
Copy link
Contributor

@sebokgabor84 Closing issue due to inactivity, feel free to revert if you're facing difficulties 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants