Skip to content

armgit / mocha

Public Imported from GitHub
0

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

Add source line to html report for Safari.

Tyson Tated1debbad614b
diff --git a/lib/reporters/html.js b/lib/reporters/html.js
index 750c8112..2fb16440 100644
--- a/lib/reporters/html.js
+++ b/lib/reporters/html.js
@@ -110,6 +110,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));
}