To access the summary you can modify your function like so : var newman = require('newman') Ĭollection: require('./C1.postman_collection. You need to write a console.log(responseBody) / JSON.parse(responseBody) inside the test scripts for each request in the collection and then on running the collection using newman, each responseBody for each request will be logged out / parsed as per your needs. What you're trying to do is basically log the response of the request(s). The summary argument in the callback contains the whole summary for the run and you can follow the documentation if you want to make use of that summary. run function's callback is called with two parameters that are err and summary Thus, logging / parsing the responseBody in a callback function is incorrect (Stating this logically).Īs per the Newman Docs it states that the. You're running the whole collection (which is a series of requests being ran all together by Newman) How to get whole html or json repsonse of an URL using Newman APIĪ postman collection is a collection of requests. Neither console.log or JSON.parse appear to be doing the trick because responseBody doesn't appear to be defined from the start call n to pass `options` object and wait for callbackĬollection: require('./pathto/my_coll.postman_collection.json'), $ node script.js var newman = require('newman') // require newman in your project I keep encountering an error of ReferenceError: responseBody is not definedĪny help on this matter would be really appreciated. I would like to add wait in between the first and second newman tests. Second one is junit report using the same collection. First one uses html extra report and creates results in HTML format using hbs template. Package.json has 2 newman executions using the same collections. I don't care how the response body is returned I just don't want to open postman if I don't have to. Hi All My postman collection tests are executed using newman. In postman the call works, and returns a response body token that I need access to. I am attempting to run a script.js with newman from a locally saved postman collection.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |