Skip to content

armgit / mocha

Public Imported from GitHub
0

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

Use the cursor.CR() function in place of '\r' in the reporters.

Nathan Rajlich255d460fb437
diff --git a/lib/reporters/list.js b/lib/reporters/list.js
index 60acc4fd..0f2943d9 100644
--- a/lib/reporters/list.js
+++ b/lib/reporters/list.js
@@ -4,6 +4,7 @@
*/
var Base = require('./base')
+ , cursor = Base.cursor
, color = Base.color;
/**
@@ -44,11 +45,13 @@ function List(runner) {
var fmt = color('checkmark', ' ✓')
+ color('pass', ' %s: ')
+ color(test.speed, '%dms');
- console.log('\r' + fmt, test.fullTitle(), test.duration);
+ cursor.CR();
+ console.log(fmt, test.fullTitle(), test.duration);
});
runner.on('fail', function(test, err){
- console.log('\r' + color('fail', ' %d) %s'), n++, test.fullTitle());
+ cursor.CR();
+ console.log(color('fail', ' %d) %s'), n++, test.fullTitle());
});
runner.on('end', self.epilogue.bind(self));
@@ -58,4 +61,4 @@ function List(runner) {
* Inherit from `Base.prototype`.
*/
-List.prototype.__proto__ = Base.prototype;
\ No newline at end of file
+List.prototype.__proto__ = Base.prototype;
diff --git a/lib/reporters/progress.js b/lib/reporters/progress.js
index 423c9825..311c8b7b 100644
--- a/lib/reporters/progress.js
+++ b/lib/reporters/progress.js
@@ -58,7 +58,8 @@ function Progress(runner, options) {
, n = width * percent | 0
, i = width - n;
- process.stdout.write('\r\033[J');
+ cursor.CR();
+ process.stdout.write('\033[J');
process.stdout.write(color('progress', ' ' + options.open));
process.stdout.write(Array(n).join(options.complete));
process.stdout.write(Array(i).join(options.incomplete));
@@ -81,4 +82,4 @@ function Progress(runner, options) {
* Inherit from `Base.prototype`.
*/
-Progress.prototype.__proto__ = Base.prototype;
\ No newline at end of file
+Progress.prototype.__proto__ = Base.prototype;
diff --git a/lib/reporters/spec.js b/lib/reporters/spec.js
index 5af9642d..390bf9d4 100644
--- a/lib/reporters/spec.js
+++ b/lib/reporters/spec.js
@@ -4,6 +4,7 @@
*/
var Base = require('./base')
+ , cursor = Base.cursor
, color = Base.color;
/**
@@ -59,18 +60,21 @@ function Spec(runner) {
var fmt = indent()
+ color('checkmark', ' ✓')
+ color('pass', ' %s ');
- console.log('\r' + fmt, test.title);
+ cursor.CR();
+ console.log(fmt, test.title);
} else {
var fmt = indent()
+ color('checkmark', ' ✓')
+ color('pass', ' %s ')
+ color(test.speed, '(%dms)');
- console.log('\r' + fmt, test.title, test.duration);
+ cursor.CR();
+ console.log(fmt, test.title, test.duration);
}
});
runner.on('fail', function(test, err){
- console.log('\r' + indent() + color('fail', ' %d) %s'), n++, test.title);
+ cursor.CR();
+ console.log(indent() + color('fail', ' %d) %s'), n++, test.title);
});
runner.on('end', self.epilogue.bind(self));
@@ -80,4 +84,4 @@ function Spec(runner) {
* Inherit from `Base.prototype`.
*/
-Spec.prototype.__proto__ = Base.prototype;
\ No newline at end of file
+Spec.prototype.__proto__ = Base.prototype;