☕️ Classic, reliable, trusted test framework for Node.js and the browser
nicer error
Tj Holowaychuk09c82304db44
diff --git a/lib/reporters/html.js b/lib/reporters/html.jsindex 0b01f749..e31f3048 100644--- a/lib/reporters/html.js+++ b/lib/reporters/html.js@@ -40,7 +40,7 @@ function HTML(runner) {, stack = [root], stat = $(statsTemplate).appendTo(root);- if (!root.length) error('#mocha div missing, add it to your document');+ if (root.length) return error('#mocha div missing, add it to your document');runner.on('suite', function(suite){if (suite.root) return;@@ -95,8 +95,7 @@ function HTML(runner) {}function error(msg) {- // TODO: nicer- throw new Error(msg);+ $('<div id="error">' + msg + '</div>').appendTo('body');}/**diff --git a/mocha.js b/mocha.jsindex 5e65f939..cb575d96 100644--- a/mocha.js+++ b/mocha.js@@ -781,7 +781,7 @@ function HTML(runner) {, stack = [root], stat = $(statsTemplate).appendTo(root);- if (!root.length) error('#mocha div missing, add it to your document');+ if (root.length) return error('#mocha div missing, add it to your document');runner.on('suite', function(suite){if (suite.root) return;@@ -836,8 +836,7 @@ function HTML(runner) {}function error(msg) {- // TODO: nicer- throw new Error(msg);+ $('<div id="error">' + msg + '</div>').appendTo('body');}/**diff --git a/test/browser/style.css b/test/browser/style.cssindex 0779d386..046657e0 100644--- a/test/browser/style.css+++ b/test/browser/style.css@@ -71,6 +71,19 @@ h2 {-webkit-box-shadow: 0 1px 3px #eee;}+#error {+ color: #c00;+ font-size: 1.5 em;+ font-weight: 100;+ letter-spacing: 1px;+}++#error::before {+ content: 'Error:';+ margin-right: 5px;+ font-weight: 200;+}+#stats {position: fixed;top: 15px;