Skip to content

armgit / mocha

Public Imported from GitHub
0

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

Fix 1606: fix err handling in IE <= 8 and non-ES5 browsers

Daniel St. Jules537d019be6c0
diff --git a/lib/runner.js b/lib/runner.js
index a985ce97..3199dc92 100644
--- a/lib/runner.js
+++ b/lib/runner.js
@@ -206,7 +206,7 @@ Runner.prototype.fail = function(test, err) {
err = new Error('the ' + type(err) + ' ' + stringify(err) + ' was thrown, throw an Error :)');
}
- err.stack = this.fullStackTrace
+ err.stack = (this.fullStackTrace || !err.stack)
? err.stack
: stackFilter(err.stack);
diff --git a/lib/utils.js b/lib/utils.js
index cb28b674..cef8d0fe 100644
--- a/lib/utils.js
+++ b/lib/utils.js
@@ -677,7 +677,7 @@ exports.stackTraceFilter = function() {
return function(stack) {
stack = stack.split('\n');
- stack = stack.reduce(function (list, line) {
+ stack = exports.reduce(stack, function(list, line) {
if (is.node && (isNodeModule(line) ||
isMochaInternal(line) ||
isNodeInternal(line)))
diff --git a/mocha.js b/mocha.js
index cffddcbc..017b9018 100755
--- a/mocha.js
+++ b/mocha.js
@@ -4779,7 +4779,7 @@ Runner.prototype.fail = function(test, err) {
err = new Error('the ' + type(err) + ' ' + stringify(err) + ' was thrown, throw an Error :)');
}
- err.stack = this.fullStackTrace
+ err.stack = (this.fullStackTrace || !err.stack)
? err.stack
: stackFilter(err.stack);
@@ -6372,7 +6372,7 @@ exports.stackTraceFilter = function() {
return function(stack) {
stack = stack.split('\n');
- stack = stack.reduce(function (list, line) {
+ stack = exports.reduce(stack, function(list, line) {
if (is.node && (isNodeModule(line) ||
isMochaInternal(line) ||
isNodeInternal(line)))