forked from postmanlabs/newman
-
Notifications
You must be signed in to change notification settings - Fork 0
/
emojitrain.js
37 lines (30 loc) · 1.08 KB
/
emojitrain.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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;