mocha 3.0.2 → 3.2.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.
Files changed (53) hide show
  1. package/CHANGELOG.md +103 -0
  2. package/LICENSE +1 -1
  3. package/README.md +2 -2
  4. package/bin/_mocha +170 -104
  5. package/bin/mocha +22 -13
  6. package/bin/options.js +7 -5
  7. package/browser-entry.js +43 -22
  8. package/lib/browser/.eslintrc.yaml +4 -0
  9. package/lib/browser/debug.js +6 -3
  10. package/lib/browser/events.js +11 -9
  11. package/lib/browser/progress.js +9 -7
  12. package/lib/browser/tty.js +4 -2
  13. package/lib/context.js +11 -9
  14. package/lib/hook.js +4 -2
  15. package/lib/interfaces/bdd.js +11 -9
  16. package/lib/interfaces/common.js +16 -14
  17. package/lib/interfaces/exports.js +4 -2
  18. package/lib/interfaces/index.js +2 -0
  19. package/lib/interfaces/qunit.js +12 -8
  20. package/lib/interfaces/tdd.js +9 -7
  21. package/lib/mocha.js +36 -34
  22. package/lib/ms.js +12 -10
  23. package/lib/pending.js +2 -1
  24. package/lib/reporters/base.js +52 -50
  25. package/lib/reporters/doc.js +8 -6
  26. package/lib/reporters/dot.js +9 -7
  27. package/lib/reporters/html.js +32 -30
  28. package/lib/reporters/index.js +2 -0
  29. package/lib/reporters/json-stream.js +8 -6
  30. package/lib/reporters/json.js +11 -9
  31. package/lib/reporters/landing.js +8 -6
  32. package/lib/reporters/list.js +13 -11
  33. package/lib/reporters/markdown.js +12 -10
  34. package/lib/reporters/min.js +4 -2
  35. package/lib/reporters/nyan.js +22 -20
  36. package/lib/reporters/progress.js +7 -5
  37. package/lib/reporters/spec.js +17 -15
  38. package/lib/reporters/tap.js +10 -8
  39. package/lib/reporters/xunit.js +14 -12
  40. package/lib/runnable.js +43 -32
  41. package/lib/runner.js +78 -63
  42. package/lib/suite.js +24 -22
  43. package/lib/test.js +4 -2
  44. package/lib/utils.js +115 -90
  45. package/mocha.js +1185 -800
  46. package/package.json +9 -2
  47. package/lib/interfaces/bdd.js.orig +0 -118
  48. package/lib/mocha.js.orig +0 -532
  49. package/lib/runnable.js.orig +0 -378
  50. package/lib/runner.js.orig +0 -934
  51. package/lib/suite.js.orig +0 -418
  52. package/lib/test.js.orig +0 -52
  53. package/lib/utils.js.orig +0 -758
package/lib/runner.js CHANGED
@@ -1,3 +1,5 @@
1
+ 'use strict';
2
+
1
3
  /**
2
4
  * Module dependencies.
3
5
  */
@@ -61,7 +63,7 @@ module.exports = Runner;
61
63
  * @param {boolean} [delay] Whether or not to delay execution of root suite
62
64
  * until ready.
63
65
  */
64
- function Runner(suite, delay) {
66
+ function Runner (suite, delay) {
65
67
  var self = this;
66
68
  this._globals = [];
67
69
  this._abort = false;
@@ -70,10 +72,10 @@ function Runner(suite, delay) {
70
72
  this.started = false;
71
73
  this.total = suite.total();
72
74
  this.failures = 0;
73
- this.on('test end', function(test) {
75
+ this.on('test end', function (test) {
74
76
  self.checkGlobals(test);
75
77
  });
76
- this.on('hook end', function(hook) {
78
+ this.on('hook end', function (hook) {
77
79
  self.checkGlobals(hook);
78
80
  });
79
81
  this._defaultGrep = /.*/;
@@ -106,7 +108,7 @@ inherits(Runner, EventEmitter);
106
108
  * @param {boolean} invert
107
109
  * @return {Runner} Runner instance.
108
110
  */
109
- Runner.prototype.grep = function(re, invert) {
111
+ Runner.prototype.grep = function (re, invert) {
110
112
  debug('grep %s', re);
111
113
  this._grep = re;
112
114
  this._invert = invert;
@@ -124,11 +126,11 @@ Runner.prototype.grep = function(re, invert) {
124
126
  * @param {Suite} suite
125
127
  * @return {number}
126
128
  */
127
- Runner.prototype.grepTotal = function(suite) {
129
+ Runner.prototype.grepTotal = function (suite) {
128
130
  var self = this;
129
131
  var total = 0;
130
132
 
131
- suite.eachTest(function(test) {
133
+ suite.eachTest(function (test) {
132
134
  var match = self._grep.test(test.fullTitle());
133
135
  if (self._invert) {
134
136
  match = !match;
@@ -147,7 +149,7 @@ Runner.prototype.grepTotal = function(suite) {
147
149
  * @return {Array}
148
150
  * @api private
149
151
  */
150
- Runner.prototype.globalProps = function() {
152
+ Runner.prototype.globalProps = function () {
151
153
  var props = keys(global);
152
154
 
153
155
  // non-enumerables
@@ -170,7 +172,7 @@ Runner.prototype.globalProps = function() {
170
172
  * @param {Array} arr
171
173
  * @return {Runner} Runner instance.
172
174
  */
173
- Runner.prototype.globals = function(arr) {
175
+ Runner.prototype.globals = function (arr) {
174
176
  if (!arguments.length) {
175
177
  return this._globals;
176
178
  }
@@ -184,7 +186,7 @@ Runner.prototype.globals = function(arr) {
184
186
  *
185
187
  * @api private
186
188
  */
187
- Runner.prototype.checkGlobals = function(test) {
189
+ Runner.prototype.checkGlobals = function (test) {
188
190
  if (this.ignoreLeaks) {
189
191
  return;
190
192
  }
@@ -219,7 +221,11 @@ Runner.prototype.checkGlobals = function(test) {
219
221
  * @param {Test} test
220
222
  * @param {Error} err
221
223
  */
222
- Runner.prototype.fail = function(test, err) {
224
+ Runner.prototype.fail = function (test, err) {
225
+ if (test.isPending()) {
226
+ return;
227
+ }
228
+
223
229
  ++this.failures;
224
230
  test.state = 'failed';
225
231
 
@@ -227,9 +233,13 @@ Runner.prototype.fail = function(test, err) {
227
233
  err = new Error('the ' + type(err) + ' ' + stringify(err) + ' was thrown, throw an Error :)');
228
234
  }
229
235
 
230
- err.stack = (this.fullStackTrace || !err.stack)
231
- ? err.stack
232
- : stackFilter(err.stack);
236
+ try {
237
+ err.stack = (this.fullStackTrace || !err.stack)
238
+ ? err.stack
239
+ : stackFilter(err.stack);
240
+ } catch (ignored) {
241
+ // some environments do not take kindly to monkeying with the stack
242
+ }
233
243
 
234
244
  this.emit('fail', test, err);
235
245
  };
@@ -254,7 +264,7 @@ Runner.prototype.fail = function(test, err) {
254
264
  * @param {Hook} hook
255
265
  * @param {Error} err
256
266
  */
257
- Runner.prototype.failHook = function(hook, err) {
267
+ Runner.prototype.failHook = function (hook, err) {
258
268
  if (hook.ctx && hook.ctx.currentTest) {
259
269
  hook.originalTitle = hook.originalTitle || hook.title;
260
270
  hook.title = hook.originalTitle + ' for "' + hook.ctx.currentTest.title + '"';
@@ -274,12 +284,12 @@ Runner.prototype.failHook = function(hook, err) {
274
284
  * @param {Function} fn
275
285
  */
276
286
 
277
- Runner.prototype.hook = function(name, fn) {
287
+ Runner.prototype.hook = function (name, fn) {
278
288
  var suite = this.suite;
279
289
  var hooks = suite['_' + name];
280
290
  var self = this;
281
291
 
282
- function next(i) {
292
+ function next (i) {
283
293
  var hook = hooks[i];
284
294
  if (!hook) {
285
295
  return fn();
@@ -291,12 +301,12 @@ Runner.prototype.hook = function(name, fn) {
291
301
  self.emit('hook', hook);
292
302
 
293
303
  if (!hook.listeners('error').length) {
294
- hook.on('error', function(err) {
304
+ hook.on('error', function (err) {
295
305
  self.failHook(hook, err);
296
306
  });
297
307
  }
298
308
 
299
- hook.run(function(err) {
309
+ hook.run(function (err) {
300
310
  var testError = hook.error();
301
311
  if (testError) {
302
312
  self.fail(self.test, testError);
@@ -306,9 +316,11 @@ Runner.prototype.hook = function(name, fn) {
306
316
  if (name === 'beforeEach' || name === 'afterEach') {
307
317
  self.test.pending = true;
308
318
  } else {
309
- suite.tests.forEach(function(test) {
319
+ utils.forEach(suite.tests, function (test) {
310
320
  test.pending = true;
311
321
  });
322
+ // a pending hook won't be executed twice.
323
+ hook.pending = true;
312
324
  }
313
325
  } else {
314
326
  self.failHook(hook, err);
@@ -323,7 +335,7 @@ Runner.prototype.hook = function(name, fn) {
323
335
  });
324
336
  }
325
337
 
326
- Runner.immediately(function() {
338
+ Runner.immediately(function () {
327
339
  next(0);
328
340
  });
329
341
  };
@@ -337,11 +349,11 @@ Runner.prototype.hook = function(name, fn) {
337
349
  * @param {Array} suites
338
350
  * @param {Function} fn
339
351
  */
340
- Runner.prototype.hooks = function(name, suites, fn) {
352
+ Runner.prototype.hooks = function (name, suites, fn) {
341
353
  var self = this;
342
354
  var orig = this.suite;
343
355
 
344
- function next(suite) {
356
+ function next (suite) {
345
357
  self.suite = suite;
346
358
 
347
359
  if (!suite) {
@@ -349,7 +361,7 @@ Runner.prototype.hooks = function(name, suites, fn) {
349
361
  return fn();
350
362
  }
351
363
 
352
- self.hook(name, function(err) {
364
+ self.hook(name, function (err) {
353
365
  if (err) {
354
366
  var errSuite = self.suite;
355
367
  self.suite = orig;
@@ -370,7 +382,7 @@ Runner.prototype.hooks = function(name, suites, fn) {
370
382
  * @param {Function} fn
371
383
  * @api private
372
384
  */
373
- Runner.prototype.hookUp = function(name, fn) {
385
+ Runner.prototype.hookUp = function (name, fn) {
374
386
  var suites = [this.suite].concat(this.parents()).reverse();
375
387
  this.hooks(name, suites, fn);
376
388
  };
@@ -382,7 +394,7 @@ Runner.prototype.hookUp = function(name, fn) {
382
394
  * @param {Function} fn
383
395
  * @api private
384
396
  */
385
- Runner.prototype.hookDown = function(name, fn) {
397
+ Runner.prototype.hookDown = function (name, fn) {
386
398
  var suites = [this.suite].concat(this.parents());
387
399
  this.hooks(name, suites, fn);
388
400
  };
@@ -394,7 +406,7 @@ Runner.prototype.hookDown = function(name, fn) {
394
406
  * @return {Array}
395
407
  * @api private
396
408
  */
397
- Runner.prototype.parents = function() {
409
+ Runner.prototype.parents = function () {
398
410
  var suite = this.suite;
399
411
  var suites = [];
400
412
  while (suite.parent) {
@@ -410,10 +422,13 @@ Runner.prototype.parents = function() {
410
422
  * @param {Function} fn
411
423
  * @api private
412
424
  */
413
- Runner.prototype.runTest = function(fn) {
425
+ Runner.prototype.runTest = function (fn) {
414
426
  var self = this;
415
427
  var test = this.test;
416
428
 
429
+ if (!test) {
430
+ return;
431
+ }
417
432
  if (this.asyncOnly) {
418
433
  test.asyncOnly = true;
419
434
  }
@@ -423,7 +438,7 @@ Runner.prototype.runTest = function(fn) {
423
438
  return test.run(fn);
424
439
  }
425
440
  try {
426
- test.on('error', function(err) {
441
+ test.on('error', function (err) {
427
442
  self.fail(test, err);
428
443
  });
429
444
  test.run(fn);
@@ -439,12 +454,12 @@ Runner.prototype.runTest = function(fn) {
439
454
  * @param {Suite} suite
440
455
  * @param {Function} fn
441
456
  */
442
- Runner.prototype.runTests = function(suite, fn) {
457
+ Runner.prototype.runTests = function (suite, fn) {
443
458
  var self = this;
444
459
  var tests = suite.tests.slice();
445
460
  var test;
446
461
 
447
- function hookErr(_, errSuite, after) {
462
+ function hookErr (_, errSuite, after) {
448
463
  // before/after Each hook for errSuite failed:
449
464
  var orig = self.suite;
450
465
 
@@ -454,7 +469,7 @@ Runner.prototype.runTests = function(suite, fn) {
454
469
 
455
470
  if (self.suite) {
456
471
  // call hookUp afterEach
457
- self.hookUp('afterEach', function(err2, errSuite2) {
472
+ self.hookUp('afterEach', function (err2, errSuite2) {
458
473
  self.suite = orig;
459
474
  // some hooks may fail even now
460
475
  if (err2) {
@@ -470,7 +485,7 @@ Runner.prototype.runTests = function(suite, fn) {
470
485
  }
471
486
  }
472
487
 
473
- function next(err, errSuite) {
488
+ function next (err, errSuite) {
474
489
  // if we bail after first err
475
490
  if (self.failures && suite._bail) {
476
491
  return fn();
@@ -522,7 +537,7 @@ Runner.prototype.runTests = function(suite, fn) {
522
537
 
523
538
  // execute test and hook(s)
524
539
  self.emit('test', self.test = test);
525
- self.hookDown('beforeEach', function(err, errSuite) {
540
+ self.hookDown('beforeEach', function (err, errSuite) {
526
541
  if (test.isPending()) {
527
542
  self.emit('pending', test);
528
543
  self.emit('test end', test);
@@ -532,7 +547,7 @@ Runner.prototype.runTests = function(suite, fn) {
532
547
  return hookErr(err, errSuite, false);
533
548
  }
534
549
  self.currentRunnable = self.test;
535
- self.runTest(function(err) {
550
+ self.runTest(function (err) {
536
551
  test = self.test;
537
552
  if (err) {
538
553
  var retry = test.currentRetry();
@@ -579,7 +594,7 @@ Runner.prototype.runTests = function(suite, fn) {
579
594
  * @param {Suite} suite
580
595
  * @param {Function} fn
581
596
  */
582
- Runner.prototype.runSuite = function(suite, fn) {
597
+ Runner.prototype.runSuite = function (suite, fn) {
583
598
  var i = 0;
584
599
  var self = this;
585
600
  var total = this.grepTotal(suite);
@@ -593,7 +608,7 @@ Runner.prototype.runSuite = function(suite, fn) {
593
608
 
594
609
  this.emit('suite', this.suite = suite);
595
610
 
596
- function next(errSuite) {
611
+ function next (errSuite) {
597
612
  if (errSuite) {
598
613
  // current suite failed on a hook from errSuite
599
614
  if (errSuite === suite) {
@@ -619,7 +634,7 @@ Runner.prototype.runSuite = function(suite, fn) {
619
634
  // huge recursive loop and thus a maximum call stack error.
620
635
  // See comment in `this.runTests()` for more information.
621
636
  if (self._grep !== self._defaultGrep) {
622
- Runner.immediately(function() {
637
+ Runner.immediately(function () {
623
638
  self.runSuite(curr, next);
624
639
  });
625
640
  } else {
@@ -627,7 +642,7 @@ Runner.prototype.runSuite = function(suite, fn) {
627
642
  }
628
643
  }
629
644
 
630
- function done(errSuite) {
645
+ function done (errSuite) {
631
646
  self.suite = suite;
632
647
  self.nextSuite = next;
633
648
 
@@ -641,7 +656,7 @@ Runner.prototype.runSuite = function(suite, fn) {
641
656
  // remove reference to test
642
657
  delete self.test;
643
658
 
644
- self.hook('afterAll', function() {
659
+ self.hook('afterAll', function () {
645
660
  self.emit('suite end', suite);
646
661
  fn(errSuite);
647
662
  });
@@ -650,7 +665,7 @@ Runner.prototype.runSuite = function(suite, fn) {
650
665
 
651
666
  this.nextSuite = next;
652
667
 
653
- this.hook('beforeAll', function(err) {
668
+ this.hook('beforeAll', function (err) {
654
669
  if (err) {
655
670
  return done();
656
671
  }
@@ -664,9 +679,9 @@ Runner.prototype.runSuite = function(suite, fn) {
664
679
  * @param {Error} err
665
680
  * @api private
666
681
  */
667
- Runner.prototype.uncaught = function(err) {
682
+ Runner.prototype.uncaught = function (err) {
668
683
  if (err) {
669
- debug('uncaught exception %s', err !== function() {
684
+ debug('uncaught exception %s', err !== function () {
670
685
  return this;
671
686
  }.call(err) ? err : (err.message || err));
672
687
  } else {
@@ -695,8 +710,8 @@ Runner.prototype.uncaught = function(err) {
695
710
 
696
711
  runnable.clearTimeout();
697
712
 
698
- // Ignore errors if complete
699
- if (runnable.state) {
713
+ // Ignore errors if complete or pending
714
+ if (runnable.state || runnable.isPending()) {
700
715
  return;
701
716
  }
702
717
  this.fail(runnable, err);
@@ -737,8 +752,8 @@ Runner.prototype.uncaught = function(err) {
737
752
  *
738
753
  * @param {Suite} suite
739
754
  */
740
- function cleanSuiteReferences(suite) {
741
- function cleanArrReferences(arr) {
755
+ function cleanSuiteReferences (suite) {
756
+ function cleanArrReferences (arr) {
742
757
  for (var i = 0; i < arr.length; i++) {
743
758
  delete arr[i].fn;
744
759
  }
@@ -775,7 +790,7 @@ function cleanSuiteReferences(suite) {
775
790
  * @param {Function} fn
776
791
  * @return {Runner} Runner instance.
777
792
  */
778
- Runner.prototype.run = function(fn) {
793
+ Runner.prototype.run = function (fn) {
779
794
  var self = this;
780
795
  var rootSuite = this.suite;
781
796
 
@@ -784,16 +799,16 @@ Runner.prototype.run = function(fn) {
784
799
  filterOnly(rootSuite);
785
800
  }
786
801
 
787
- fn = fn || function() {};
802
+ fn = fn || function () {};
788
803
 
789
- function uncaught(err) {
804
+ function uncaught (err) {
790
805
  self.uncaught(err);
791
806
  }
792
807
 
793
- function start() {
808
+ function start () {
794
809
  self.started = true;
795
810
  self.emit('start');
796
- self.runSuite(rootSuite, function() {
811
+ self.runSuite(rootSuite, function () {
797
812
  debug('finished running');
798
813
  self.emit('end');
799
814
  });
@@ -805,7 +820,7 @@ Runner.prototype.run = function(fn) {
805
820
  this.on('suite end', cleanSuiteReferences);
806
821
 
807
822
  // callback
808
- this.on('end', function() {
823
+ this.on('end', function () {
809
824
  debug('end');
810
825
  process.removeListener('uncaughtException', uncaught);
811
826
  fn(self.failures);
@@ -832,7 +847,7 @@ Runner.prototype.run = function(fn) {
832
847
  * @api public
833
848
  * @return {Runner} Runner instance.
834
849
  */
835
- Runner.prototype.abort = function() {
850
+ Runner.prototype.abort = function () {
836
851
  debug('aborting');
837
852
  this._abort = true;
838
853
 
@@ -846,7 +861,7 @@ Runner.prototype.abort = function() {
846
861
  * @returns {Boolean}
847
862
  * @api private
848
863
  */
849
- function filterOnly(suite) {
864
+ function filterOnly (suite) {
850
865
  if (suite._onlyTests.length) {
851
866
  // If the suite contains `only` tests, run those and ignore any nested suites.
852
867
  suite.tests = suite._onlyTests;
@@ -854,7 +869,7 @@ function filterOnly(suite) {
854
869
  } else {
855
870
  // Otherwise, do not run any of the tests in this suite.
856
871
  suite.tests = [];
857
- suite._onlySuites.forEach(function(onlySuite) {
872
+ utils.forEach(suite._onlySuites, function (onlySuite) {
858
873
  // If there are other `only` tests/suites nested in the current `only` suite, then filter that `only` suite.
859
874
  // Otherwise, all of the tests on this `only` suite should be run, so don't filter it.
860
875
  if (hasOnly(onlySuite)) {
@@ -862,7 +877,7 @@ function filterOnly(suite) {
862
877
  }
863
878
  });
864
879
  // Run the `only` suites, as well as any other suites that have `only` tests/suites as descendants.
865
- suite.suites = filter(suite.suites, function(childSuite) {
880
+ suite.suites = filter(suite.suites, function (childSuite) {
866
881
  return indexOf(suite._onlySuites, childSuite) !== -1 || filterOnly(childSuite);
867
882
  });
868
883
  }
@@ -877,7 +892,7 @@ function filterOnly(suite) {
877
892
  * @returns {Boolean}
878
893
  * @api private
879
894
  */
880
- function hasOnly(suite) {
895
+ function hasOnly (suite) {
881
896
  return suite._onlyTests.length || suite._onlySuites.length || some(suite.suites, hasOnly);
882
897
  }
883
898
 
@@ -889,10 +904,10 @@ function hasOnly(suite) {
889
904
  * @param {Array} globals
890
905
  * @return {Array}
891
906
  */
892
- function filterLeaks(ok, globals) {
893
- return filter(globals, function(key) {
907
+ function filterLeaks (ok, globals) {
908
+ return filter(globals, function (key) {
894
909
  // Firefox and Chrome exposes iframes as index inside the window object
895
- if (/^d+/.test(key)) {
910
+ if (/^\d+/.test(key)) {
896
911
  return false;
897
912
  }
898
913
 
@@ -914,7 +929,7 @@ function filterLeaks(ok, globals) {
914
929
  return false;
915
930
  }
916
931
 
917
- var matched = filter(ok, function(ok) {
932
+ var matched = filter(ok, function (ok) {
918
933
  if (~ok.indexOf('*')) {
919
934
  return key.indexOf(ok.split('*')[0]) === 0;
920
935
  }
@@ -930,10 +945,10 @@ function filterLeaks(ok, globals) {
930
945
  * @return {Array}
931
946
  * @api private
932
947
  */
933
- function extraGlobals() {
948
+ function extraGlobals () {
934
949
  if (typeof process === 'object' && typeof process.version === 'string') {
935
950
  var parts = process.version.split('.');
936
- var nodeVersion = utils.reduce(parts, function(a, v) {
951
+ var nodeVersion = utils.reduce(parts, function (a, v) {
937
952
  return a << 8 | v;
938
953
  });
939
954
 
package/lib/suite.js CHANGED
@@ -1,3 +1,5 @@
1
+ 'use strict';
2
+
1
3
  /**
2
4
  * Module dependencies.
3
5
  */
@@ -25,7 +27,7 @@ exports = module.exports = Suite;
25
27
  * @param {string} title
26
28
  * @return {Suite}
27
29
  */
28
- exports.create = function(parent, title) {
30
+ exports.create = function (parent, title) {
29
31
  var suite = new Suite(title, parent.ctx);
30
32
  suite.parent = parent;
31
33
  title = suite.fullTitle();
@@ -40,12 +42,12 @@ exports.create = function(parent, title) {
40
42
  * @param {string} title
41
43
  * @param {Context} parentContext
42
44
  */
43
- function Suite(title, parentContext) {
45
+ function Suite (title, parentContext) {
44
46
  if (!utils.isString(title)) {
45
47
  throw new Error('Suite `title` should be a "string" but "' + typeof title + '" was given instead.');
46
48
  }
47
49
  this.title = title;
48
- function Context() {}
50
+ function Context () {}
49
51
  Context.prototype = parentContext;
50
52
  this.ctx = new Context();
51
53
  this.suites = [];
@@ -77,7 +79,7 @@ inherits(Suite, EventEmitter);
77
79
  * @api private
78
80
  * @return {Suite}
79
81
  */
80
- Suite.prototype.clone = function() {
82
+ Suite.prototype.clone = function () {
81
83
  var suite = new Suite(this.title);
82
84
  debug('clone');
83
85
  suite.ctx = this.ctx;
@@ -96,7 +98,7 @@ Suite.prototype.clone = function() {
96
98
  * @param {number|string} ms
97
99
  * @return {Suite|number} for chaining
98
100
  */
99
- Suite.prototype.timeout = function(ms) {
101
+ Suite.prototype.timeout = function (ms) {
100
102
  if (!arguments.length) {
101
103
  return this._timeout;
102
104
  }
@@ -118,7 +120,7 @@ Suite.prototype.timeout = function(ms) {
118
120
  * @param {number|string} n
119
121
  * @return {Suite|number} for chaining
120
122
  */
121
- Suite.prototype.retries = function(n) {
123
+ Suite.prototype.retries = function (n) {
122
124
  if (!arguments.length) {
123
125
  return this._retries;
124
126
  }
@@ -134,7 +136,7 @@ Suite.prototype.retries = function(n) {
134
136
  * @param {boolean} enabled
135
137
  * @return {Suite|boolean} self or enabled
136
138
  */
137
- Suite.prototype.enableTimeouts = function(enabled) {
139
+ Suite.prototype.enableTimeouts = function (enabled) {
138
140
  if (!arguments.length) {
139
141
  return this._enableTimeouts;
140
142
  }
@@ -150,7 +152,7 @@ Suite.prototype.enableTimeouts = function(enabled) {
150
152
  * @param {number|string} ms
151
153
  * @return {Suite|number} for chaining
152
154
  */
153
- Suite.prototype.slow = function(ms) {
155
+ Suite.prototype.slow = function (ms) {
154
156
  if (!arguments.length) {
155
157
  return this._slow;
156
158
  }
@@ -169,7 +171,7 @@ Suite.prototype.slow = function(ms) {
169
171
  * @param {boolean} bail
170
172
  * @return {Suite|number} for chaining
171
173
  */
172
- Suite.prototype.bail = function(bail) {
174
+ Suite.prototype.bail = function (bail) {
173
175
  if (!arguments.length) {
174
176
  return this._bail;
175
177
  }
@@ -183,7 +185,7 @@ Suite.prototype.bail = function(bail) {
183
185
  *
184
186
  * @api private
185
187
  */
186
- Suite.prototype.isPending = function() {
188
+ Suite.prototype.isPending = function () {
187
189
  return this.pending || (this.parent && this.parent.isPending());
188
190
  };
189
191
 
@@ -195,7 +197,7 @@ Suite.prototype.isPending = function() {
195
197
  * @param {Function} fn
196
198
  * @return {Suite} for chaining
197
199
  */
198
- Suite.prototype.beforeAll = function(title, fn) {
200
+ Suite.prototype.beforeAll = function (title, fn) {
199
201
  if (this.isPending()) {
200
202
  return this;
201
203
  }
@@ -225,7 +227,7 @@ Suite.prototype.beforeAll = function(title, fn) {
225
227
  * @param {Function} fn
226
228
  * @return {Suite} for chaining
227
229
  */
228
- Suite.prototype.afterAll = function(title, fn) {
230
+ Suite.prototype.afterAll = function (title, fn) {
229
231
  if (this.isPending()) {
230
232
  return this;
231
233
  }
@@ -255,7 +257,7 @@ Suite.prototype.afterAll = function(title, fn) {
255
257
  * @param {Function} fn
256
258
  * @return {Suite} for chaining
257
259
  */
258
- Suite.prototype.beforeEach = function(title, fn) {
260
+ Suite.prototype.beforeEach = function (title, fn) {
259
261
  if (this.isPending()) {
260
262
  return this;
261
263
  }
@@ -285,7 +287,7 @@ Suite.prototype.beforeEach = function(title, fn) {
285
287
  * @param {Function} fn
286
288
  * @return {Suite} for chaining
287
289
  */
288
- Suite.prototype.afterEach = function(title, fn) {
290
+ Suite.prototype.afterEach = function (title, fn) {
289
291
  if (this.isPending()) {
290
292
  return this;
291
293
  }
@@ -314,7 +316,7 @@ Suite.prototype.afterEach = function(title, fn) {
314
316
  * @param {Suite} suite
315
317
  * @return {Suite} for chaining
316
318
  */
317
- Suite.prototype.addSuite = function(suite) {
319
+ Suite.prototype.addSuite = function (suite) {
318
320
  suite.parent = this;
319
321
  suite.timeout(this.timeout());
320
322
  suite.retries(this.retries());
@@ -333,7 +335,7 @@ Suite.prototype.addSuite = function(suite) {
333
335
  * @param {Test} test
334
336
  * @return {Suite} for chaining
335
337
  */
336
- Suite.prototype.addTest = function(test) {
338
+ Suite.prototype.addTest = function (test) {
337
339
  test.parent = this;
338
340
  test.timeout(this.timeout());
339
341
  test.retries(this.retries());
@@ -352,7 +354,7 @@ Suite.prototype.addTest = function(test) {
352
354
  * @api public
353
355
  * @return {string}
354
356
  */
355
- Suite.prototype.fullTitle = function() {
357
+ Suite.prototype.fullTitle = function () {
356
358
  if (this.parent) {
357
359
  var full = this.parent.fullTitle();
358
360
  if (full) {
@@ -368,8 +370,8 @@ Suite.prototype.fullTitle = function() {
368
370
  * @api public
369
371
  * @return {number}
370
372
  */
371
- Suite.prototype.total = function() {
372
- return utils.reduce(this.suites, function(sum, suite) {
373
+ Suite.prototype.total = function () {
374
+ return utils.reduce(this.suites, function (sum, suite) {
373
375
  return sum + suite.total();
374
376
  }, 0) + this.tests.length;
375
377
  };
@@ -382,9 +384,9 @@ Suite.prototype.total = function() {
382
384
  * @param {Function} fn
383
385
  * @return {Suite}
384
386
  */
385
- Suite.prototype.eachTest = function(fn) {
387
+ Suite.prototype.eachTest = function (fn) {
386
388
  utils.forEach(this.tests, fn);
387
- utils.forEach(this.suites, function(suite) {
389
+ utils.forEach(this.suites, function (suite) {
388
390
  suite.eachTest(fn);
389
391
  });
390
392
  return this;
@@ -393,7 +395,7 @@ Suite.prototype.eachTest = function(fn) {
393
395
  /**
394
396
  * This will run the root suite if we happen to be running in delayed mode.
395
397
  */
396
- Suite.prototype.run = function run() {
398
+ Suite.prototype.run = function run () {
397
399
  if (this.root) {
398
400
  this.emit('run');
399
401
  }
package/lib/test.js CHANGED
@@ -1,3 +1,5 @@
1
+ 'use strict';
2
+
1
3
  /**
2
4
  * Module dependencies.
3
5
  */
@@ -19,7 +21,7 @@ module.exports = Test;
19
21
  * @param {String} title
20
22
  * @param {Function} fn
21
23
  */
22
- function Test(title, fn) {
24
+ function Test (title, fn) {
23
25
  if (!isString(title)) {
24
26
  throw new Error('Test `title` should be a "string" but "' + typeof title + '" was given instead.');
25
27
  }
@@ -35,7 +37,7 @@ Test.prototype = create(Runnable.prototype, {
35
37
  constructor: Test
36
38
  });
37
39
 
38
- Test.prototype.clone = function() {
40
+ Test.prototype.clone = function () {
39
41
  var test = new Test(this.title, this.fn);
40
42
  test.timeout(this.timeout());
41
43
  test.slow(this.slow());