From c18e1dc87ffc02a5265a4daf67eaaa625d34debb Mon Sep 17 00:00:00 2001 From: Steve Ognibene Date: Wed, 7 Sep 2016 11:29:29 -0400 Subject: [PATCH 1/2] fixes the rendering issue with the Windows console --- lib/reporters/default.js | 9 ++++++--- lib/reporters/nested.js | 6 ++++-- lib/reporters/skip_passed.js | 11 +++++++---- lib/reporters/verbose.js | 13 ++++++++----- 4 files changed, 25 insertions(+), 14 deletions(-) diff --git a/lib/reporters/default.js b/lib/reporters/default.js index 4a13e5a37..1a224f67c 100644 --- a/lib/reporters/default.js +++ b/lib/reporters/default.js @@ -13,7 +13,8 @@ var nodeunit = require('../nodeunit'), fs = require('fs'), track = require('../track'), path = require('path'), - AssertionError = require('../assert').AssertionError; + AssertionError = require('../assert').AssertionError, + process = require('process'); /** * Reporter info string @@ -51,6 +52,8 @@ exports.run = function (files, options, callback) { var assertion_message = function (str) { return options.assertion_prefix + str + options.assertion_suffix; }; + var pass_indicator = process.platform === 'win32' ? '\u221A' : '✔'; + var fail_indicator = process.platform === 'win32' ? '\u00D7' : '✖'; var start = new Date().getTime(); var tracker = track.createTracker(function (tracker) { @@ -80,10 +83,10 @@ exports.run = function (files, options, callback) { tracker.remove(name); if (!assertions.failures()) { - console.log('✔ ' + name); + console.log(pass_indicator + ' ' + name); } else { - console.log(error('✖ ' + name) + '\n'); + console.log(error(fail_indicator + ' ' + name) + '\n'); assertions.forEach(function (a) { if (a.failed()) { a = utils.betterErrors(a); diff --git a/lib/reporters/nested.js b/lib/reporters/nested.js index 62f3d7959..a89318f8f 100644 --- a/lib/reporters/nested.js +++ b/lib/reporters/nested.js @@ -13,7 +13,8 @@ var nodeunit = require('../nodeunit'), fs = require('fs'), track = require('../track'), path = require('path'), - AssertionError = require('../assert').AssertionError; + AssertionError = require('../assert').AssertionError, + process = require('process'); /** * Reporter info string @@ -52,6 +53,7 @@ exports.run = function (files, options, callback) { var assertion_message = function (str) { return options.assertion_prefix + str + options.assertion_suffix; }; + var fail_indicator = process.platform === 'win32' ? '\u00D7' : '✖'; var spaces_per_indent = options.spaces_per_indent || 4; @@ -86,7 +88,7 @@ exports.run = function (files, options, callback) { }; var fail_text = function (txt) { - return bold(error(txt + " (fail) ✖ ")); + return bold(error(txt + " (fail) " + fail_indicator + " ")); }; var status_text = function (txt, status) { diff --git a/lib/reporters/skip_passed.js b/lib/reporters/skip_passed.js index 369022360..235b93e76 100644 --- a/lib/reporters/skip_passed.js +++ b/lib/reporters/skip_passed.js @@ -12,7 +12,8 @@ var nodeunit = require('../nodeunit'), utils = require('../utils'), fs = require('fs'), path = require('path'), - AssertionError = require('../assert').AssertionError; + AssertionError = require('../assert').AssertionError, + process = require('process'); /** * Reporter info string @@ -49,6 +50,8 @@ exports.run = function (files, options, callback) { var assertion_message = function (str) { return options.assertion_prefix + str + options.assertion_suffix; }; + var pass_indicator = process.platform === 'win32' ? '\u221A' : '✔'; + var fail_indicator = process.platform === 'win32' ? '\u00D7' : '✖'; var start = new Date().getTime(); var paths = files.map(function (p) { @@ -63,7 +66,7 @@ exports.run = function (files, options, callback) { }, testDone: function (name, assertions) { if (assertions.failures()) { - console.log(error('✖ ' + name) + '\n'); + console.log(error(fail_indicator + ' ' + name) + '\n'); assertions.forEach(function (a) { if (a.failed()) { a = utils.betterErrors(a); @@ -79,10 +82,10 @@ exports.run = function (files, options, callback) { }, moduleDone: function (name, assertions) { if (!assertions.failures()) { - console.log('✔ all tests passed'); + console.log(pass_indicator + ' all tests passed'); } else { - console.log(error('✖ some tests failed')); + console.log(error(fail_indicator + ' some tests failed')); } }, done: function (assertions) { diff --git a/lib/reporters/verbose.js b/lib/reporters/verbose.js index 347dd1240..4806fb486 100644 --- a/lib/reporters/verbose.js +++ b/lib/reporters/verbose.js @@ -13,7 +13,8 @@ var nodeunit = require('../nodeunit'), fs = require('fs'), track = require('../track'), path = require('path'), - AssertionError = require('../assert').AssertionError; + AssertionError = require('../assert').AssertionError, + process = require('process'); /** * Reporter info string @@ -51,6 +52,8 @@ exports.run = function (files, options, callback) { var assertion_message = function (str) { return options.assertion_prefix + str + options.assertion_suffix; }; + var pass_indicator = process.platform === 'win32' ? '\u221A' : '✔'; + var fail_indicator = process.platform === 'win32' ? '\u00D7' : '✖'; var start = new Date().getTime(); var paths = files.map(function (p) { @@ -82,20 +85,20 @@ exports.run = function (files, options, callback) { tracker.remove(name); if (!assertions.failures()) { - console.log('✔ ' + name); + console.log(pass_indicator + ' ' + name); } else { - console.log(error('✖ ' + name)); + console.log(error(fail_indicator + ' ' + name)); } // verbose so print everything assertions.forEach(function (a) { if (a.failed()) { - console.log(error(' ✖ ' + a.message)); + console.log(error(' ' + fail_indicator + ' ' + a.message)); a = utils.betterErrors(a); console.log(' ' + a.error.stack); } else { - console.log(' ✔ ' + a.message); + console.log(' ' + pass_indicator + ' ' + a.message); } }); }, From f8c6cc3400b528c3a9c77eb469cb0638bc51bf1b Mon Sep 17 00:00:00 2001 From: Steve Ognibene Date: Wed, 7 Sep 2016 12:00:01 -0400 Subject: [PATCH 2/2] requiring process not required. --- lib/reporters/default.js | 3 +-- lib/reporters/nested.js | 3 +-- lib/reporters/skip_passed.js | 3 +-- lib/reporters/verbose.js | 3 +-- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/reporters/default.js b/lib/reporters/default.js index 1a224f67c..4f906f761 100644 --- a/lib/reporters/default.js +++ b/lib/reporters/default.js @@ -13,8 +13,7 @@ var nodeunit = require('../nodeunit'), fs = require('fs'), track = require('../track'), path = require('path'), - AssertionError = require('../assert').AssertionError, - process = require('process'); + AssertionError = require('../assert').AssertionError; /** * Reporter info string diff --git a/lib/reporters/nested.js b/lib/reporters/nested.js index a89318f8f..9c979b6de 100644 --- a/lib/reporters/nested.js +++ b/lib/reporters/nested.js @@ -13,8 +13,7 @@ var nodeunit = require('../nodeunit'), fs = require('fs'), track = require('../track'), path = require('path'), - AssertionError = require('../assert').AssertionError, - process = require('process'); + AssertionError = require('../assert').AssertionError; /** * Reporter info string diff --git a/lib/reporters/skip_passed.js b/lib/reporters/skip_passed.js index 235b93e76..c238a0685 100644 --- a/lib/reporters/skip_passed.js +++ b/lib/reporters/skip_passed.js @@ -12,8 +12,7 @@ var nodeunit = require('../nodeunit'), utils = require('../utils'), fs = require('fs'), path = require('path'), - AssertionError = require('../assert').AssertionError, - process = require('process'); + AssertionError = require('../assert').AssertionError; /** * Reporter info string diff --git a/lib/reporters/verbose.js b/lib/reporters/verbose.js index 4806fb486..1f5595da4 100644 --- a/lib/reporters/verbose.js +++ b/lib/reporters/verbose.js @@ -13,8 +13,7 @@ var nodeunit = require('../nodeunit'), fs = require('fs'), track = require('../track'), path = require('path'), - AssertionError = require('../assert').AssertionError, - process = require('process'); + AssertionError = require('../assert').AssertionError; /** * Reporter info string