mocha 5.1.1 → 5.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.
- package/CHANGELOG.md +32 -0
- package/bin/_mocha +82 -36
- package/bin/options.js +14 -8
- package/browser-entry.js +20 -16
- package/lib/browser/progress.js +8 -8
- package/lib/browser/tty.js +2 -2
- package/lib/context.js +7 -7
- package/lib/hook.js +5 -16
- package/lib/interfaces/bdd.js +12 -13
- package/lib/interfaces/common.js +18 -15
- package/lib/interfaces/exports.js +2 -7
- package/lib/interfaces/qunit.js +6 -10
- package/lib/interfaces/tdd.js +7 -11
- package/lib/mocha.js +56 -57
- package/lib/ms.js +7 -5
- package/lib/pending.js +1 -5
- package/lib/reporters/base.js +91 -63
- package/lib/reporters/doc.js +16 -8
- package/lib/reporters/dot.js +7 -7
- package/lib/reporters/html.js +74 -40
- package/lib/reporters/json-stream.js +7 -7
- package/lib/reporters/json.js +21 -19
- package/lib/reporters/landing.js +7 -7
- package/lib/reporters/list.js +9 -9
- package/lib/reporters/markdown.js +11 -11
- package/lib/reporters/min.js +2 -2
- package/lib/reporters/nyan.js +24 -24
- package/lib/reporters/progress.js +6 -6
- package/lib/reporters/spec.js +12 -10
- package/lib/reporters/tap.js +8 -8
- package/lib/reporters/xunit.js +41 -23
- package/lib/runnable.js +64 -62
- package/lib/runner.js +99 -78
- package/lib/suite.js +39 -33
- package/lib/test.js +9 -13
- package/lib/utils.js +131 -85
- package/mocha.js +1556 -1064
- package/package.json +32 -19
- package/images/error.png +0 -0
- package/images/ok.png +0 -0
package/lib/utils.js
CHANGED
|
@@ -30,8 +30,8 @@ exports.inherits = require('util').inherits;
|
|
|
30
30
|
* @param {string} html
|
|
31
31
|
* @return {string}
|
|
32
32
|
*/
|
|
33
|
-
exports.escape = function
|
|
34
|
-
return he.encode(String(html), {
|
|
33
|
+
exports.escape = function(html) {
|
|
34
|
+
return he.encode(String(html), {useNamedReferences: false});
|
|
35
35
|
};
|
|
36
36
|
|
|
37
37
|
/**
|
|
@@ -41,7 +41,7 @@ exports.escape = function (html) {
|
|
|
41
41
|
* @param {Object} obj
|
|
42
42
|
* @return {boolean}
|
|
43
43
|
*/
|
|
44
|
-
exports.isString = function
|
|
44
|
+
exports.isString = function(obj) {
|
|
45
45
|
return typeof obj === 'string';
|
|
46
46
|
};
|
|
47
47
|
|
|
@@ -53,11 +53,11 @@ exports.isString = function (obj) {
|
|
|
53
53
|
* @param {Array} files
|
|
54
54
|
* @param {Function} fn
|
|
55
55
|
*/
|
|
56
|
-
exports.watch = function
|
|
57
|
-
var options = {
|
|
58
|
-
files.forEach(function
|
|
56
|
+
exports.watch = function(files, fn) {
|
|
57
|
+
var options = {interval: 100};
|
|
58
|
+
files.forEach(function(file) {
|
|
59
59
|
debug('file %s', file);
|
|
60
|
-
fs.watchFile(file, options, function
|
|
60
|
+
fs.watchFile(file, options, function(curr, prev) {
|
|
61
61
|
if (prev.mtime < curr.mtime) {
|
|
62
62
|
fn(file);
|
|
63
63
|
}
|
|
@@ -72,7 +72,7 @@ exports.watch = function (files, fn) {
|
|
|
72
72
|
* @param {string} path
|
|
73
73
|
* @return {boolean}
|
|
74
74
|
*/
|
|
75
|
-
function ignored
|
|
75
|
+
function ignored(path) {
|
|
76
76
|
return !~ignore.indexOf(path);
|
|
77
77
|
}
|
|
78
78
|
|
|
@@ -85,15 +85,16 @@ function ignored (path) {
|
|
|
85
85
|
* @param {Array} [ret=[]]
|
|
86
86
|
* @return {Array}
|
|
87
87
|
*/
|
|
88
|
-
exports.files = function
|
|
88
|
+
exports.files = function(dir, ext, ret) {
|
|
89
89
|
ret = ret || [];
|
|
90
90
|
ext = ext || ['js'];
|
|
91
91
|
|
|
92
92
|
var re = new RegExp('\\.(' + ext.join('|') + ')$');
|
|
93
93
|
|
|
94
|
-
fs
|
|
94
|
+
fs
|
|
95
|
+
.readdirSync(dir)
|
|
95
96
|
.filter(ignored)
|
|
96
|
-
.forEach(function
|
|
97
|
+
.forEach(function(path) {
|
|
97
98
|
path = join(dir, path);
|
|
98
99
|
if (fs.lstatSync(path).isDirectory()) {
|
|
99
100
|
exports.files(path, ext, ret);
|
|
@@ -112,7 +113,7 @@ exports.files = function (dir, ext, ret) {
|
|
|
112
113
|
* @param {string} str
|
|
113
114
|
* @return {string}
|
|
114
115
|
*/
|
|
115
|
-
exports.slug = function
|
|
116
|
+
exports.slug = function(str) {
|
|
116
117
|
return str
|
|
117
118
|
.toLowerCase()
|
|
118
119
|
.replace(/ +/g, '-')
|
|
@@ -125,15 +126,22 @@ exports.slug = function (str) {
|
|
|
125
126
|
* @param {string} str
|
|
126
127
|
* @return {string}
|
|
127
128
|
*/
|
|
128
|
-
exports.clean = function
|
|
129
|
+
exports.clean = function(str) {
|
|
129
130
|
str = str
|
|
130
|
-
.replace(/\r\n?|[\n\u2028\u2029]/g, '\n')
|
|
131
|
+
.replace(/\r\n?|[\n\u2028\u2029]/g, '\n')
|
|
132
|
+
.replace(/^\uFEFF/, '')
|
|
131
133
|
// (traditional)-> space/name parameters body (lambda)-> parameters body multi-statement/single keep body content
|
|
132
|
-
.replace(
|
|
134
|
+
.replace(
|
|
135
|
+
/^function(?:\s*|\s+[^(]*)\([^)]*\)\s*\{((?:.|\n)*?)\s*\}$|^\([^)]*\)\s*=>\s*(?:\{((?:.|\n)*?)\s*\}|((?:.|\n)*))$/,
|
|
136
|
+
'$1$2$3'
|
|
137
|
+
);
|
|
133
138
|
|
|
134
139
|
var spaces = str.match(/^\n?( *)/)[1].length;
|
|
135
140
|
var tabs = str.match(/^\n?(\t*)/)[1].length;
|
|
136
|
-
var re = new RegExp(
|
|
141
|
+
var re = new RegExp(
|
|
142
|
+
'^\n?' + (tabs ? '\t' : ' ') + '{' + (tabs || spaces) + '}',
|
|
143
|
+
'gm'
|
|
144
|
+
);
|
|
137
145
|
|
|
138
146
|
str = str.replace(re, '');
|
|
139
147
|
|
|
@@ -147,17 +155,20 @@ exports.clean = function (str) {
|
|
|
147
155
|
* @param {string} qs
|
|
148
156
|
* @return {Object}
|
|
149
157
|
*/
|
|
150
|
-
exports.parseQuery = function
|
|
151
|
-
return qs
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
158
|
+
exports.parseQuery = function(qs) {
|
|
159
|
+
return qs
|
|
160
|
+
.replace('?', '')
|
|
161
|
+
.split('&')
|
|
162
|
+
.reduce(function(obj, pair) {
|
|
163
|
+
var i = pair.indexOf('=');
|
|
164
|
+
var key = pair.slice(0, i);
|
|
165
|
+
var val = pair.slice(++i);
|
|
166
|
+
|
|
167
|
+
// Due to how the URLSearchParams API treats spaces
|
|
168
|
+
obj[key] = decodeURIComponent(val.replace(/\+/g, '%20'));
|
|
169
|
+
|
|
170
|
+
return obj;
|
|
171
|
+
}, {});
|
|
161
172
|
};
|
|
162
173
|
|
|
163
174
|
/**
|
|
@@ -167,7 +178,7 @@ exports.parseQuery = function (qs) {
|
|
|
167
178
|
* @param {string} js
|
|
168
179
|
* @return {string}
|
|
169
180
|
*/
|
|
170
|
-
function highlight
|
|
181
|
+
function highlight(js) {
|
|
171
182
|
return js
|
|
172
183
|
.replace(/</g, '<')
|
|
173
184
|
.replace(/>/g, '>')
|
|
@@ -175,8 +186,14 @@ function highlight (js) {
|
|
|
175
186
|
.replace(/('.*?')/gm, '<span class="string">$1</span>')
|
|
176
187
|
.replace(/(\d+\.\d+)/gm, '<span class="number">$1</span>')
|
|
177
188
|
.replace(/(\d+)/gm, '<span class="number">$1</span>')
|
|
178
|
-
.replace(
|
|
179
|
-
|
|
189
|
+
.replace(
|
|
190
|
+
/\bnew[ \t]+(\w+)/gm,
|
|
191
|
+
'<span class="keyword">new</span> <span class="init">$1</span>'
|
|
192
|
+
)
|
|
193
|
+
.replace(
|
|
194
|
+
/\b(function|new|throw|return|var|if|else)\b/gm,
|
|
195
|
+
'<span class="keyword">$1</span>'
|
|
196
|
+
);
|
|
180
197
|
}
|
|
181
198
|
|
|
182
199
|
/**
|
|
@@ -185,7 +202,7 @@ function highlight (js) {
|
|
|
185
202
|
* @api private
|
|
186
203
|
* @param {string} name
|
|
187
204
|
*/
|
|
188
|
-
exports.highlightTags = function
|
|
205
|
+
exports.highlightTags = function(name) {
|
|
189
206
|
var code = document.getElementById('mocha').getElementsByTagName(name);
|
|
190
207
|
for (var i = 0, len = code.length; i < len; ++i) {
|
|
191
208
|
code[i].innerHTML = highlight(code[i].innerHTML);
|
|
@@ -206,7 +223,7 @@ exports.highlightTags = function (name) {
|
|
|
206
223
|
* @param {string} typeHint The type of the value
|
|
207
224
|
* @returns {string}
|
|
208
225
|
*/
|
|
209
|
-
function emptyRepresentation
|
|
226
|
+
function emptyRepresentation(value, typeHint) {
|
|
210
227
|
switch (typeHint) {
|
|
211
228
|
case 'function':
|
|
212
229
|
return '[Function]';
|
|
@@ -240,7 +257,7 @@ function emptyRepresentation (value, typeHint) {
|
|
|
240
257
|
* type(global) // 'global'
|
|
241
258
|
* type(new String('foo') // 'object'
|
|
242
259
|
*/
|
|
243
|
-
var type = exports.type = function type
|
|
260
|
+
var type = (exports.type = function type(value) {
|
|
244
261
|
if (value === undefined) {
|
|
245
262
|
return 'undefined';
|
|
246
263
|
} else if (value === null) {
|
|
@@ -248,10 +265,11 @@ var type = exports.type = function type (value) {
|
|
|
248
265
|
} else if (Buffer.isBuffer(value)) {
|
|
249
266
|
return 'buffer';
|
|
250
267
|
}
|
|
251
|
-
return Object.prototype.toString
|
|
268
|
+
return Object.prototype.toString
|
|
269
|
+
.call(value)
|
|
252
270
|
.replace(/^\[.+\s(.+?)]$/, '$1')
|
|
253
271
|
.toLowerCase();
|
|
254
|
-
};
|
|
272
|
+
});
|
|
255
273
|
|
|
256
274
|
/**
|
|
257
275
|
* Stringify `value`. Different behavior depending on type of value:
|
|
@@ -268,21 +286,23 @@ var type = exports.type = function type (value) {
|
|
|
268
286
|
* @param {*} value
|
|
269
287
|
* @return {string}
|
|
270
288
|
*/
|
|
271
|
-
exports.stringify = function
|
|
289
|
+
exports.stringify = function(value) {
|
|
272
290
|
var typeHint = type(value);
|
|
273
291
|
|
|
274
292
|
if (!~['object', 'array', 'function'].indexOf(typeHint)) {
|
|
275
293
|
if (typeHint === 'buffer') {
|
|
276
294
|
var json = Buffer.prototype.toJSON.call(value);
|
|
277
295
|
// Based on the toJSON result
|
|
278
|
-
return jsonStringify(
|
|
279
|
-
.
|
|
296
|
+
return jsonStringify(
|
|
297
|
+
json.data && json.type ? json.data : json,
|
|
298
|
+
2
|
|
299
|
+
).replace(/,(\n|$)/g, '$1');
|
|
280
300
|
}
|
|
281
301
|
|
|
282
302
|
// IE7/IE8 has a bizarre String constructor; needs to be coerced
|
|
283
303
|
// into an array and back to obj.
|
|
284
304
|
if (typeHint === 'string' && typeof value === 'object') {
|
|
285
|
-
value = value.split('').reduce(function
|
|
305
|
+
value = value.split('').reduce(function(acc, char, idx) {
|
|
286
306
|
acc[idx] = char;
|
|
287
307
|
return acc;
|
|
288
308
|
}, {});
|
|
@@ -294,7 +314,10 @@ exports.stringify = function (value) {
|
|
|
294
314
|
|
|
295
315
|
for (var prop in value) {
|
|
296
316
|
if (Object.prototype.hasOwnProperty.call(value, prop)) {
|
|
297
|
-
return jsonStringify(
|
|
317
|
+
return jsonStringify(
|
|
318
|
+
exports.canonicalize(value, null, typeHint),
|
|
319
|
+
2
|
|
320
|
+
).replace(/,(\n|$)/g, '$1');
|
|
298
321
|
}
|
|
299
322
|
}
|
|
300
323
|
|
|
@@ -310,7 +333,7 @@ exports.stringify = function (value) {
|
|
|
310
333
|
* @param {number=} depth
|
|
311
334
|
* @returns {*}
|
|
312
335
|
*/
|
|
313
|
-
function jsonStringify
|
|
336
|
+
function jsonStringify(object, spaces, depth) {
|
|
314
337
|
if (typeof spaces === 'undefined') {
|
|
315
338
|
// primitive types
|
|
316
339
|
return _stringify(object);
|
|
@@ -320,13 +343,16 @@ function jsonStringify (object, spaces, depth) {
|
|
|
320
343
|
var space = spaces * depth;
|
|
321
344
|
var str = Array.isArray(object) ? '[' : '{';
|
|
322
345
|
var end = Array.isArray(object) ? ']' : '}';
|
|
323
|
-
var length =
|
|
346
|
+
var length =
|
|
347
|
+
typeof object.length === 'number'
|
|
348
|
+
? object.length
|
|
349
|
+
: Object.keys(object).length;
|
|
324
350
|
// `.repeat()` polyfill
|
|
325
|
-
function repeat
|
|
351
|
+
function repeat(s, n) {
|
|
326
352
|
return new Array(n).join(s);
|
|
327
353
|
}
|
|
328
354
|
|
|
329
|
-
function _stringify
|
|
355
|
+
function _stringify(val) {
|
|
330
356
|
switch (type(val)) {
|
|
331
357
|
case 'null':
|
|
332
358
|
case 'undefined':
|
|
@@ -340,9 +366,10 @@ function jsonStringify (object, spaces, depth) {
|
|
|
340
366
|
case 'regexp':
|
|
341
367
|
case 'symbol':
|
|
342
368
|
case 'number':
|
|
343
|
-
val =
|
|
344
|
-
|
|
345
|
-
|
|
369
|
+
val =
|
|
370
|
+
val === 0 && 1 / val === -Infinity // `-0`
|
|
371
|
+
? '-0'
|
|
372
|
+
: val.toString();
|
|
346
373
|
break;
|
|
347
374
|
case 'date':
|
|
348
375
|
var sDate = isNaN(val.getTime()) ? val.toString() : val.toISOString();
|
|
@@ -355,9 +382,10 @@ function jsonStringify (object, spaces, depth) {
|
|
|
355
382
|
val = '[Buffer: ' + jsonStringify(json, 2, depth + 1) + ']';
|
|
356
383
|
break;
|
|
357
384
|
default:
|
|
358
|
-
val =
|
|
359
|
-
|
|
360
|
-
|
|
385
|
+
val =
|
|
386
|
+
val === '[Function]' || val === '[Circular]'
|
|
387
|
+
? val
|
|
388
|
+
: JSON.stringify(val); // string
|
|
361
389
|
}
|
|
362
390
|
return val;
|
|
363
391
|
}
|
|
@@ -367,15 +395,19 @@ function jsonStringify (object, spaces, depth) {
|
|
|
367
395
|
continue; // not my business
|
|
368
396
|
}
|
|
369
397
|
--length;
|
|
370
|
-
str +=
|
|
398
|
+
str +=
|
|
399
|
+
'\n ' +
|
|
400
|
+
repeat(' ', space) +
|
|
371
401
|
(Array.isArray(object) ? '' : '"' + i + '": ') + // key
|
|
372
402
|
_stringify(object[i]) + // value
|
|
373
403
|
(length ? ',' : ''); // comma
|
|
374
404
|
}
|
|
375
405
|
|
|
376
|
-
return
|
|
406
|
+
return (
|
|
407
|
+
str +
|
|
377
408
|
// [], {}
|
|
378
|
-
(str.length !== 1 ? '\n' + repeat(' ', --space) + end : end)
|
|
409
|
+
(str.length !== 1 ? '\n' + repeat(' ', --space) + end : end)
|
|
410
|
+
);
|
|
379
411
|
}
|
|
380
412
|
|
|
381
413
|
/**
|
|
@@ -397,13 +429,13 @@ function jsonStringify (object, spaces, depth) {
|
|
|
397
429
|
* @param {string} [typeHint] Type hint
|
|
398
430
|
* @return {(Object|Array|Function|string|undefined)}
|
|
399
431
|
*/
|
|
400
|
-
exports.canonicalize = function canonicalize
|
|
432
|
+
exports.canonicalize = function canonicalize(value, stack, typeHint) {
|
|
401
433
|
var canonicalizedObj;
|
|
402
434
|
/* eslint-disable no-unused-vars */
|
|
403
435
|
var prop;
|
|
404
436
|
/* eslint-enable no-unused-vars */
|
|
405
437
|
typeHint = typeHint || type(value);
|
|
406
|
-
function withStack
|
|
438
|
+
function withStack(value, fn) {
|
|
407
439
|
stack.push(value);
|
|
408
440
|
fn();
|
|
409
441
|
stack.pop();
|
|
@@ -422,8 +454,8 @@ exports.canonicalize = function canonicalize (value, stack, typeHint) {
|
|
|
422
454
|
canonicalizedObj = value;
|
|
423
455
|
break;
|
|
424
456
|
case 'array':
|
|
425
|
-
withStack(value, function
|
|
426
|
-
canonicalizedObj = value.map(function
|
|
457
|
+
withStack(value, function() {
|
|
458
|
+
canonicalizedObj = value.map(function(item) {
|
|
427
459
|
return exports.canonicalize(item, stack);
|
|
428
460
|
});
|
|
429
461
|
});
|
|
@@ -442,10 +474,12 @@ exports.canonicalize = function canonicalize (value, stack, typeHint) {
|
|
|
442
474
|
/* falls through */
|
|
443
475
|
case 'object':
|
|
444
476
|
canonicalizedObj = canonicalizedObj || {};
|
|
445
|
-
withStack(value, function
|
|
446
|
-
Object.keys(value)
|
|
447
|
-
|
|
448
|
-
|
|
477
|
+
withStack(value, function() {
|
|
478
|
+
Object.keys(value)
|
|
479
|
+
.sort()
|
|
480
|
+
.forEach(function(key) {
|
|
481
|
+
canonicalizedObj[key] = exports.canonicalize(value[key], stack);
|
|
482
|
+
});
|
|
449
483
|
});
|
|
450
484
|
break;
|
|
451
485
|
case 'date':
|
|
@@ -473,7 +507,7 @@ exports.canonicalize = function canonicalize (value, stack, typeHint) {
|
|
|
473
507
|
* @param {boolean} recursive Whether or not to recurse into subdirectories.
|
|
474
508
|
* @return {string[]} An array of paths.
|
|
475
509
|
*/
|
|
476
|
-
exports.lookupFiles = function lookupFiles
|
|
510
|
+
exports.lookupFiles = function lookupFiles(filepath, extensions, recursive) {
|
|
477
511
|
var files = [];
|
|
478
512
|
|
|
479
513
|
if (!fs.existsSync(filepath)) {
|
|
@@ -498,7 +532,7 @@ exports.lookupFiles = function lookupFiles (filepath, extensions, recursive) {
|
|
|
498
532
|
return;
|
|
499
533
|
}
|
|
500
534
|
|
|
501
|
-
fs.readdirSync(filepath).forEach(function
|
|
535
|
+
fs.readdirSync(filepath).forEach(function(file) {
|
|
502
536
|
file = path.join(filepath, file);
|
|
503
537
|
try {
|
|
504
538
|
var stat = fs.statSync(file);
|
|
@@ -512,6 +546,11 @@ exports.lookupFiles = function lookupFiles (filepath, extensions, recursive) {
|
|
|
512
546
|
// ignore error
|
|
513
547
|
return;
|
|
514
548
|
}
|
|
549
|
+
if (!extensions) {
|
|
550
|
+
throw new Error(
|
|
551
|
+
'extensions parameter required when filepath is a directory'
|
|
552
|
+
);
|
|
553
|
+
}
|
|
515
554
|
var re = new RegExp('\\.(?:' + extensions.join('|') + ')$');
|
|
516
555
|
if (!stat.isFile() || !re.test(file) || path.basename(file)[0] === '.') {
|
|
517
556
|
return;
|
|
@@ -528,8 +567,10 @@ exports.lookupFiles = function lookupFiles (filepath, extensions, recursive) {
|
|
|
528
567
|
* @return {Error}
|
|
529
568
|
*/
|
|
530
569
|
|
|
531
|
-
exports.undefinedError = function
|
|
532
|
-
return new Error(
|
|
570
|
+
exports.undefinedError = function() {
|
|
571
|
+
return new Error(
|
|
572
|
+
'Caught undefined error, did you throw without specifying what?'
|
|
573
|
+
);
|
|
533
574
|
};
|
|
534
575
|
|
|
535
576
|
/**
|
|
@@ -539,7 +580,7 @@ exports.undefinedError = function () {
|
|
|
539
580
|
* @return {Error}
|
|
540
581
|
*/
|
|
541
582
|
|
|
542
|
-
exports.getError = function
|
|
583
|
+
exports.getError = function(err) {
|
|
543
584
|
return err || exports.undefinedError();
|
|
544
585
|
};
|
|
545
586
|
|
|
@@ -552,9 +593,9 @@ exports.getError = function (err) {
|
|
|
552
593
|
* (i.e: strip Mocha and internal node functions from stack trace).
|
|
553
594
|
* @returns {Function}
|
|
554
595
|
*/
|
|
555
|
-
exports.stackTraceFilter = function
|
|
596
|
+
exports.stackTraceFilter = function() {
|
|
556
597
|
// TODO: Replace with `process.browser`
|
|
557
|
-
var is = typeof document === 'undefined' ? {
|
|
598
|
+
var is = typeof document === 'undefined' ? {node: true} : {browser: true};
|
|
558
599
|
var slash = path.sep;
|
|
559
600
|
var cwd;
|
|
560
601
|
if (is.node) {
|
|
@@ -562,30 +603,35 @@ exports.stackTraceFilter = function () {
|
|
|
562
603
|
} else {
|
|
563
604
|
cwd = (typeof location === 'undefined'
|
|
564
605
|
? window.location
|
|
565
|
-
: location
|
|
606
|
+
: location
|
|
607
|
+
).href.replace(/\/[^/]*$/, '/');
|
|
566
608
|
slash = '/';
|
|
567
609
|
}
|
|
568
610
|
|
|
569
|
-
function isMochaInternal
|
|
570
|
-
return (
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
611
|
+
function isMochaInternal(line) {
|
|
612
|
+
return (
|
|
613
|
+
~line.indexOf('node_modules' + slash + 'mocha' + slash) ||
|
|
614
|
+
~line.indexOf('node_modules' + slash + 'mocha.js') ||
|
|
615
|
+
~line.indexOf('bower_components' + slash + 'mocha.js') ||
|
|
616
|
+
~line.indexOf(slash + 'mocha.js')
|
|
617
|
+
);
|
|
574
618
|
}
|
|
575
619
|
|
|
576
|
-
function isNodeInternal
|
|
577
|
-
return (
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
620
|
+
function isNodeInternal(line) {
|
|
621
|
+
return (
|
|
622
|
+
~line.indexOf('(timers.js:') ||
|
|
623
|
+
~line.indexOf('(events.js:') ||
|
|
624
|
+
~line.indexOf('(node.js:') ||
|
|
625
|
+
~line.indexOf('(module.js:') ||
|
|
626
|
+
~line.indexOf('GeneratorFunctionPrototype.next (native)') ||
|
|
627
|
+
false
|
|
628
|
+
);
|
|
583
629
|
}
|
|
584
630
|
|
|
585
|
-
return function
|
|
631
|
+
return function(stack) {
|
|
586
632
|
stack = stack.split('\n');
|
|
587
633
|
|
|
588
|
-
stack = stack.reduce(function
|
|
634
|
+
stack = stack.reduce(function(list, line) {
|
|
589
635
|
if (isMochaInternal(line)) {
|
|
590
636
|
return list;
|
|
591
637
|
}
|
|
@@ -613,7 +659,7 @@ exports.stackTraceFilter = function () {
|
|
|
613
659
|
* @param {*} value
|
|
614
660
|
* @returns {boolean} Whether or not `value` is a Promise
|
|
615
661
|
*/
|
|
616
|
-
exports.isPromise = function isPromise
|
|
662
|
+
exports.isPromise = function isPromise(value) {
|
|
617
663
|
return typeof value === 'object' && typeof value.then === 'function';
|
|
618
664
|
};
|
|
619
665
|
|
|
@@ -621,4 +667,4 @@ exports.isPromise = function isPromise (value) {
|
|
|
621
667
|
* It's a noop.
|
|
622
668
|
* @api
|
|
623
669
|
*/
|
|
624
|
-
exports.noop = function
|
|
670
|
+
exports.noop = function() {};
|