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/utils.js CHANGED
@@ -1,3 +1,5 @@
1
+ 'use strict';
2
+
1
3
  /* eslint-env browser */
2
4
 
3
5
  /**
@@ -9,10 +11,12 @@ var basename = require('path').basename;
9
11
  var debug = require('debug')('mocha:watch');
10
12
  var exists = require('fs').existsSync || require('path').existsSync;
11
13
  var glob = require('glob');
12
- var join = require('path').join;
14
+ var path = require('path');
15
+ var join = path.join;
13
16
  var readdirSync = require('fs').readdirSync;
14
17
  var statSync = require('fs').statSync;
15
18
  var watchFile = require('fs').watchFile;
19
+ var lstatSync = require('fs').lstatSync;
16
20
  var toISOString = require('./to-iso-string');
17
21
 
18
22
  /**
@@ -30,7 +34,7 @@ exports.inherits = require('util').inherits;
30
34
  * @param {string} html
31
35
  * @return {string}
32
36
  */
33
- exports.escape = function(html) {
37
+ exports.escape = function (html) {
34
38
  return String(html)
35
39
  .replace(/&/g, '&')
36
40
  .replace(/"/g, '"')
@@ -46,7 +50,7 @@ exports.escape = function(html) {
46
50
  * @param {Function} fn
47
51
  * @param {Object} scope
48
52
  */
49
- exports.forEach = function(arr, fn, scope) {
53
+ exports.forEach = function (arr, fn, scope) {
50
54
  for (var i = 0, l = arr.length; i < l; i++) {
51
55
  fn.call(scope, arr[i], i);
52
56
  }
@@ -59,7 +63,7 @@ exports.forEach = function(arr, fn, scope) {
59
63
  * @param {Object} obj
60
64
  * @return {boolean}
61
65
  */
62
- exports.isString = function(obj) {
66
+ exports.isString = function (obj) {
63
67
  return typeof obj === 'string';
64
68
  };
65
69
 
@@ -72,7 +76,7 @@ exports.isString = function(obj) {
72
76
  * @param {Object} scope
73
77
  * @return {Array}
74
78
  */
75
- exports.map = function(arr, fn, scope) {
79
+ exports.map = function (arr, fn, scope) {
76
80
  var result = [];
77
81
  for (var i = 0, l = arr.length; i < l; i++) {
78
82
  result.push(fn.call(scope, arr[i], i, arr));
@@ -89,7 +93,7 @@ exports.map = function(arr, fn, scope) {
89
93
  * @param {number} start
90
94
  * @return {number}
91
95
  */
92
- exports.indexOf = function(arr, obj, start) {
96
+ var indexOf = exports.indexOf = function (arr, obj, start) {
93
97
  for (var i = start || 0, l = arr.length; i < l; i++) {
94
98
  if (arr[i] === obj) {
95
99
  return i;
@@ -107,7 +111,7 @@ exports.indexOf = function(arr, obj, start) {
107
111
  * @param {Object} val Initial value.
108
112
  * @return {*}
109
113
  */
110
- exports.reduce = function(arr, fn, val) {
114
+ var reduce = exports.reduce = function (arr, fn, val) {
111
115
  var rval = val;
112
116
 
113
117
  for (var i = 0, l = arr.length; i < l; i++) {
@@ -125,7 +129,7 @@ exports.reduce = function(arr, fn, val) {
125
129
  * @param {Function} fn
126
130
  * @return {Array}
127
131
  */
128
- exports.filter = function(arr, fn) {
132
+ exports.filter = function (arr, fn) {
129
133
  var ret = [];
130
134
 
131
135
  for (var i = 0, l = arr.length; i < l; i++) {
@@ -146,7 +150,7 @@ exports.filter = function(arr, fn) {
146
150
  * @param {Function} fn
147
151
  * @return {Array}
148
152
  */
149
- exports.some = function(arr, fn) {
153
+ exports.some = function (arr, fn) {
150
154
  for (var i = 0, l = arr.length; i < l; i++) {
151
155
  if (fn(arr[i])) {
152
156
  return true;
@@ -162,7 +166,7 @@ exports.some = function(arr, fn) {
162
166
  * @param {Object} obj
163
167
  * @return {Array} keys
164
168
  */
165
- exports.keys = typeof Object.keys === 'function' ? Object.keys : function(obj) {
169
+ exports.keys = typeof Object.keys === 'function' ? Object.keys : function (obj) {
166
170
  var keys = [];
167
171
  var has = Object.prototype.hasOwnProperty; // for `window` on <=IE8
168
172
 
@@ -183,11 +187,11 @@ exports.keys = typeof Object.keys === 'function' ? Object.keys : function(obj) {
183
187
  * @param {Array} files
184
188
  * @param {Function} fn
185
189
  */
186
- exports.watch = function(files, fn) {
190
+ exports.watch = function (files, fn) {
187
191
  var options = { interval: 100 };
188
- files.forEach(function(file) {
192
+ files.forEach(function (file) {
189
193
  debug('file %s', file);
190
- watchFile(file, options, function(curr, prev) {
194
+ watchFile(file, options, function (curr, prev) {
191
195
  if (prev.mtime < curr.mtime) {
192
196
  fn(file);
193
197
  }
@@ -202,7 +206,7 @@ exports.watch = function(files, fn) {
202
206
  * @param {Object} obj
203
207
  * @return {Boolean}
204
208
  */
205
- var isArray = typeof Array.isArray === 'function' ? Array.isArray : function(obj) {
209
+ var isArray = typeof Array.isArray === 'function' ? Array.isArray : function (obj) {
206
210
  return Object.prototype.toString.call(obj) === '[object Array]';
207
211
  };
208
212
 
@@ -214,7 +218,7 @@ exports.isArray = isArray;
214
218
  * @type {Function}
215
219
  */
216
220
  if (typeof Buffer !== 'undefined' && Buffer.prototype) {
217
- Buffer.prototype.toJSON = Buffer.prototype.toJSON || function() {
221
+ Buffer.prototype.toJSON = Buffer.prototype.toJSON || function () {
218
222
  return Array.prototype.slice.call(this, 0);
219
223
  };
220
224
  }
@@ -226,7 +230,7 @@ if (typeof Buffer !== 'undefined' && Buffer.prototype) {
226
230
  * @param {string} path
227
231
  * @return {boolean}
228
232
  */
229
- function ignored(path) {
233
+ function ignored (path) {
230
234
  return !~ignore.indexOf(path);
231
235
  }
232
236
 
@@ -239,7 +243,7 @@ function ignored(path) {
239
243
  * @param {Array} [ret=[]]
240
244
  * @return {Array}
241
245
  */
242
- exports.files = function(dir, ext, ret) {
246
+ exports.files = function (dir, ext, ret) {
243
247
  ret = ret || [];
244
248
  ext = ext || ['js'];
245
249
 
@@ -247,9 +251,9 @@ exports.files = function(dir, ext, ret) {
247
251
 
248
252
  readdirSync(dir)
249
253
  .filter(ignored)
250
- .forEach(function(path) {
254
+ .forEach(function (path) {
251
255
  path = join(dir, path);
252
- if (statSync(path).isDirectory()) {
256
+ if (lstatSync(path).isDirectory()) {
253
257
  exports.files(path, ext, ret);
254
258
  } else if (path.match(re)) {
255
259
  ret.push(path);
@@ -266,7 +270,7 @@ exports.files = function(dir, ext, ret) {
266
270
  * @param {string} str
267
271
  * @return {string}
268
272
  */
269
- exports.slug = function(str) {
273
+ exports.slug = function (str) {
270
274
  return str
271
275
  .toLowerCase()
272
276
  .replace(/ +/g, '-')
@@ -279,7 +283,7 @@ exports.slug = function(str) {
279
283
  * @param {string} str
280
284
  * @return {string}
281
285
  */
282
- exports.clean = function(str) {
286
+ exports.clean = function (str) {
283
287
  str = str
284
288
  .replace(/\r\n?|[\n\u2028\u2029]/g, '\n').replace(/^\uFEFF/, '')
285
289
  // (traditional)-> space/name parameters body (lambda)-> parameters body multi-statement/single keep body content
@@ -287,7 +291,7 @@ exports.clean = function(str) {
287
291
 
288
292
  var spaces = str.match(/^\n?( *)/)[1].length;
289
293
  var tabs = str.match(/^\n?(\t*)/)[1].length;
290
- var re = new RegExp('^\n?' + (tabs ? '\t' : ' ') + '{' + (tabs ? tabs : spaces) + '}', 'gm');
294
+ var re = new RegExp('^\n?' + (tabs ? '\t' : ' ') + '{' + (tabs || spaces) + '}', 'gm');
291
295
 
292
296
  str = str.replace(re, '');
293
297
 
@@ -301,7 +305,7 @@ exports.clean = function(str) {
301
305
  * @param {string} str
302
306
  * @return {string}
303
307
  */
304
- exports.trim = function(str) {
308
+ exports.trim = function (str) {
305
309
  return str.replace(/^\s+|\s+$/g, '');
306
310
  };
307
311
 
@@ -312,8 +316,8 @@ exports.trim = function(str) {
312
316
  * @param {string} qs
313
317
  * @return {Object}
314
318
  */
315
- exports.parseQuery = function(qs) {
316
- return exports.reduce(qs.replace('?', '').split('&'), function(obj, pair) {
319
+ exports.parseQuery = function (qs) {
320
+ return reduce(qs.replace('?', '').split('&'), function (obj, pair) {
317
321
  var i = pair.indexOf('=');
318
322
  var key = pair.slice(0, i);
319
323
  var val = pair.slice(++i);
@@ -330,7 +334,7 @@ exports.parseQuery = function(qs) {
330
334
  * @param {string} js
331
335
  * @return {string}
332
336
  */
333
- function highlight(js) {
337
+ function highlight (js) {
334
338
  return js
335
339
  .replace(/</g, '&lt;')
336
340
  .replace(/>/g, '&gt;')
@@ -348,7 +352,7 @@ function highlight(js) {
348
352
  * @api private
349
353
  * @param {string} name
350
354
  */
351
- exports.highlightTags = function(name) {
355
+ exports.highlightTags = function (name) {
352
356
  var code = document.getElementById('mocha').getElementsByTagName(name);
353
357
  for (var i = 0, len = code.length; i < len; ++i) {
354
358
  code[i].innerHTML = highlight(code[i].innerHTML);
@@ -366,13 +370,11 @@ exports.highlightTags = function(name) {
366
370
  *
367
371
  * @api private
368
372
  * @param {*} value The value to inspect.
369
- * @param {string} [type] The type of the value, if known.
373
+ * @param {string} typeHint The type of the value
370
374
  * @returns {string}
371
375
  */
372
- function emptyRepresentation(value, type) {
373
- type = type || exports.type(value);
374
-
375
- switch (type) {
376
+ function emptyRepresentation (value, typeHint) {
377
+ switch (typeHint) {
376
378
  case 'function':
377
379
  return '[Function]';
378
380
  case 'object':
@@ -391,7 +393,7 @@ function emptyRepresentation(value, type) {
391
393
  * @api private
392
394
  * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toString
393
395
  * @param {*} value The value to test.
394
- * @returns {string}
396
+ * @returns {string} Computed type
395
397
  * @example
396
398
  * type({}) // 'object'
397
399
  * type([]) // 'array'
@@ -403,8 +405,9 @@ function emptyRepresentation(value, type) {
403
405
  * type(/foo/) // 'regexp'
404
406
  * type('type') // 'string'
405
407
  * type(global) // 'global'
408
+ * type(new String('foo') // 'object'
406
409
  */
407
- exports.type = function type(value) {
410
+ var type = exports.type = function type (value) {
408
411
  if (value === undefined) {
409
412
  return 'undefined';
410
413
  } else if (value === null) {
@@ -432,26 +435,37 @@ exports.type = function type(value) {
432
435
  * @param {*} value
433
436
  * @return {string}
434
437
  */
435
- exports.stringify = function(value) {
436
- var type = exports.type(value);
438
+ exports.stringify = function (value) {
439
+ var typeHint = type(value);
437
440
 
438
- if (!~exports.indexOf(['object', 'array', 'function'], type)) {
439
- if (type !== 'buffer') {
441
+ if (!~indexOf(['object', 'array', 'function'], typeHint)) {
442
+ if (typeHint === 'buffer') {
443
+ var json = value.toJSON();
444
+ // Based on the toJSON result
445
+ return jsonStringify(json.data && json.type ? json.data : json, 2)
446
+ .replace(/,(\n|$)/g, '$1');
447
+ }
448
+
449
+ // IE7/IE8 has a bizarre String constructor; needs to be coerced
450
+ // into an array and back to obj.
451
+ if (typeHint === 'string' && typeof value === 'object') {
452
+ value = reduce(value.split(''), function (acc, char, idx) {
453
+ acc[idx] = char;
454
+ return acc;
455
+ }, {});
456
+ typeHint = 'object';
457
+ } else {
440
458
  return jsonStringify(value);
441
459
  }
442
- var json = value.toJSON();
443
- // Based on the toJSON result
444
- return jsonStringify(json.data && json.type ? json.data : json, 2)
445
- .replace(/,(\n|$)/g, '$1');
446
460
  }
447
461
 
448
462
  for (var prop in value) {
449
463
  if (Object.prototype.hasOwnProperty.call(value, prop)) {
450
- return jsonStringify(exports.canonicalize(value), 2).replace(/,(\n|$)/g, '$1');
464
+ return jsonStringify(exports.canonicalize(value, null, typeHint), 2).replace(/,(\n|$)/g, '$1');
451
465
  }
452
466
  }
453
467
 
454
- return emptyRepresentation(value, type);
468
+ return emptyRepresentation(value, typeHint);
455
469
  };
456
470
 
457
471
  /**
@@ -463,7 +477,7 @@ exports.stringify = function(value) {
463
477
  * @param {number=} depth
464
478
  * @returns {*}
465
479
  */
466
- function jsonStringify(object, spaces, depth) {
480
+ function jsonStringify (object, spaces, depth) {
467
481
  if (typeof spaces === 'undefined') {
468
482
  // primitive types
469
483
  return _stringify(object);
@@ -475,12 +489,12 @@ function jsonStringify(object, spaces, depth) {
475
489
  var end = isArray(object) ? ']' : '}';
476
490
  var length = typeof object.length === 'number' ? object.length : exports.keys(object).length;
477
491
  // `.repeat()` polyfill
478
- function repeat(s, n) {
492
+ function repeat (s, n) {
479
493
  return new Array(n).join(s);
480
494
  }
481
495
 
482
- function _stringify(val) {
483
- switch (exports.type(val)) {
496
+ function _stringify (val) {
497
+ switch (type(val)) {
484
498
  case 'null':
485
499
  case 'undefined':
486
500
  val = '[' + val + ']';
@@ -525,15 +539,15 @@ function jsonStringify(object, spaces, depth) {
525
539
  continue; // not my business
526
540
  }
527
541
  --length;
528
- str += '\n ' + repeat(' ', space)
529
- + (isArray(object) ? '' : '"' + i + '": ') // key
530
- + _stringify(object[i]) // value
531
- + (length ? ',' : ''); // comma
542
+ str += '\n ' + repeat(' ', space) +
543
+ (isArray(object) ? '' : '"' + i + '": ') + // key
544
+ _stringify(object[i]) + // value
545
+ (length ? ',' : ''); // comma
532
546
  }
533
547
 
534
- return str
548
+ return str +
535
549
  // [], {}
536
- + (str.length !== 1 ? '\n' + repeat(' ', --space) + end : end);
550
+ (str.length !== 1 ? '\n' + repeat(' ', --space) + end : end);
537
551
  }
538
552
 
539
553
  /**
@@ -543,7 +557,7 @@ function jsonStringify(object, spaces, depth) {
543
557
  * @param {*} value The value to test.
544
558
  * @return {boolean} True if `value` is a buffer, otherwise false
545
559
  */
546
- exports.isBuffer = function(value) {
560
+ exports.isBuffer = function (value) {
547
561
  return typeof Buffer !== 'undefined' && Buffer.isBuffer(value);
548
562
  };
549
563
 
@@ -563,15 +577,16 @@ exports.isBuffer = function(value) {
563
577
  * @see {@link exports.stringify}
564
578
  * @param {*} value Thing to inspect. May or may not have properties.
565
579
  * @param {Array} [stack=[]] Stack of seen values
580
+ * @param {string} [typeHint] Type hint
566
581
  * @return {(Object|Array|Function|string|undefined)}
567
582
  */
568
- exports.canonicalize = function(value, stack) {
583
+ exports.canonicalize = function canonicalize (value, stack, typeHint) {
569
584
  var canonicalizedObj;
570
585
  /* eslint-disable no-unused-vars */
571
586
  var prop;
572
587
  /* eslint-enable no-unused-vars */
573
- var type = exports.type(value);
574
- function withStack(value, fn) {
588
+ typeHint = typeHint || type(value);
589
+ function withStack (value, fn) {
575
590
  stack.push(value);
576
591
  fn();
577
592
  stack.pop();
@@ -579,19 +594,19 @@ exports.canonicalize = function(value, stack) {
579
594
 
580
595
  stack = stack || [];
581
596
 
582
- if (exports.indexOf(stack, value) !== -1) {
597
+ if (indexOf(stack, value) !== -1) {
583
598
  return '[Circular]';
584
599
  }
585
600
 
586
- switch (type) {
601
+ switch (typeHint) {
587
602
  case 'undefined':
588
603
  case 'buffer':
589
604
  case 'null':
590
605
  canonicalizedObj = value;
591
606
  break;
592
607
  case 'array':
593
- withStack(value, function() {
594
- canonicalizedObj = exports.map(value, function(item) {
608
+ withStack(value, function () {
609
+ canonicalizedObj = exports.map(value, function (item) {
595
610
  return exports.canonicalize(item, stack);
596
611
  });
597
612
  });
@@ -604,14 +619,14 @@ exports.canonicalize = function(value, stack) {
604
619
  }
605
620
  /* eslint-enable guard-for-in */
606
621
  if (!canonicalizedObj) {
607
- canonicalizedObj = emptyRepresentation(value, type);
622
+ canonicalizedObj = emptyRepresentation(value, typeHint);
608
623
  break;
609
624
  }
610
625
  /* falls through */
611
626
  case 'object':
612
627
  canonicalizedObj = canonicalizedObj || {};
613
- withStack(value, function() {
614
- exports.forEach(exports.keys(value).sort(), function(key) {
628
+ withStack(value, function () {
629
+ exports.forEach(exports.keys(value).sort(), function (key) {
615
630
  canonicalizedObj[key] = exports.canonicalize(value[key], stack);
616
631
  });
617
632
  });
@@ -639,7 +654,7 @@ exports.canonicalize = function(value, stack) {
639
654
  * @param {boolean} recursive Whether or not to recurse into subdirectories.
640
655
  * @return {string[]} An array of paths.
641
656
  */
642
- exports.lookupFiles = function lookupFiles(path, extensions, recursive) {
657
+ exports.lookupFiles = function lookupFiles (path, extensions, recursive) {
643
658
  var files = [];
644
659
  var re = new RegExp('\\.(' + extensions.join('|') + ')$');
645
660
 
@@ -665,7 +680,7 @@ exports.lookupFiles = function lookupFiles(path, extensions, recursive) {
665
680
  return;
666
681
  }
667
682
 
668
- readdirSync(path).forEach(function(file) {
683
+ readdirSync(path).forEach(function (file) {
669
684
  file = join(path, file);
670
685
  try {
671
686
  var stat = statSync(file);
@@ -694,7 +709,7 @@ exports.lookupFiles = function lookupFiles(path, extensions, recursive) {
694
709
  * @return {Error}
695
710
  */
696
711
 
697
- exports.undefinedError = function() {
712
+ exports.undefinedError = function () {
698
713
  return new Error('Caught undefined error, did you throw without specifying what?');
699
714
  };
700
715
 
@@ -705,7 +720,7 @@ exports.undefinedError = function() {
705
720
  * @return {Error}
706
721
  */
707
722
 
708
- exports.getError = function(err) {
723
+ exports.getError = function (err) {
709
724
  return err || exports.undefinedError();
710
725
  };
711
726
 
@@ -718,34 +733,38 @@ exports.getError = function(err) {
718
733
  * (i.e: strip Mocha and internal node functions from stack trace).
719
734
  * @returns {Function}
720
735
  */
721
- exports.stackTraceFilter = function() {
736
+ exports.stackTraceFilter = function () {
722
737
  // TODO: Replace with `process.browser`
723
- var slash = '/';
724
738
  var is = typeof document === 'undefined' ? { node: true } : { browser: true };
725
- var cwd = is.node
726
- ? process.cwd() + slash
727
- : (typeof location === 'undefined' ? window.location : location).href.replace(/\/[^\/]*$/, '/');
728
-
729
- function isMochaInternal(line) {
730
- return (~line.indexOf('node_modules' + slash + 'mocha' + slash))
731
- || (~line.indexOf('components' + slash + 'mochajs' + slash))
732
- || (~line.indexOf('components' + slash + 'mocha' + slash))
733
- || (~line.indexOf(slash + 'mocha.js'));
739
+ var slash = path.sep;
740
+ var cwd;
741
+ if (is.node) {
742
+ cwd = process.cwd() + slash;
743
+ } else {
744
+ cwd = (typeof location === 'undefined' ? window.location : location).href.replace(/\/[^\/]*$/, '/');
745
+ slash = '/';
734
746
  }
735
747
 
736
- function isNodeInternal(line) {
737
- return (~line.indexOf('(timers.js:'))
738
- || (~line.indexOf('(events.js:'))
739
- || (~line.indexOf('(node.js:'))
740
- || (~line.indexOf('(module.js:'))
741
- || (~line.indexOf('GeneratorFunctionPrototype.next (native)'))
742
- || false;
748
+ function isMochaInternal (line) {
749
+ return (~line.indexOf('node_modules' + slash + 'mocha' + slash)) ||
750
+ (~line.indexOf('node_modules' + slash + 'mocha.js')) ||
751
+ (~line.indexOf('bower_components' + slash + 'mocha.js')) ||
752
+ (~line.indexOf(slash + 'mocha.js'));
743
753
  }
744
754
 
745
- return function(stack) {
755
+ function isNodeInternal (line) {
756
+ return (~line.indexOf('(timers.js:')) ||
757
+ (~line.indexOf('(events.js:')) ||
758
+ (~line.indexOf('(node.js:')) ||
759
+ (~line.indexOf('(module.js:')) ||
760
+ (~line.indexOf('GeneratorFunctionPrototype.next (native)')) ||
761
+ false;
762
+ }
763
+
764
+ return function (stack) {
746
765
  stack = stack.split('\n');
747
766
 
748
- stack = exports.reduce(stack, function(list, line) {
767
+ stack = reduce(stack, function (list, line) {
749
768
  if (isMochaInternal(line)) {
750
769
  return list;
751
770
  }
@@ -773,6 +792,12 @@ exports.stackTraceFilter = function() {
773
792
  * @param {*} value
774
793
  * @returns {boolean} Whether or not `value` is a Promise
775
794
  */
776
- exports.isPromise = function isPromise(value) {
795
+ exports.isPromise = function isPromise (value) {
777
796
  return typeof value === 'object' && typeof value.then === 'function';
778
797
  };
798
+
799
+ /**
800
+ * It's a noop.
801
+ * @api
802
+ */
803
+ exports.noop = function () {};