Skip to content

armgit / mocha

Public Imported from GitHub
0

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

build

TJ Holowaychuk750b66910cf4
diff --git a/mocha.js b/mocha.js
index 52b7bf4d..10b2509c 100644
--- a/mocha.js
+++ b/mocha.js
@@ -1642,7 +1642,7 @@ function HTML(runner) {
var el = fragment('<div class="test pass pending"><h2>%e</h2></div>', test.title);
} else {
var el = fragment('<div class="test fail"><h2>%e</h2></div>', test.title);
- var str = test.err.stack || test.err;
+ var str = test.err.stack || test.err.toString();
// FF / Opera do not add the message
if (!~str.indexOf(test.err.message)) {
@@ -1653,6 +1653,11 @@ function HTML(runner) {
// 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 + ")";
+ }
+
el.appendChild(fragment('<pre class="error">%e</pre>', str));
}
@@ -4028,7 +4033,7 @@ window.mocha = require('mocha');
}
/**
- * Setup mocha with the give setting options.
+ * Setup mocha with the given setting options.
*/
mocha.setup = function(opts){