mocha 10.5.1 → 10.5.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/lib/nodejs/serializer.js +6 -10
- package/lib/utils.js +33 -0
- package/mocha.js +35 -2
- package/mocha.js.map +1 -1
- package/package.json +1 -1
package/lib/nodejs/serializer.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
'use strict';
|
|
8
8
|
|
|
9
|
-
const {type} = require('../utils');
|
|
9
|
+
const {type, breakCircularDeps} = require('../utils');
|
|
10
10
|
const {createInvalidArgumentTypeError} = require('../errors');
|
|
11
11
|
// this is not named `mocha:parallel:serializer` because it's noisy and it's
|
|
12
12
|
// helpful to be able to write `DEBUG=mocha:parallel*` and get everything else.
|
|
@@ -188,14 +188,9 @@ class SerializableEvent {
|
|
|
188
188
|
* @param {Array<object|string>} pairs - List of parent/key tuples to process; modified in-place. This JSDoc type is an approximation
|
|
189
189
|
* @param {object} parent - Some parent object
|
|
190
190
|
* @param {string} key - Key to inspect
|
|
191
|
-
* @param {WeakSet<Object>} seenObjects - For avoiding circular references
|
|
192
191
|
*/
|
|
193
|
-
static _serialize(pairs, parent, key
|
|
192
|
+
static _serialize(pairs, parent, key) {
|
|
194
193
|
let value = parent[key];
|
|
195
|
-
if (seenObjects.has(value)) {
|
|
196
|
-
parent[key] = Object.create(null);
|
|
197
|
-
return;
|
|
198
|
-
}
|
|
199
194
|
let _type = type(value);
|
|
200
195
|
if (_type === 'error') {
|
|
201
196
|
// we need to reference the stack prop b/c it's lazily-loaded.
|
|
@@ -263,13 +258,14 @@ class SerializableEvent {
|
|
|
263
258
|
error: this.originalError
|
|
264
259
|
});
|
|
265
260
|
|
|
261
|
+
// mutates the object
|
|
262
|
+
breakCircularDeps(result);
|
|
263
|
+
|
|
266
264
|
const pairs = Object.keys(result).map(key => [result, key]);
|
|
267
|
-
const seenObjects = new WeakSet();
|
|
268
265
|
|
|
269
266
|
let pair;
|
|
270
267
|
while ((pair = pairs.shift())) {
|
|
271
|
-
SerializableEvent._serialize(pairs, ...pair
|
|
272
|
-
seenObjects.add(pair[0]);
|
|
268
|
+
SerializableEvent._serialize(pairs, ...pair);
|
|
273
269
|
}
|
|
274
270
|
|
|
275
271
|
this.data = result.data;
|
package/lib/utils.js
CHANGED
|
@@ -647,3 +647,36 @@ exports.assignNewMochaID = obj => {
|
|
|
647
647
|
*/
|
|
648
648
|
exports.getMochaID = obj =>
|
|
649
649
|
obj && typeof obj === 'object' ? obj[MOCHA_ID_PROP_NAME] : undefined;
|
|
650
|
+
|
|
651
|
+
/**
|
|
652
|
+
* Replaces any detected circular dependency with the string '[Circular]'
|
|
653
|
+
* Mutates original object
|
|
654
|
+
* @param inputObj {*}
|
|
655
|
+
* @returns {*}
|
|
656
|
+
*/
|
|
657
|
+
exports.breakCircularDeps = inputObj => {
|
|
658
|
+
const seen = new Set();
|
|
659
|
+
|
|
660
|
+
function _breakCircularDeps(obj) {
|
|
661
|
+
if (obj && typeof obj !== 'object') {
|
|
662
|
+
return obj;
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
if (seen.has(obj)) {
|
|
666
|
+
return '[Circular]';
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
seen.add(obj);
|
|
670
|
+
for (const k in obj) {
|
|
671
|
+
if (Object.prototype.hasOwnProperty.call(obj, k)) {
|
|
672
|
+
obj[k] = _breakCircularDeps(obj[k], k);
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
// deleting means only a seen object that is its own child will be detected
|
|
677
|
+
seen.delete(obj);
|
|
678
|
+
return obj;
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
return _breakCircularDeps(inputObj);
|
|
682
|
+
};
|
package/mocha.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// mocha@10.5.
|
|
1
|
+
// mocha@10.5.2 in javascript ES2018
|
|
2
2
|
(function (global, factory) {
|
|
3
3
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
4
4
|
typeof define === 'function' && define.amd ? define(factory) :
|
|
@@ -11460,6 +11460,39 @@
|
|
|
11460
11460
|
*/
|
|
11461
11461
|
exports.getMochaID = obj =>
|
|
11462
11462
|
obj && typeof obj === 'object' ? obj[MOCHA_ID_PROP_NAME] : undefined;
|
|
11463
|
+
|
|
11464
|
+
/**
|
|
11465
|
+
* Replaces any detected circular dependency with the string '[Circular]'
|
|
11466
|
+
* Mutates original object
|
|
11467
|
+
* @param inputObj {*}
|
|
11468
|
+
* @returns {*}
|
|
11469
|
+
*/
|
|
11470
|
+
exports.breakCircularDeps = inputObj => {
|
|
11471
|
+
const seen = new Set();
|
|
11472
|
+
|
|
11473
|
+
function _breakCircularDeps(obj) {
|
|
11474
|
+
if (obj && typeof obj !== 'object') {
|
|
11475
|
+
return obj;
|
|
11476
|
+
}
|
|
11477
|
+
|
|
11478
|
+
if (seen.has(obj)) {
|
|
11479
|
+
return '[Circular]';
|
|
11480
|
+
}
|
|
11481
|
+
|
|
11482
|
+
seen.add(obj);
|
|
11483
|
+
for (const k in obj) {
|
|
11484
|
+
if (Object.prototype.hasOwnProperty.call(obj, k)) {
|
|
11485
|
+
obj[k] = _breakCircularDeps(obj[k]);
|
|
11486
|
+
}
|
|
11487
|
+
}
|
|
11488
|
+
|
|
11489
|
+
// deleting means only a seen object that is its own child will be detected
|
|
11490
|
+
seen.delete(obj);
|
|
11491
|
+
return obj;
|
|
11492
|
+
}
|
|
11493
|
+
|
|
11494
|
+
return _breakCircularDeps(inputObj);
|
|
11495
|
+
};
|
|
11463
11496
|
}(utils$3));
|
|
11464
11497
|
|
|
11465
11498
|
var _nodeResolve_empty = {};
|
|
@@ -18986,7 +19019,7 @@
|
|
|
18986
19019
|
};
|
|
18987
19020
|
|
|
18988
19021
|
var name = "mocha";
|
|
18989
|
-
var version = "10.5.
|
|
19022
|
+
var version = "10.5.2";
|
|
18990
19023
|
var homepage = "https://mochajs.org/";
|
|
18991
19024
|
var notifyLogo = "https://ibin.co/4QuRuGjXvl36.png";
|
|
18992
19025
|
var require$$17 = {
|