Skip to content

armgit / mocha

Public Imported from GitHub
0

☕️ Classic, reliable, trusted test framework for Node.js and the browser

Less re-rendering with progress reporter

Connor Dunnda357f886e70
diff --git a/lib/reporters/progress.js b/lib/reporters/progress.js
index 59536386..2debb945 100644
--- a/lib/reporters/progress.js
+++ b/lib/reporters/progress.js
@@ -1,4 +1,3 @@
-
/**
* Module dependencies.
*/
@@ -36,7 +35,8 @@ function Progress(runner, options) {
, width = Base.window.width * .50 | 0
, total = runner.total
, complete = 0
- , max = Math.max;
+ , max = Math.max
+ , lastN = -1;
// default chars
options.open = options.open || '[';
@@ -59,6 +59,12 @@ function Progress(runner, options) {
, n = width * percent | 0
, i = width - n;
+ if (lastN === n && !options.verbose) {
+ // Don't re-render the line if it hasn't changed
+ return;
+ }
+ lastN = n;
+
cursor.CR();
process.stdout.write('\u001b[J');
process.stdout.write(color('progress', ' ' + options.open));