Skip to content

armgit / mocha

Public Imported from GitHub
0

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

strip msg from stack trace

Tj Holowaychuk301f83d72c34
diff --git a/lib/reporters/base.js b/lib/reporters/base.js
index 260e3bda..b4db7849 100644
--- a/lib/reporters/base.js
+++ b/lib/reporters/base.js
@@ -93,14 +93,16 @@ exports.list = function(failures){
+ color('error message', '%s')
+ color('error stack', '\n%s\n');
- // stack
+ // msg
var stack = test.err.stack
- .replace(/^/gm, ' ')
- .split('\n')
- .slice(1)
- .join('\n');
+ , i = stack.indexOf('at')
+ , msg = stack.slice(0, i);
- console.log(fmt, i, test.title, test.err.message, stack);
+ // indent stack trace without msg
+ stack = stack.slice(i)
+ .replace(/^/gm, ' ');
+
+ console.log(fmt, i, test.title, msg, stack);
});
};