Skip to content

Instantly share code, notes, and snippets.

@toopay
Created October 22, 2018 14:22
Show Gist options
  • Save toopay/de0d5f34e31cdf58ae81191aeac0ea20 to your computer and use it in GitHub Desktop.
Save toopay/de0d5f34e31cdf58ae81191aeac0ea20 to your computer and use it in GitHub Desktop.
newman-reporter-curl.js
var CurlReporter;
/**
* Simple reporter that generates a curl statement
*
* @param {Object} newman - A run object with event handler specification methods.
* @param {Function} newman.on - An event setter method that provides hooks for reporting collection run progress.
* @param {Object} reporterOptions - A set of reporter specific run options.
* @param {Object} options - A set of generic collection run options.
* @returns {*}
*/
CurlReporter = function (newman, reporterOptions, options) {
if (options.silent || reporterOptions.silent) {
return;
}
newman.on('start', function (err, o) {
if (err) { return; }
// Can start opening a file here
});
newman.on('beforeRequest', function (err, o) {
if (err || !o.request) { return; }
console.log('curl -X %s %s ', o.request.method, o.request.url.toString());
});
newman.on('done', function () {
// Can closing the file here
});
};
CurlReporter.prototype.dominant = true;
module.exports = CurlReporter;
@toopay
Copy link
Author

toopay commented Oct 22, 2018

Install this file as npm, and then ran :

newman run collection.json --no-color --global-var "fakerServer=http://localhost:3000/"  --environment="env-dev.json" -r curl

Sample output would be :

toopay@Trusty-Lenovo-G40-70:/PROJECT/kwri/contact-microservice/tests/postman$ newman run collection.json --no-color --global-var "fakerServer=http://localhost:3000/"  --environment="env-dev.json" -r curl
curl -X POST https://dev-kong.command-api.kw.com/login 
curl -X GET http://localhost:3000/?property=name.findName 
curl -X GET http://localhost:3000/?property=address.secondaryAddress 
curl -X POST https://dev-kong.command-api.kw.com/contacts 
curl -X GET https://dev-kong.command-api.kw.com/contacts 
curl -X GET https://dev-kong.command-api.kw.com/contacts?sort=-id&page[limit]=1&include=emails,addresses,company&fields[persons]=last_name&filter[last_name][like]=%Pacocha 
curl -X GET https://dev-kong.command-api.kw.com/contacts/41089?include=emails,addresses,company&fields[persons]=last_name 
curl -X GET http://localhost:3000/?property=name.findName 
curl -X PATCH https://dev-kong.command-api.kw.com/contacts/41089 
curl -X GET http://localhost:3000/?property=image.imageUrl 
curl -X POST https://dev-kong.command-api.kw.com/contacts/41089/profile-photo 
curl -X DELETE https://dev-kong.command-api.kw.com/contacts/41089 
curl -X GET http://localhost:3000/?property=name.firstName 
curl -X GET http://localhost:3000/?property=name.firstName 
curl -X GET http://localhost:3000/?property=name.lastName 
curl -X GET http://localhost:3000/?property=date.past 
curl -X GET http://localhost:3000/?property=lorem.sentence 
curl -X GET http://localhost:3000/?property=address.streetAddress 
curl -X GET http://localhost:3000/?property=address.secondaryAddress 
curl -X GET http://localhost:3000/?property=internet.email 
curl -X GET http://localhost:3000/?property=address.streetAddress 
curl -X GET http://localhost:3000/?property=address.streetName 
curl -X GET http://localhost:3000/?property=address.city 
curl -X GET http://localhost:3000/?property=address.state 
curl -X GET http://localhost:3000/?property=address.country 
curl -X GET http://localhost:3000/?property=address.zipCode 
curl -X GET http://localhost:3000/?property=phone.phoneNumber 
curl -X GET http://localhost:3000/?property=lorem.words 
curl -X POST https://dev-kong.command-api.kw.com/contacts/multiple-store 
curl -X DELETE https://dev-kong.command-api.kw.com/contacts 
curl -X PATCH https://dev-kong.command-api.kw.com/contacts 
curl -X DELETE https://dev-kong.command-api.kw.com/contacts 
curl -X GET https://dev-kong.command-api.kw.com/contacts/export 
curl -X GET https://dev-kong.command-api.kw.com/contacts?archieved=true&sort=-id 
curl -X GET https://dev-kong.command-api.kw.com/contacts?withArchived=true 
curl -X POST https://dev-kong.command-api.kw.com/contacts/multiple-store 
curl -X PATCH https://dev-kong.command-api.kw.com/contacts/41092 
curl -X DELETE https://dev-kong.command-api.kw.com/contacts 
curl -X GET http://localhost:3000/?property=name.findName&locale=us 
curl -X GET http://localhost:3000/?property=lorem.words 
curl -X GET http://localhost:3000/?property=lorem.words 
curl -X POST https://dev-kong.command-api.kw.com/contacts/templates 
curl -X GET https://dev-kong.command-api.kw.com/contacts/templates/359 
curl -X GET https://dev-kong.command-api.kw.com/contacts/templates?fields[templates]=name 
curl -X GET http://localhost:3000/?property=lorem.words 
curl -X PATCH https://dev-kong.command-api.kw.com/contacts/templates/359 
curl -X DELETE https://dev-kong.command-api.kw.com/contacts/templates/359 
curl -X POST https://dev-kong.command-api.kw.com/contacts/multiple-store 
curl -X POST https://dev-kong.command-api.kw.com/contacts/phones 
curl -X GET https://dev-kong.command-api.kw.com/contacts/phones/20796?include=contact 
curl -X GET https://dev-kong.command-api.kw.com/contacts/phones?fields[phones]=number&filter[number][like]=202-555-1664 
curl -X PATCH https://dev-kong.command-api.kw.com/contacts/phones/20796 
curl -X DELETE https://dev-kong.command-api.kw.com/contacts/phones/20796 
curl -X DELETE https://dev-kong.command-api.kw.com/contacts 
curl -X POST https://dev-kong.command-api.kw.com/contacts/multiple-store 
curl -X GET http://localhost:3000/?property=internet.email 
curl -X POST https://dev-kong.command-api.kw.com/contacts/emails 
curl -X GET https://dev-kong.command-api.kw.com/contacts/emails/23512?include=contact 
curl -X GET https://dev-kong.command-api.kw.com/contacts/emails?fields[emails]=email&filter[email][is]=Noemy15@gmail.com&include=contact 
curl -X GET http://localhost:3000/?property=internet.email 
curl -X PATCH https://dev-kong.command-api.kw.com/contacts/emails/23512 
curl -X DELETE https://dev-kong.command-api.kw.com/contacts/emails/23512 
curl -X POST https://dev-kong.command-api.kw.com/contacts/emails 
curl -X DELETE https://dev-kong.command-api.kw.com/contacts/emails 
curl -X DELETE https://dev-kong.command-api.kw.com/contacts 
curl -X GET http://localhost:3000/?property=name.firstName 
curl -X POST https://dev-kong.command-api.kw.com/contacts/multiple-store 
curl -X POST https://dev-kong.command-api.kw.com/contacts/social-accounts 
curl -X GET https://dev-kong.command-api.kw.com/contacts/social-accounts/2745?include=contact 
curl -X GET https://dev-kong.command-api.kw.com/contacts/social-accounts?fields[social-accounts]=identifier&filter[identifierl][is]=Georgianna&include=contact 
curl -X GET http://localhost:3000/?property=name.firstName 
curl -X PATCH https://dev-kong.command-api.kw.com/contacts/social-accounts/2745 
curl -X DELETE https://dev-kong.command-api.kw.com/contacts/social-accounts/2745 
curl -X DELETE https://dev-kong.command-api.kw.com/contacts 
curl -X GET http://localhost:3000/?property=address.streetAddress 
curl -X GET http://localhost:3000/?property=address.streetName 
curl -X GET http://localhost:3000/?property=address.city 
curl -X GET http://localhost:3000/?property=address.state 
curl -X GET http://localhost:3000/?property=address.country 
curl -X GET http://localhost:3000/?property=address.zipCode 
curl -X GET http://localhost:3000/?property=address.latitude 
curl -X GET http://localhost:3000/?property=address.longitude 
curl -X POST https://dev-kong.command-api.kw.com/contacts/multiple-store 
curl -X POST https://dev-kong.command-api.kw.com/contacts/addresses 
curl -X GET https://dev-kong.command-api.kw.com/contacts/addresses/6986?include=contacts 
curl -X GET https://dev-kong.command-api.kw.com/contacts/addresses?fields[addresses]=address_line_1&filter[address_line_1][is]=846 Wilbert Mountain&include=contacts 
curl -X GET http://localhost:3000/?property=address.streetAddress 
curl -X PATCH https://dev-kong.command-api.kw.com/contacts/addresses/6986 
curl -X DELETE https://dev-kong.command-api.kw.com/contacts/addresses/6986 
curl -X DELETE https://dev-kong.command-api.kw.com/contacts 
curl -X GET http://localhost:3000/?property=lorem.words 
curl -X GET http://localhost:3000/?property=address.streetAddress 
curl -X POST https://dev-kong.command-api.kw.com/contacts/companies 
curl -X GET https://dev-kong.command-api.kw.com/contacts/companies/2241 
curl -X GET https://dev-kong.command-api.kw.com/contacts/companies 
curl -X PATCH https://dev-kong.command-api.kw.com/contacts/companies/2241 
curl -X DELETE https://dev-kong.command-api.kw.com/contacts/companies/2241 
curl -X POST https://dev-kong.command-api.kw.com/contacts/multiple-store 
curl -X POST https://dev-kong.command-api.kw.com/contacts/addresses 
curl -X POST https://dev-kong.command-api.kw.com/contacts/purchase-dates 
curl -X GET https://dev-kong.command-api.kw.com/contacts/purchase-dates/480 
curl -X POST https://dev-kong.command-api.kw.com/contacts/multiple-store 
curl -X GET https://dev-kong.command-api.kw.com/contacts/purchase-dates?filter[contact_id][is]=41104 
curl -X PATCH https://dev-kong.command-api.kw.com/contacts/purchase-dates/480 
curl -X DELETE https://dev-kong.command-api.kw.com/contacts/purchase-dates/480 
curl -X POST https://dev-kong.command-api.kw.com/contacts/purchase-dates 
curl -X DELETE https://dev-kong.command-api.kw.com/contacts/purchase-dates 
curl -X POST https://dev-kong.command-api.kw.com/contacts/multiple-store 
curl -X GET http://localhost:3000/?property=lorem.words 
curl -X POST https://dev-kong.command-api.kw.com/contacts/family 
curl -X GET https://dev-kong.command-api.kw.com/contacts/family/646 
curl -X GET http://localhost:3000/?property=lorem.words 
curl -X PATCH https://dev-kong.command-api.kw.com/contacts/family/646 
curl -X DELETE https://dev-kong.command-api.kw.com/contacts/family/646 
curl -X DELETE https://dev-kong.command-api.kw.com/contacts/family 
curl -X DELETE https://dev-kong.command-api.kw.com/contacts 
curl -X POST https://dev-kong.command-api.kw.com/contacts/custom-fields 
curl -X GET https://dev-kong.command-api.kw.com/contacts/custom-fields/1290 
curl -X GET https://dev-kong.command-api.kw.com/contacts/custom-fields 
curl -X PATCH https://dev-kong.command-api.kw.com/contacts/custom-fields/1290 
curl -X DELETE https://dev-kong.command-api.kw.com/contacts/custom-fields/1290 
curl -X GET http://localhost:3000/?property=lorem.words 
curl -X POST https://dev-kong.command-api.kw.com/contacts/custom-field-values 
curl -X GET https://dev-kong.command-api.kw.com/contacts/custom-field-values/777 
curl -X GET https://dev-kong.command-api.kw.com/contacts/custom-field-values 
curl -X GET http://localhost:3000/?property=lorem.words 
curl -X PATCH https://dev-kong.command-api.kw.com/contacts/custom-field-values/777 
curl -X POST https://dev-kong.command-api.kw.com/contacts/custom-field-values 
curl -X DELETE https://dev-kong.command-api.kw.com/contacts/custom-field-values/777 
curl -X POST https://dev-kong.command-api.kw.com/contacts/multiple-store 
curl -X GET http://localhost:3000/?property=lorem.sentence 
curl -X POST https://dev-kong.command-api.kw.com/contacts/object-custom-fields 
curl -X GET https://dev-kong.command-api.kw.com/contacts/object-custom-fields/{{OBJECT_CUSTOM_FIELDE_ID}} 
curl -X GET https://dev-kong.command-api.kw.com/contacts/object-custom-fields 
curl -X GET http://localhost:3000/?property=lorem.sentence 
curl -X PATCH https://dev-kong.command-api.kw.com/contacts/object-custom-fields/{{OBJECT_CUSTOM_FIELDE_ID}} 
curl -X DELETE https://dev-kong.command-api.kw.com/contacts/object-custom-fields/{{OBJECT_CUSTOM_FIELDE_ID}} 
curl -X DELETE https://dev-kong.command-api.kw.com/contacts 
curl -X GET http://localhost:3000/?property=lorem.words 
curl -X POST https://dev-kong.command-api.kw.com/contacts/system-metas 
curl -X GET https://dev-kong.command-api.kw.com/contacts/system-metas/126 
curl -X GET https://dev-kong.command-api.kw.com/contacts/system-metas 
curl -X GET http://localhost:3000/?property=lorem.words 
curl -X PATCH https://dev-kong.command-api.kw.com/contacts/system-metas/126 
curl -X DELETE https://dev-kong.command-api.kw.com/contacts/system-metas/126 
curl -X DELETE https://dev-kong.command-api.kw.com/contacts 
curl -X POST https://dev-kong.command-api.kw.com/contacts/multiple-store 
curl -X POST https://dev-kong.command-api.kw.com/contacts/interactions?forceSyncQueue=1 
curl -X GET https://dev-kong.command-api.kw.com/contacts/41110/timeline?filter[timeline_type][is]=4 
curl -X POST https://dev-kong.command-api.kw.com/contacts/interactions?forceSyncQueue=1 
curl -X GET https://dev-kong.command-api.kw.com/contacts/41110/timeline?filter[timeline_type][is]=9 
curl -X POST https://dev-kong.command-api.kw.com/contacts/interactions?forceSyncQueue=1 
curl -X GET https://dev-kong.command-api.kw.com/contacts/41110/timeline?filter[timeline_type][is]=12 
curl -X PATCH https://dev-kong.command-api.kw.com/contacts/41110?forceSyncQueue=1 
curl -X GET https://dev-kong.command-api.kw.com/contacts/41110/timeline?filter[timeline_type][is]=8 
curl -X PATCH https://dev-kong.command-api.kw.com/contacts/41110?forceSyncQueue=1 
curl -X GET https://dev-kong.command-api.kw.com/contacts/41110/timeline?filter[timeline_type][is]=5 

@renatovieiradesouza
Copy link

How to install this js file with npm?

@Mumeii
Copy link

Mumeii commented Oct 6, 2022

@renatovieiradesouza : Hi

For having to deal with the awkwardness of the way to install a newman-reporter, here is a a small advise about how to do it :

to use a newman reporter called newman-reporter-XXXX you have to :

  • install this reporter globally, I.E. -g option while installing it with npm
  • reference to it on the newman command line with the -r XXXX option

Here are the usual suspects of troubles you could encounter. For example, with the previous example :

  • if the package name is not starting with newman-reporter (for exemple simply XXXX without the required prefix), newman will fail to find the module called newman-reporter-XXXX, as the one installed globally simply be XXXX
  • on the other hand, if you specify the full package name with the -r option, such as -r newman-reporter-XXXX, newman will fail to find the module called newman-reporter-newman-reporter-XXXX ...

Hope this will help someone 😋

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment