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