Created
October 22, 2018 14:22
-
-
Save toopay/de0d5f34e31cdf58ae81191aeac0ea20 to your computer and use it in GitHub Desktop.
newman-reporter-curl.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
@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 callednewman-reporter-XXXX
, as the one installed globally simply beXXXX
- 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 callednewman-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
How to install this js file with npm?