0

My postman tests runs well and passes when i run the collection in postman. I've exported and saved my Postman collection.json into a folder, but when running the json file using Newman, all tests fails. some of the errors are:-

  • getaddrinfo ENOTFOUND {{baseurl}} at request
  • expected { Object (id, _details, ...) } to have property 'code' at assertion:0 in test-script
  • Unexpected token u in JSON at position 0 at test-script
Christian Baumann
  • 3,188
  • 3
  • 20
  • 37
  • Did you also export your environment? – Christian Baumann Aug 30 '21 at 13:32
  • @ChristianBaumann No sure i did that. It's my first time to do this. –  Sep 01 '21 at 14:02
  • Especially the `getaddrinfo ENOTFOUND {{baseurl}}` appears like an evnironment variable is missing/ not set. – Christian Baumann Sep 01 '21 at 14:14
  • @ChristianBaumann, do i export and save the environment as a json format in the same folder as the collections? –  Sep 01 '21 at 15:30
  • Can be same or different folder, you pass in the path via the `-e, --environment [file|URL]` switch, see https://learning.postman.com/docs/running-collections/using-newman-cli/command-line-integration-with-newman/#options – Christian Baumann Sep 01 '21 at 16:20

2 Answers2

0

Export your environment file as json. Pass it in the newman command line as "-e" parameter.

$ newman run yourcollectionfile.json -e yourenvironmentfile.json

When running postman, you also have to specify the environment file you are using. Documentation for this is found here: https://learning.postman.com/docs/running-collections/using-newman-cli/command-line-integration-with-newman/

tgtgtg
  • 51
  • 3
0

you have to use a local variable in your exported collection . i was facing the simliar issue made all variables as local and my test passed.

mohd Bilal
  • 61
  • 1
  • 4