mocha 1.17.0 → 1.18.2

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/bin/_mocha CHANGED
File without changes
@@ -33,32 +33,32 @@ module.exports = function(suite){
33
33
  * Execute before running tests.
34
34
  */
35
35
 
36
- context.before = function(fn){
37
- suites[0].beforeAll(fn);
36
+ context.before = function(name, fn){
37
+ suites[0].beforeAll(name, fn);
38
38
  };
39
39
 
40
40
  /**
41
41
  * Execute after running tests.
42
42
  */
43
43
 
44
- context.after = function(fn){
45
- suites[0].afterAll(fn);
44
+ context.after = function(name, fn){
45
+ suites[0].afterAll(name, fn);
46
46
  };
47
47
 
48
48
  /**
49
49
  * Execute before each test case.
50
50
  */
51
51
 
52
- context.beforeEach = function(fn){
53
- suites[0].beforeEach(fn);
52
+ context.beforeEach = function(name, fn){
53
+ suites[0].beforeEach(name, fn);
54
54
  };
55
55
 
56
56
  /**
57
57
  * Execute after each test case.
58
58
  */
59
59
 
60
- context.afterEach = function(fn){
61
- suites[0].afterEach(fn);
60
+ context.afterEach = function(name, fn){
61
+ suites[0].afterEach(name, fn);
62
62
  };
63
63
 
64
64
  /**
@@ -41,32 +41,32 @@ module.exports = function(suite){
41
41
  * Execute before running tests.
42
42
  */
43
43
 
44
- context.before = function(fn){
45
- suites[0].beforeAll(fn);
44
+ context.before = function(name, fn){
45
+ suites[0].beforeAll(name, fn);
46
46
  };
47
47
 
48
48
  /**
49
49
  * Execute after running tests.
50
50
  */
51
51
 
52
- context.after = function(fn){
53
- suites[0].afterAll(fn);
52
+ context.after = function(name, fn){
53
+ suites[0].afterAll(name, fn);
54
54
  };
55
55
 
56
56
  /**
57
57
  * Execute before each test case.
58
58
  */
59
59
 
60
- context.beforeEach = function(fn){
61
- suites[0].beforeEach(fn);
60
+ context.beforeEach = function(name, fn){
61
+ suites[0].beforeEach(name, fn);
62
62
  };
63
63
 
64
64
  /**
65
65
  * Execute after each test case.
66
66
  */
67
67
 
68
- context.afterEach = function(fn){
69
- suites[0].afterEach(fn);
68
+ context.afterEach = function(name, fn){
69
+ suites[0].afterEach(name, fn);
70
70
  };
71
71
 
72
72
  /**
@@ -41,32 +41,32 @@ module.exports = function(suite){
41
41
  * Execute before each test case.
42
42
  */
43
43
 
44
- context.setup = function(fn){
45
- suites[0].beforeEach(fn);
44
+ context.setup = function(name, fn){
45
+ suites[0].beforeEach(name, fn);
46
46
  };
47
47
 
48
48
  /**
49
49
  * Execute after each test case.
50
50
  */
51
51
 
52
- context.teardown = function(fn){
53
- suites[0].afterEach(fn);
52
+ context.teardown = function(name, fn){
53
+ suites[0].afterEach(name, fn);
54
54
  };
55
55
 
56
56
  /**
57
57
  * Execute before the suite.
58
58
  */
59
59
 
60
- context.suiteSetup = function(fn){
61
- suites[0].beforeAll(fn);
60
+ context.suiteSetup = function(name, fn){
61
+ suites[0].beforeAll(name, fn);
62
62
  };
63
63
 
64
64
  /**
65
65
  * Execute after the suite.
66
66
  */
67
67
 
68
- context.suiteTeardown = function(fn){
69
- suites[0].afterAll(fn);
68
+ context.suiteTeardown = function(name, fn){
69
+ suites[0].afterAll(name, fn);
70
70
  };
71
71
 
72
72
  /**
package/lib/mocha.js CHANGED
@@ -356,8 +356,9 @@ Mocha.prototype.run = function(fn){
356
356
  if (this.files.length) this.loadFiles();
357
357
  var suite = this.suite;
358
358
  var options = this.options;
359
+ options.files = this.files;
359
360
  var runner = new exports.Runner(suite);
360
- var reporter = new this._reporter(runner);
361
+ var reporter = new this._reporter(runner, options);
361
362
  runner.ignoreLeaks = false !== options.ignoreLeaks;
362
363
  runner.asyncOnly = options.asyncOnly;
363
364
  if (options.grep) runner.grep(options.grep, options.invert);
@@ -188,7 +188,7 @@ exports.list = function(failures){
188
188
  if ('string' == typeof actual && 'string' == typeof expected) {
189
189
  fmt = color('error title', ' %s) %s:\n%s') + color('error stack', '\n%s\n');
190
190
  var match = message.match(/^([^:]+): expected/);
191
- msg = match ? '\n ' + color('error message', match[1]) : '';
191
+ msg = '\n ' + color('error message', match ? match[1] : msg);
192
192
 
193
193
  if (exports.inlineDiffs) {
194
194
  msg += inlineDiff(err, escape);
@@ -42,7 +42,7 @@ var statsTemplate = '<ul id="mocha-stats">'
42
42
  * @api public
43
43
  */
44
44
 
45
- function HTML(runner, root) {
45
+ function HTML(runner) {
46
46
  Base.call(this, runner);
47
47
 
48
48
  var self = this
@@ -60,8 +60,7 @@ function HTML(runner, root) {
60
60
  , stack = [report]
61
61
  , progress
62
62
  , ctx
63
-
64
- root = root || document.getElementById('mocha');
63
+ , root = document.getElementById('mocha');
65
64
 
66
65
  if (canvas.getContext) {
67
66
  var ratio = window.devicePixelRatio || 1;
package/lib/runnable.js CHANGED
@@ -168,16 +168,6 @@ Runnable.prototype.run = function(fn){
168
168
 
169
169
  if (ctx) ctx.runnable(this);
170
170
 
171
- // timeout
172
- if (this.async) {
173
- if (ms) {
174
- this.timer = setTimeout(function(){
175
- done(new Error('timeout of ' + ms + 'ms exceeded'));
176
- self.timedOut = true;
177
- }, ms);
178
- }
179
- }
180
-
181
171
  // called multiple times
182
172
  function multiple(err) {
183
173
  if (emitted) return;
@@ -198,8 +188,10 @@ Runnable.prototype.run = function(fn){
198
188
  // for .resetTimeout()
199
189
  this.callback = done;
200
190
 
201
- // async
191
+ // explicit async with `done` argument
202
192
  if (this.async) {
193
+ this.resetTimeout();
194
+
203
195
  try {
204
196
  this.fn.call(ctx, function(err){
205
197
  if (err instanceof Error || toString.call(err) === "[object Error]") return done(err);
@@ -216,12 +208,24 @@ Runnable.prototype.run = function(fn){
216
208
  return done(new Error('--async-only option in use without declaring `done()`'));
217
209
  }
218
210
 
219
- // sync
211
+ // sync or promise-returning
220
212
  try {
221
- if (!this.pending) this.fn.call(ctx);
222
- this.duration = new Date - start;
223
- fn();
213
+ if (this.pending) {
214
+ done();
215
+ } else {
216
+ callFn(this.fn);
217
+ }
224
218
  } catch (err) {
225
- fn(err);
219
+ done(err);
220
+ }
221
+
222
+ function callFn(fn) {
223
+ var result = fn.call(ctx);
224
+ if (result && typeof result.then === 'function') {
225
+ self.resetTimeout();
226
+ result.then(function(){ done() }, done);
227
+ } else {
228
+ done();
229
+ }
226
230
  }
227
231
  };
package/lib/runner.js CHANGED
@@ -58,7 +58,7 @@ function Runner(suite) {
58
58
  this.on('test end', function(test){ self.checkGlobals(test); });
59
59
  this.on('hook end', function(hook){ self.checkGlobals(hook); });
60
60
  this.grep(/.*/);
61
- this.globals(this.globalProps().concat(['errno']));
61
+ this.globals(this.globalProps().concat(extraGlobals()));
62
62
  }
63
63
 
64
64
  /**
@@ -168,10 +168,6 @@ Runner.prototype.checkGlobals = function(test){
168
168
  ok = ok.concat(test._allowedGlobals || []);
169
169
  }
170
170
 
171
- // check length - 2 ('errno' and 'location' globals)
172
- if (isNode && 1 == ok.length - globals.length) return;
173
- else if (2 == ok.length - globals.length) return;
174
-
175
171
  if(this.prevGlobalsLength == globals.length) return;
176
172
  this.prevGlobalsLength = globals.length;
177
173
 
@@ -638,3 +634,28 @@ function filterLeaks(ok, globals) {
638
634
  return matched.length == 0 && (!global.navigator || 'onerror' !== key);
639
635
  });
640
636
  }
637
+
638
+ /**
639
+ * Array of globals dependent on the environment.
640
+ *
641
+ * @return {Array}
642
+ * @api private
643
+ */
644
+
645
+ function extraGlobals() {
646
+ if (typeof(process) === 'object' &&
647
+ typeof(process.version) === 'string') {
648
+
649
+ var nodeVersion = process.version.split('.').reduce(function(a, v) {
650
+ return a << 8 | v;
651
+ });
652
+
653
+ // 'errno' was renamed to process._errno in v0.9.11.
654
+
655
+ if (nodeVersion < 0x00090B) {
656
+ return ['errno'];
657
+ }
658
+ }
659
+
660
+ return [];
661
+ }
package/lib/suite.js CHANGED
@@ -140,9 +140,15 @@ Suite.prototype.bail = function(bail){
140
140
  * @api private
141
141
  */
142
142
 
143
- Suite.prototype.beforeAll = function(fn){
143
+ Suite.prototype.beforeAll = function(title, fn){
144
144
  if (this.pending) return this;
145
- var hook = new Hook('"before all" hook', fn);
145
+ if ('function' === typeof title) {
146
+ fn = title;
147
+ title = fn.name;
148
+ }
149
+ title = '"before all" hook' + (title ? ': ' + title : '');
150
+
151
+ var hook = new Hook(title, fn);
146
152
  hook.parent = this;
147
153
  hook.timeout(this.timeout());
148
154
  hook.slow(this.slow());
@@ -160,9 +166,15 @@ Suite.prototype.beforeAll = function(fn){
160
166
  * @api private
161
167
  */
162
168
 
163
- Suite.prototype.afterAll = function(fn){
169
+ Suite.prototype.afterAll = function(title, fn){
164
170
  if (this.pending) return this;
165
- var hook = new Hook('"after all" hook', fn);
171
+ if ('function' === typeof title) {
172
+ fn = title;
173
+ title = fn.name;
174
+ }
175
+ title = '"after all" hook' + (title ? ': ' + title : '');
176
+
177
+ var hook = new Hook(title, fn);
166
178
  hook.parent = this;
167
179
  hook.timeout(this.timeout());
168
180
  hook.slow(this.slow());
@@ -180,9 +192,15 @@ Suite.prototype.afterAll = function(fn){
180
192
  * @api private
181
193
  */
182
194
 
183
- Suite.prototype.beforeEach = function(fn){
195
+ Suite.prototype.beforeEach = function(title, fn){
184
196
  if (this.pending) return this;
185
- var hook = new Hook('"before each" hook', fn);
197
+ if ('function' === typeof title) {
198
+ fn = title;
199
+ title = fn.name;
200
+ }
201
+ title = '"before each" hook' + (title ? ': ' + title : '');
202
+
203
+ var hook = new Hook(title, fn);
186
204
  hook.parent = this;
187
205
  hook.timeout(this.timeout());
188
206
  hook.slow(this.slow());
@@ -200,9 +218,15 @@ Suite.prototype.beforeEach = function(fn){
200
218
  * @api private
201
219
  */
202
220
 
203
- Suite.prototype.afterEach = function(fn){
221
+ Suite.prototype.afterEach = function(title, fn){
204
222
  if (this.pending) return this;
205
- var hook = new Hook('"after each" hook', fn);
223
+ if ('function' === typeof title) {
224
+ fn = title;
225
+ title = fn.name;
226
+ }
227
+ title = '"after each" hook' + (title ? ': ' + title : '');
228
+
229
+ var hook = new Hook(title, fn);
206
230
  hook.parent = this;
207
231
  hook.timeout(this.timeout());
208
232
  hook.slow(this.slow());
package/mocha.js CHANGED
@@ -915,32 +915,32 @@ module.exports = function(suite){
915
915
  * Execute before running tests.
916
916
  */
917
917
 
918
- context.before = function(fn){
919
- suites[0].beforeAll(fn);
918
+ context.before = function(name, fn){
919
+ suites[0].beforeAll(name, fn);
920
920
  };
921
921
 
922
922
  /**
923
923
  * Execute after running tests.
924
924
  */
925
925
 
926
- context.after = function(fn){
927
- suites[0].afterAll(fn);
926
+ context.after = function(name, fn){
927
+ suites[0].afterAll(name, fn);
928
928
  };
929
929
 
930
930
  /**
931
931
  * Execute before each test case.
932
932
  */
933
933
 
934
- context.beforeEach = function(fn){
935
- suites[0].beforeEach(fn);
934
+ context.beforeEach = function(name, fn){
935
+ suites[0].beforeEach(name, fn);
936
936
  };
937
937
 
938
938
  /**
939
939
  * Execute after each test case.
940
940
  */
941
941
 
942
- context.afterEach = function(fn){
943
- suites[0].afterEach(fn);
942
+ context.afterEach = function(name, fn){
943
+ suites[0].afterEach(name, fn);
944
944
  };
945
945
 
946
946
  /**
@@ -1137,32 +1137,32 @@ module.exports = function(suite){
1137
1137
  * Execute before running tests.
1138
1138
  */
1139
1139
 
1140
- context.before = function(fn){
1141
- suites[0].beforeAll(fn);
1140
+ context.before = function(name, fn){
1141
+ suites[0].beforeAll(name, fn);
1142
1142
  };
1143
1143
 
1144
1144
  /**
1145
1145
  * Execute after running tests.
1146
1146
  */
1147
1147
 
1148
- context.after = function(fn){
1149
- suites[0].afterAll(fn);
1148
+ context.after = function(name, fn){
1149
+ suites[0].afterAll(name, fn);
1150
1150
  };
1151
1151
 
1152
1152
  /**
1153
1153
  * Execute before each test case.
1154
1154
  */
1155
1155
 
1156
- context.beforeEach = function(fn){
1157
- suites[0].beforeEach(fn);
1156
+ context.beforeEach = function(name, fn){
1157
+ suites[0].beforeEach(name, fn);
1158
1158
  };
1159
1159
 
1160
1160
  /**
1161
1161
  * Execute after each test case.
1162
1162
  */
1163
1163
 
1164
- context.afterEach = function(fn){
1165
- suites[0].afterEach(fn);
1164
+ context.afterEach = function(name, fn){
1165
+ suites[0].afterEach(name, fn);
1166
1166
  };
1167
1167
 
1168
1168
  /**
@@ -1263,32 +1263,32 @@ module.exports = function(suite){
1263
1263
  * Execute before each test case.
1264
1264
  */
1265
1265
 
1266
- context.setup = function(fn){
1267
- suites[0].beforeEach(fn);
1266
+ context.setup = function(name, fn){
1267
+ suites[0].beforeEach(name, fn);
1268
1268
  };
1269
1269
 
1270
1270
  /**
1271
1271
  * Execute after each test case.
1272
1272
  */
1273
1273
 
1274
- context.teardown = function(fn){
1275
- suites[0].afterEach(fn);
1274
+ context.teardown = function(name, fn){
1275
+ suites[0].afterEach(name, fn);
1276
1276
  };
1277
1277
 
1278
1278
  /**
1279
1279
  * Execute before the suite.
1280
1280
  */
1281
1281
 
1282
- context.suiteSetup = function(fn){
1283
- suites[0].beforeAll(fn);
1282
+ context.suiteSetup = function(name, fn){
1283
+ suites[0].beforeAll(name, fn);
1284
1284
  };
1285
1285
 
1286
1286
  /**
1287
1287
  * Execute after the suite.
1288
1288
  */
1289
1289
 
1290
- context.suiteTeardown = function(fn){
1291
- suites[0].afterAll(fn);
1290
+ context.suiteTeardown = function(name, fn){
1291
+ suites[0].afterAll(name, fn);
1292
1292
  };
1293
1293
 
1294
1294
  /**
@@ -1720,8 +1720,9 @@ Mocha.prototype.run = function(fn){
1720
1720
  if (this.files.length) this.loadFiles();
1721
1721
  var suite = this.suite;
1722
1722
  var options = this.options;
1723
+ options.files = this.files;
1723
1724
  var runner = new exports.Runner(suite);
1724
- var reporter = new this._reporter(runner);
1725
+ var reporter = new this._reporter(runner, options);
1725
1726
  runner.ignoreLeaks = false !== options.ignoreLeaks;
1726
1727
  runner.asyncOnly = options.asyncOnly;
1727
1728
  if (options.grep) runner.grep(options.grep, options.invert);
@@ -2038,7 +2039,7 @@ exports.list = function(failures){
2038
2039
  if ('string' == typeof actual && 'string' == typeof expected) {
2039
2040
  fmt = color('error title', ' %s) %s:\n%s') + color('error stack', '\n%s\n');
2040
2041
  var match = message.match(/^([^:]+): expected/);
2041
- msg = match ? '\n ' + color('error message', match[1]) : '';
2042
+ msg = '\n ' + color('error message', match ? match[1] : msg);
2042
2043
 
2043
2044
  if (exports.inlineDiffs) {
2044
2045
  msg += inlineDiff(err, escape);
@@ -2586,7 +2587,7 @@ var statsTemplate = '<ul id="mocha-stats">'
2586
2587
  * @api public
2587
2588
  */
2588
2589
 
2589
- function HTML(runner, root) {
2590
+ function HTML(runner) {
2590
2591
  Base.call(this, runner);
2591
2592
 
2592
2593
  var self = this
@@ -2604,8 +2605,7 @@ function HTML(runner, root) {
2604
2605
  , stack = [report]
2605
2606
  , progress
2606
2607
  , ctx
2607
-
2608
- root = root || document.getElementById('mocha');
2608
+ , root = document.getElementById('mocha');
2609
2609
 
2610
2610
  if (canvas.getContext) {
2611
2611
  var ratio = window.devicePixelRatio || 1;
@@ -4283,16 +4283,6 @@ Runnable.prototype.run = function(fn){
4283
4283
 
4284
4284
  if (ctx) ctx.runnable(this);
4285
4285
 
4286
- // timeout
4287
- if (this.async) {
4288
- if (ms) {
4289
- this.timer = setTimeout(function(){
4290
- done(new Error('timeout of ' + ms + 'ms exceeded'));
4291
- self.timedOut = true;
4292
- }, ms);
4293
- }
4294
- }
4295
-
4296
4286
  // called multiple times
4297
4287
  function multiple(err) {
4298
4288
  if (emitted) return;
@@ -4313,8 +4303,10 @@ Runnable.prototype.run = function(fn){
4313
4303
  // for .resetTimeout()
4314
4304
  this.callback = done;
4315
4305
 
4316
- // async
4306
+ // explicit async with `done` argument
4317
4307
  if (this.async) {
4308
+ this.resetTimeout();
4309
+
4318
4310
  try {
4319
4311
  this.fn.call(ctx, function(err){
4320
4312
  if (err instanceof Error || toString.call(err) === "[object Error]") return done(err);
@@ -4331,13 +4323,25 @@ Runnable.prototype.run = function(fn){
4331
4323
  return done(new Error('--async-only option in use without declaring `done()`'));
4332
4324
  }
4333
4325
 
4334
- // sync
4326
+ // sync or promise-returning
4335
4327
  try {
4336
- if (!this.pending) this.fn.call(ctx);
4337
- this.duration = new Date - start;
4338
- fn();
4328
+ if (this.pending) {
4329
+ done();
4330
+ } else {
4331
+ callFn(this.fn);
4332
+ }
4339
4333
  } catch (err) {
4340
- fn(err);
4334
+ done(err);
4335
+ }
4336
+
4337
+ function callFn(fn) {
4338
+ var result = fn.call(ctx);
4339
+ if (result && typeof result.then === 'function') {
4340
+ self.resetTimeout();
4341
+ result.then(function(){ done() }, done);
4342
+ } else {
4343
+ done();
4344
+ }
4341
4345
  }
4342
4346
  };
4343
4347
 
@@ -4404,7 +4408,7 @@ function Runner(suite) {
4404
4408
  this.on('test end', function(test){ self.checkGlobals(test); });
4405
4409
  this.on('hook end', function(hook){ self.checkGlobals(hook); });
4406
4410
  this.grep(/.*/);
4407
- this.globals(this.globalProps().concat(['errno']));
4411
+ this.globals(this.globalProps().concat(extraGlobals()));
4408
4412
  }
4409
4413
 
4410
4414
  /**
@@ -4518,10 +4522,6 @@ Runner.prototype.checkGlobals = function(test){
4518
4522
  ok = ok.concat(test._allowedGlobals || []);
4519
4523
  }
4520
4524
 
4521
- // check length - 2 ('errno' and 'location' globals)
4522
- if (isNode && 1 == ok.length - globals.length) return;
4523
- else if (2 == ok.length - globals.length) return;
4524
-
4525
4525
  if(this.prevGlobalsLength == globals.length) return;
4526
4526
  this.prevGlobalsLength = globals.length;
4527
4527
 
@@ -4989,6 +4989,31 @@ function filterLeaks(ok, globals) {
4989
4989
  });
4990
4990
  }
4991
4991
 
4992
+ /**
4993
+ * Array of globals dependent on the environment.
4994
+ *
4995
+ * @return {Array}
4996
+ * @api private
4997
+ */
4998
+
4999
+ function extraGlobals() {
5000
+ if (typeof(process) === 'object' &&
5001
+ typeof(process.version) === 'string') {
5002
+
5003
+ var nodeVersion = process.version.split('.').reduce(function(a, v) {
5004
+ return a << 8 | v;
5005
+ });
5006
+
5007
+ // 'errno' was renamed to process._errno in v0.9.11.
5008
+
5009
+ if (nodeVersion < 0x00090B) {
5010
+ return ['errno'];
5011
+ }
5012
+ }
5013
+
5014
+ return [];
5015
+ }
5016
+
4992
5017
  }); // module: runner.js
4993
5018
 
4994
5019
  require.register("suite.js", function(module, exports, require){
@@ -5138,9 +5163,15 @@ Suite.prototype.bail = function(bail){
5138
5163
  * @api private
5139
5164
  */
5140
5165
 
5141
- Suite.prototype.beforeAll = function(fn){
5166
+ Suite.prototype.beforeAll = function(title, fn){
5142
5167
  if (this.pending) return this;
5143
- var hook = new Hook('"before all" hook', fn);
5168
+ if ('function' === typeof title) {
5169
+ fn = title;
5170
+ title = fn.name;
5171
+ }
5172
+ title = '"before all" hook' + (title ? ': ' + title : '');
5173
+
5174
+ var hook = new Hook(title, fn);
5144
5175
  hook.parent = this;
5145
5176
  hook.timeout(this.timeout());
5146
5177
  hook.slow(this.slow());
@@ -5158,9 +5189,15 @@ Suite.prototype.beforeAll = function(fn){
5158
5189
  * @api private
5159
5190
  */
5160
5191
 
5161
- Suite.prototype.afterAll = function(fn){
5192
+ Suite.prototype.afterAll = function(title, fn){
5162
5193
  if (this.pending) return this;
5163
- var hook = new Hook('"after all" hook', fn);
5194
+ if ('function' === typeof title) {
5195
+ fn = title;
5196
+ title = fn.name;
5197
+ }
5198
+ title = '"after all" hook' + (title ? ': ' + title : '');
5199
+
5200
+ var hook = new Hook(title, fn);
5164
5201
  hook.parent = this;
5165
5202
  hook.timeout(this.timeout());
5166
5203
  hook.slow(this.slow());
@@ -5178,9 +5215,15 @@ Suite.prototype.afterAll = function(fn){
5178
5215
  * @api private
5179
5216
  */
5180
5217
 
5181
- Suite.prototype.beforeEach = function(fn){
5218
+ Suite.prototype.beforeEach = function(title, fn){
5182
5219
  if (this.pending) return this;
5183
- var hook = new Hook('"before each" hook', fn);
5220
+ if ('function' === typeof title) {
5221
+ fn = title;
5222
+ title = fn.name;
5223
+ }
5224
+ title = '"before each" hook' + (title ? ': ' + title : '');
5225
+
5226
+ var hook = new Hook(title, fn);
5184
5227
  hook.parent = this;
5185
5228
  hook.timeout(this.timeout());
5186
5229
  hook.slow(this.slow());
@@ -5198,9 +5241,15 @@ Suite.prototype.beforeEach = function(fn){
5198
5241
  * @api private
5199
5242
  */
5200
5243
 
5201
- Suite.prototype.afterEach = function(fn){
5244
+ Suite.prototype.afterEach = function(title, fn){
5202
5245
  if (this.pending) return this;
5203
- var hook = new Hook('"after each" hook', fn);
5246
+ if ('function' === typeof title) {
5247
+ fn = title;
5248
+ title = fn.name;
5249
+ }
5250
+ title = '"after each" hook' + (title ? ': ' + title : '');
5251
+
5252
+ var hook = new Hook(title, fn);
5204
5253
  hook.parent = this;
5205
5254
  hook.timeout(this.timeout());
5206
5255
  hook.slow(this.slow());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mocha",
3
- "version": "1.17.0",
3
+ "version": "1.18.2",
4
4
  "description": "simple, flexible, fun test framework",
5
5
  "keywords": [
6
6
  "mocha",