mocha 1.8.1 → 1.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/runner.js CHANGED
@@ -1,4 +1,3 @@
1
-
2
1
  /**
3
2
  * Module dependencies.
4
3
  */
@@ -8,8 +7,7 @@ var EventEmitter = require('events').EventEmitter
8
7
  , Test = require('./test')
9
8
  , utils = require('./utils')
10
9
  , filter = utils.filter
11
- , keys = utils.keys
12
- , noop = function(){};
10
+ , keys = utils.keys;
13
11
 
14
12
  /**
15
13
  * Non-enumerable globals.
@@ -45,6 +43,7 @@ module.exports = Runner;
45
43
  * - `hook end` (hook) hook complete
46
44
  * - `pass` (test) test passed
47
45
  * - `fail` (test, err) test failed
46
+ * - `pending` (test) test pending
48
47
  *
49
48
  * @api public
50
49
  */
@@ -61,6 +60,15 @@ function Runner(suite) {
61
60
  this.globals(this.globalProps().concat(['errno']));
62
61
  }
63
62
 
63
+ /**
64
+ * Wrapper for setImmediate, process.nextTick, or browser polyfill.
65
+ *
66
+ * @param {Function} fn
67
+ * @api private
68
+ */
69
+
70
+ Runner.immediately = global.setImmediate || process.nextTick;
71
+
64
72
  /**
65
73
  * Inherit from `EventEmitter.prototype`.
66
74
  */
@@ -185,7 +193,7 @@ Runner.prototype.fail = function(test, err){
185
193
  if ('string' == typeof err) {
186
194
  err = new Error('the string "' + err + '" was thrown, throw an Error :)');
187
195
  }
188
-
196
+
189
197
  this.emit('fail', test, err);
190
198
  };
191
199
 
@@ -224,6 +232,7 @@ Runner.prototype.hook = function(name, fn){
224
232
  function next(i) {
225
233
  var hook = hooks[i];
226
234
  if (!hook) return fn();
235
+ if (self.failures && suite.bail()) return fn();
227
236
  self.currentRunnable = hook;
228
237
 
229
238
  self.emit('hook', hook);
@@ -242,7 +251,7 @@ Runner.prototype.hook = function(name, fn){
242
251
  });
243
252
  }
244
253
 
245
- process.nextTick(function(){
254
+ Runner.immediately(function(){
246
255
  next(0);
247
256
  });
248
257
  };
@@ -485,14 +494,16 @@ Runner.prototype.run = function(fn){
485
494
  var self = this
486
495
  , fn = fn || function(){};
487
496
 
497
+ function uncaught(err){
498
+ self.uncaught(err);
499
+ }
500
+
488
501
  debug('start');
489
502
 
490
503
  // callback
491
504
  this.on('end', function(){
492
505
  debug('end');
493
- process.removeListener('uncaughtException', function(err){
494
- self.uncaught(err);
495
- });
506
+ process.removeListener('uncaughtException', uncaught);
496
507
  fn(self.failures);
497
508
  });
498
509
 
@@ -504,9 +515,7 @@ Runner.prototype.run = function(fn){
504
515
  });
505
516
 
506
517
  // uncaught exception
507
- process.on('uncaughtException', function(err){
508
- self.uncaught(err);
509
- });
518
+ process.on('uncaughtException', uncaught);
510
519
 
511
520
  return this;
512
521
  };
@@ -522,6 +531,8 @@ Runner.prototype.run = function(fn){
522
531
 
523
532
  function filterLeaks(ok, globals) {
524
533
  return filter(globals, function(key){
534
+ // Firefox and Chrome exposes iframes as index inside the window object
535
+ if (/^d+/.test(key)) return false;
525
536
  var matched = filter(ok, function(ok){
526
537
  if (~ok.indexOf('*')) return 0 == key.indexOf(ok.split('*')[0]);
527
538
  // Opera and IE expose global variables for HTML element IDs (issue #243)
package/lib/template.html CHANGED
@@ -3,13 +3,14 @@
3
3
  <head>
4
4
  <title>Mocha</title>
5
5
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
7
  <link rel="stylesheet" href="mocha.css" />
7
8
  </head>
8
9
  <body>
9
10
  <div id="mocha"></div>
10
11
  <script src="mocha.js"></script>
11
12
  <script>mocha.setup('bdd')</script>
12
- <script src="my-tests.js"></script>
13
+ <script src="tests.js"></script>
13
14
  <script>
14
15
  mocha.run();
15
16
  </script>
package/lib/utils.js CHANGED
@@ -63,7 +63,7 @@ exports.indexOf = function(arr, obj, start){
63
63
 
64
64
  /**
65
65
  * Array#reduce (<=IE8)
66
- *
66
+ *
67
67
  * @param {Array} array
68
68
  * @param {Function} fn
69
69
  * @param {Object} initial value
package/mocha.css CHANGED
@@ -1,8 +1,12 @@
1
1
  @charset "utf-8";
2
2
 
3
3
  body {
4
+ margin:0;
5
+ }
6
+
7
+ #mocha {
4
8
  font: 20px/1.5 "Helvetica Neue", Helvetica, Arial, sans-serif;
5
- padding: 60px 50px;
9
+ margin: 60px 50px;
6
10
  }
7
11
 
8
12
  #mocha ul, #mocha li {
@@ -38,7 +42,7 @@ body {
38
42
  font-size: .8em;
39
43
  }
40
44
 
41
- .hidden {
45
+ #mocha .hidden {
42
46
  display: none;
43
47
  }
44
48
 
@@ -59,7 +63,7 @@ body {
59
63
 
60
64
  #mocha .test.pending:hover h2::after {
61
65
  content: '(pending)';
62
- font-family: arial;
66
+ font-family: arial, sans-serif;
63
67
  }
64
68
 
65
69
  #mocha .test.pass.medium .duration {
@@ -185,7 +189,7 @@ body {
185
189
 
186
190
  #mocha-error {
187
191
  color: #c00;
188
- font-size: 1.5 em;
192
+ font-size: 1.5em;
189
193
  font-weight: 100;
190
194
  letter-spacing: 1px;
191
195
  }
@@ -224,8 +228,23 @@ body {
224
228
  padding-top: 11px;
225
229
  }
226
230
 
227
- code .comment { color: #ddd }
228
- code .init { color: #2F6FAD }
229
- code .string { color: #5890AD }
230
- code .keyword { color: #8A6343 }
231
- code .number { color: #2F6FAD }
231
+ #mocha-stats canvas {
232
+ width: 40px;
233
+ height: 40px;
234
+ }
235
+
236
+ #mocha code .comment { color: #ddd }
237
+ #mocha code .init { color: #2F6FAD }
238
+ #mocha code .string { color: #5890AD }
239
+ #mocha code .keyword { color: #8A6343 }
240
+ #mocha code .number { color: #2F6FAD }
241
+
242
+ @media screen and (max-device-width: 480px) {
243
+ #mocha {
244
+ margin: 60px 0px;
245
+ }
246
+
247
+ #mocha #stats {
248
+ position: absolute;
249
+ }
250
+ }