Simon Priet e69a613a37 feat: Created a mini nodeJS server with NewMan for testing without PostMan GUI.
This will mimic a run in a CD/CI environment or docker container.
2021-09-08 14:01:19 +02:00

38 lines
1.1 KiB
JavaScript

var SmileyReporter;
/**
* Fills your collection run (read life) with a bunch of Emojis 😀.
*
* @param {Object} newman - The collection run object with event handling hooks to enable reporting.
* @param {Object} reporterOptions - A set of reporter specific run options.
* @param {Object} options - A set of generic collection run options.
* @returns {*}
*/
SmileyReporter = function (newman, reporterOptions, options) {
if (options.silent || reporterOptions.silent) {
return;
}
var fails = {},
noteFailure;
noteFailure = function (err, args) {
err && (fails[args.cursor.ref] = true);
};
newman.on('script', noteFailure);
newman.on('request', noteFailure);
newman.on('assertion', noteFailure);
newman.on('item', function (err, args) {
process.stdout.write((err || fails[args.cursor.ref]) ? '😢 ' : '😀 ');
});
newman.on('done', function (err) {
console.info((err || Object.keys(fails).length) ? ' 😭' : ' 😍');
});
};
SmileyReporter.prototype.dominant = true;
module.exports = SmileyReporter;