How to stream the htmlextra progress bar into a GUI? #406
-
I'm building a GUI in nw.js that executes newman using htmlextra. I'm working on streaming the htmlextra progress bar to the GUI so users can see progress toward completion. I've noticed that while I'm able to stream regular newman output, I can't stream the htmlextra progress bar. Example cmdString:
Example code:
Is the progress bar produced using buffering or something? Any ideas on how to achieve this are appreciated! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hmm...I'm not actually sure how I did that now :D I think I also put it behind a flag because there were some occasions where it was repeated or it didn't render correctly when used with other reporters. I tried to copy what the if (options.displayProgressBar) {
// Add progress feedback for the reporter
if (_.includes(collectionRunOptions.reporters, 'cli') || _.get(collectionRunOptions.reporter, 'cli') || _.includes(collectionRunOptions.reporters, 'json') || _.get(collectionRunOptions.reporter, 'json') || _.includes(collectionRunOptions.reporters, 'progress') || _.get(collectionRunOptions.reporter, 'progress')) {
newman.on('start', function (err, o) {
if (err) { return err; }
});
}
if (!_.includes(collectionRunOptions.reporters, 'progress') && !_.get(collectionRunOptions.reporter, 'progress') && !_.includes(collectionRunOptions.reporters, 'cli') && !_.get(collectionRunOptions.reporter, 'cli') && !_.includes(collectionRunOptions.reporters, 'json') && !_.get(collectionRunOptions.reporter, 'json')) {
var bar = new progress.Bar({
format: 'Newman Run Progress |' + chalk.green('{bar}') + '| {percentage}% || Requests: {value}/{total} || ETA: {eta}s',
barCompleteChar: '\u2588',
barIncompleteChar: '\u2591',
hideCursor: true
});
newman.on('start', function (err, o) {
if (err) { return; }
bar.start(o.cursor.length * o.cursor.cycles, 0);
});
newman.on('item', function () {
bar.increment();
});
newman.on('done', function () {
bar.stop();
});
}
} The progress itself it coming from the Newman side and not my reporter, the report gets generated right at the end of the Newman Run and all the progress is based on how far along the collection run is. |
Beta Was this translation helpful? Give feedback.
Hmm...I'm not actually sure how I did that now :D I think I also put it behind a flag because there were some occasions where it was repeated or it didn't render correctly when used with other reporters.
I tried to copy what the
-r progress
reporter was doing but it's a horrible piece that I'm not proud of.