☕️ Classic, reliable, trusted test framework for Node.js and the browser
Split message and stack into two separate variables
Sune Simonsen68ba3b24acb9
diff --git a/lib/reporters/html.js b/lib/reporters/html.jsindex aec2af0d..af383c9b 100644--- a/lib/reporters/html.js+++ b/lib/reporters/html.js@@ -136,23 +136,28 @@ function HTML(runner) {var el = fragment('<li class="test pass pending"><h2>%e</h2></li>', test.title);} else {var el = fragment('<li class="test fail"><h2>%e <a href="%e" class="replay">‣</a></h2></li>', test.title, self.testURL(test));- var str = test.err.stack || test.err.toString();-- // FF / Opera do not add the message- if (!~str.indexOf(test.err.message)) {- str = test.err.message + '\n' + str;- }+ var stackString, // Note: Includes leading newline+ message = test.err.toString();// <=IE7 stringifies to [Object Error]. Since it can be overloaded, we// check for the result of the stringifying.- if ('[object Error]' == str) str = test.err.message;-- // Safari doesn't give you a stack. Let's at least provide a source line.- if (!test.err.stack && test.err.sourceURL && test.err.line !== undefined) {- str += "\n(" + test.err.sourceURL + ":" + test.err.line + ")";+ if ('[object Error]' === message) message = test.err.message;++ if (test.err.stack) {+ var indexOfMessage = test.err.stack.indexOf(test.err.message);+ if (indexOfMessage === -1) {+ stackString = test.err.stack;+ } else {+ stackString = test.err.stack.substr(test.err.message.length + indexOfMessage);+ }+ } else if (test.err.sourceURL && test.err.line !== undefined) {+ // Safari doesn't give you a stack. Let's at least provide a source line.+ stackString = "\n(" + test.err.sourceURL + ":" + test.err.line + ")";}- el.appendChild(fragment('<pre class="error">%e</pre>', str));+ stackString = stackString || '';++ el.appendChild(fragment('<pre class="error">%e%e</pre>', message, stackString));}// toggle code