var newman = require('newman'),
collectionUrl = "https://raw.githubusercontent.com/postmanlabs/newman/develop/examples/sample-collection.json",
uniqueUrls = {}; // here we will maintain the unique URLs
// call newman.run to pass `options` object and listen to events
newman.run({ collection: collectionUrl })
.on('request', function (err, args) {
if (err) { return; }
var url = args.request.url.toString();
// store unique URLs and the count of times they were
// requested.
uniqueUrls[url] ?
(uniqueUrls[url] += 1) : (uniqueUrls[url] = 1);
})
.once('done', await function (err) {
console.log("List of unique URLs in this collection:");
// list all unique URLs
Object.keys(uniqueUrls).forEach(function (url) {
console.log(`${uniqueUrls[url]} occurrence(s): ${url}`);
});
});