Skip to content

armgit / mocha

Public Imported from GitHub
0

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

Minor fix to HTML reporter display.

Gareth Murphycc74060d0503
diff --git a/.gitignore b/.gitignore
index c8eebf36..a53e7e15 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,3 +8,5 @@ _mocha.js
test.js
my-reporter.js
*.sw*
+.idea
+*.iml
diff --git a/lib/reporters/html.js b/lib/reporters/html.js
index 7bdac333..aa3f81a1 100644
--- a/lib/reporters/html.js
+++ b/lib/reporters/html.js
@@ -165,7 +165,7 @@ function HTML(runner, root) {
on(h2, 'click', function(){
pre.style.display = 'none' == pre.style.display
- ? 'inline-block'
+ ? 'block'
: 'none';
});
diff --git a/mocha.css b/mocha.css
index 81adbd52..86f02bc1 100644
--- a/mocha.css
+++ b/mocha.css
@@ -53,6 +53,7 @@ body {
#mocha .test {
margin-left: 15px;
+ overflow: hidden;
}
#mocha .test.pending:hover h2::after {
@@ -129,7 +130,9 @@ body {
}
#mocha .test pre {
- display: inline-block;
+ display: block;
+ float: left;
+ clear: left;
font: 12px/1.5 monaco, monospace;
margin: 5px;
padding: 15px;
diff --git a/mocha.js b/mocha.js
index 8a52a6c6..e13f4648 100644
--- a/mocha.js
+++ b/mocha.js
@@ -1005,6 +1005,7 @@ function image(name) {
* - `reporter` reporter instance, defaults to `mocha.reporters.Dot`
* - `globals` array of accepted globals
* - `timeout` timeout in milliseconds
+ * - `bail` bail on the first test failure
* - `slow` milliseconds to wait before considering a test slow
* - `ignoreLeaks` ignore global leaks
* - `grep` string or regexp to filter tests with
@@ -1020,11 +1021,25 @@ function Mocha(options) {
this.grep(options.grep);
this.suite = new exports.Suite('', new exports.Context);
this.ui(options.ui);
+ this.bail(options.bail);
this.reporter(options.reporter);
if (options.timeout) this.timeout(options.timeout);
if (options.slow) this.slow(options.slow);
}
+/**
+ * Enable or disable bailing on the first failure.
+ *
+ * @param {Boolean} [bail]
+ * @api public
+ */
+
+Mocha.prototype.bail = function(bail){
+ if (null == bail) bail = true;
+ this.suite.bail(bail);
+ return this;
+};
+
/**
* Add test `file`.
*
@@ -1040,7 +1055,7 @@ Mocha.prototype.addFile = function(file){
/**
* Set reporter to `reporter`, defaults to "dot".
*
- * @param {String|Function} reporter name of a reporter or a reporter constructor
+ * @param {String|Function} reporter name or constructor
* @api public
*/
@@ -2073,7 +2088,7 @@ function HTML(runner, root) {
on(h2, 'click', function(){
pre.style.display = 'none' == pre.style.display
- ? 'inline-block'
+ ? 'block'
: 'none';
});