Skip to content

armgit / mocha

Public Imported from GitHub
0

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

always display error stack

Tj Holowaychuk97a93f21b39c
diff --git a/lib/reporters/html.js b/lib/reporters/html.js
index 1560dbeb..8c7215aa 100644
--- a/lib/reporters/html.js
+++ b/lib/reporters/html.js
@@ -67,8 +67,13 @@ function HTML(runner) {
stat.find('.duration em').text((ms / 1000).toFixed(2));
// test
- var str = test.passed ? 'pass' : 'fail';
- var el = $('<div class="test ' + str + '"><h2>' + test.title + '</h2></div>')
+ if (test.passed) {
+ var el = $('<div class="test pass"><h2>' + test.title + '</h2></div>')
+ } else {
+ var el = $('<div class="test fail"><h2>' + test.title + '</h2></div>');
+ var err = $('<pre class="error">' + test.err.stack + '</pre>');
+ el.append(err);
+ }
// code
var pre = $('<pre><code>' + clean(test.fn.toString()) + '</code></pre>');
diff --git a/mocha.js b/mocha.js
index 70256bc6..8f26a661 100644
--- a/mocha.js
+++ b/mocha.js
@@ -808,8 +808,13 @@ function HTML(runner) {
stat.find('.duration em').text((ms / 1000).toFixed(2));
// test
- var str = test.passed ? 'pass' : 'fail';
- var el = $('<div class="test ' + str + '"><h2>' + test.title + '</h2></div>')
+ if (test.passed) {
+ var el = $('<div class="test pass"><h2>' + test.title + '</h2></div>')
+ } else {
+ var el = $('<div class="test fail"><h2>' + test.title + '</h2></div>');
+ var err = $('<pre class="error">' + test.err.stack + '</pre>');
+ el.append(err);
+ }
// code
var pre = $('<pre><code>' + clean(test.fn.toString()) + '</code></pre>');
diff --git a/test/browser/style.css b/test/browser/style.css
index 558db6d0..56ee0f46 100644
--- a/test/browser/style.css
+++ b/test/browser/style.css
@@ -55,8 +55,14 @@ h2 {
color: #c00;
}
+.test pre.error {
+ display: block;
+ color: #c00;
+}
+
.test pre {
display: none;
+ font: 12px/1.5 monaco, monospace;
margin: 5px;
padding: 15px;
border: 1px solid #eee;
@@ -66,7 +72,6 @@ h2 {
}
.test:hover pre {
- font: 12px/1.5 monaco, monospace;
display: inline-block;
}