Skip to content

armgit / mocha

Public Imported from GitHub
0

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

Use ul/li elements instead of divs for better copy-and-pasting

Jo Lissd888cc5d202b
diff --git a/lib/reporters/html.js b/lib/reporters/html.js
index 7b3a1c2c..c572205f 100644
--- a/lib/reporters/html.js
+++ b/lib/reporters/html.js
@@ -55,7 +55,8 @@ function HTML(runner) {
, failures = items[2].getElementsByTagName('em')[0]
, duration = items[3].getElementsByTagName('em')[0]
, canvas = stat.getElementsByTagName('canvas')[0]
- , stack = [root]
+ , report = fragment('<ul id="report"></ul>')
+ , stack = [report]
, progress
, ctx
@@ -67,6 +68,7 @@ function HTML(runner) {
if (!root) return error('#mocha div missing, add it to your document');
root.appendChild(stat);
+ root.appendChild(report);
if (progress) progress.size(40);
@@ -74,11 +76,11 @@ function HTML(runner) {
if (suite.root) return;
// suite
- var el = fragment('<div class="suite"><h1>%s</h1></div>', suite.title);
+ var el = fragment('<li class="suite"><h1>%s</h1></li>', suite.title);
// container
stack[0].appendChild(el);
- stack.unshift(document.createElement('div'));
+ stack.unshift(document.createElement('ul'));
el.appendChild(stack[0]);
});
@@ -104,11 +106,11 @@ function HTML(runner) {
// test
if ('passed' == test.state) {
- var el = fragment('<div class="test pass %e"><h2>%e<span class="duration">%ems</span></h2></div>', test.speed, test.title, test.duration);
+ var el = fragment('<li class="test pass %e"><h2>%e<span class="duration">%ems</span></h2></li>', test.speed, test.title, test.duration);
} else if (test.pending) {
- var el = fragment('<div class="test pass pending"><h2>%e</h2></div>', test.title);
+ var el = fragment('<li class="test pass pending"><h2>%e</h2></li>', test.title);
} else {
- var el = fragment('<div class="test fail"><h2>%e</h2></div>', test.title);
+ var el = fragment('<li class="test fail"><h2>%e</h2></li>', test.title);
var str = test.err.stack || test.err.toString();
// FF / Opera do not add the message
diff --git a/mocha.css b/mocha.css
index 350bb6a3..57b0cc8d 100644
--- a/mocha.css
+++ b/mocha.css
@@ -4,6 +4,15 @@ body {
padding: 60px 50px;
}
+#mocha ul, #mocha li {
+ margin: 0;
+ padding: 0;
+}
+
+#mocha ul {
+ list-style: none;
+}
+
#mocha h1, #mocha h2 {
margin: 0;
}