Skip to content

armgit / mocha

Public Imported from GitHub
0

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

add tab, CR, LF to error diffs for now

TJ Holowaychuk5e695f868002
diff --git a/lib/reporters/base.js b/lib/reporters/base.js
index 1cbc00f0..493ca317 100644
--- a/lib/reporters/base.js
+++ b/lib/reporters/base.js
@@ -333,7 +333,10 @@ function pad(str, len) {
function errorDiff(err, type) {
return diff['diff' + type](err.actual, err.expected).map(function(str){
- if (/^(\n+)$/.test(str.value)) str.value = Array(++RegExp.$1.length).join('<newline>');
+ str.value = str.value
+ .replace(/\t/g, '<tab>')
+ .replace(/\r/g, '<CR>')
+ .replace(/\n/g, '<LF>\n');
if (str.added) return colorLines('diff added', str.value);
if (str.removed) return colorLines('diff removed', str.value);
return str.value;