postmanlabs / newman

Newman is a command-line collection runner for Postman
https://www.postman.com
Apache License 2.0
6.89k stars 1.17k forks source link

Get the number of requests a collection has from newman using node.js #2799

Open PauSanch opened 3 years ago

PauSanch commented 3 years ago

Hi, I need to get the number of requests a collection has from newman using node.js. I was trying to query 'args' (based on a previous helpful forum answer) but I can't get it...

const newman = require('newman'); newman.run({ collection: ("./PostmanCollections/CollectionName.json"), environment: ("./postmanVariables/A1Env.postman_environment.json"), reporters: "cli", }).on('beforeIteration', (err, args) => { console.log(Count request collecction: ${args. ?¿}) })

I had also thought about using the postman api from postman to count the response json requests, but I think I would have a problem passing that variable to node.js.

Thank you in advance!

shamasis commented 3 years ago

@PauSanch do you really need to do it using newman? What if you loaded the collection before running Newman using postman-collection package? That package has some neat functions.