@jsenv/cli 0.1.21 → 0.1.22
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/package.json +1 -1
- package/template-node-package/.jsenv/jsenv_tests_output.txt +1 -1
- package/template-node-package/package.json +2 -2
- package/template-web/.jsenv/chrome@127.00/@fs/Users/damien.maillard/dev/perso/jsenv-core/packages/independent/assert/dist/jsenv_assert_browser.js +247 -105
- package/template-web/.jsenv/chrome@127.00/tests/animals.test.html@L13C5-L30C14.js +2 -2
- package/template-web/.jsenv/chrome@127.00/tests/animals.test.html@L13C5-L30C14.js.map +4 -4
- package/template-web/.jsenv/jsenv_tests_output.txt +3 -3
- package/template-web/package.json +2 -2
- package/template-web-components/.jsenv/chrome@127.00/@fs/Users/damien.maillard/dev/perso/jsenv-core/packages/independent/assert/dist/jsenv_assert_browser.js +247 -105
- package/template-web-components/.jsenv/chrome@127.00/tests/animals.test.html@L13C5-L30C14.js +2 -2
- package/template-web-components/.jsenv/chrome@127.00/tests/animals.test.html@L13C5-L30C14.js.map +4 -4
- package/template-web-components/.jsenv/jsenv_tests_output.txt +3 -3
- package/template-web-components/package.json +2 -2
- package/template-web-preact/.jsenv/chrome@127.00/@fs/Users/damien.maillard/dev/perso/jsenv-core/packages/independent/assert/dist/jsenv_assert_browser.js +247 -105
- package/template-web-preact/.jsenv/chrome@127.00/tests/animals.test.html@L13C5-L30C14.js +2 -2
- package/template-web-preact/.jsenv/chrome@127.00/tests/animals.test.html@L13C5-L30C14.js.map +4 -4
- package/template-web-preact/.jsenv/jsenv_tests_output.txt +2 -2
- package/template-web-preact/package.json +2 -2
- package/template-web-react/.jsenv/chrome@127.00/@fs/Users/damien.maillard/dev/perso/jsenv-core/packages/independent/assert/dist/jsenv_assert_browser.js +247 -105
- package/template-web-react/.jsenv/chrome@127.00/tests/animals.test.html@L13C5-L30C14.js +2 -2
- package/template-web-react/.jsenv/chrome@127.00/tests/animals.test.html@L13C5-L30C14.js.map +4 -4
- package/template-web-react/.jsenv/craft/cjs_to_esm/@fs/Users/damien.maillard/dev/perso/jsenv-core/node_modules/react/index.production.js__compile_info__.json +2 -2
- package/template-web-react/.jsenv/craft/cjs_to_esm/@fs/Users/damien.maillard/dev/perso/jsenv-core/node_modules/react/jsx-runtime.production.js__compile_info__.json +2 -2
- package/template-web-react/.jsenv/craft/cjs_to_esm/@fs/Users/damien.maillard/dev/perso/jsenv-core/node_modules/react-dom/client.production.js__compile_info__.json +2 -2
- package/template-web-react/.jsenv/jsenv_tests_output.txt +3 -3
- package/template-web-react/package.json +2 -2
|
@@ -132,7 +132,9 @@ function stripAnsi(string) {
|
|
|
132
132
|
return string.replace(regex, '');
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
-
const truncateAndApplyColor = (valueDiff, node, props
|
|
135
|
+
const truncateAndApplyColor = (valueDiff, node, props, {
|
|
136
|
+
chirurgicalColor
|
|
137
|
+
} = {}) => {
|
|
136
138
|
const {
|
|
137
139
|
columnsRemaining
|
|
138
140
|
} = props;
|
|
@@ -169,10 +171,13 @@ const truncateAndApplyColor = (valueDiff, node, props) => {
|
|
|
169
171
|
if (endMarker) {
|
|
170
172
|
diff += endMarker;
|
|
171
173
|
}
|
|
172
|
-
diff = applyStyles(node, diff
|
|
174
|
+
diff = applyStyles(node, diff, {
|
|
175
|
+
chirurgicalColor
|
|
176
|
+
});
|
|
173
177
|
return diff;
|
|
174
178
|
};
|
|
175
179
|
const applyStyles = (node, text, {
|
|
180
|
+
chirurgicalColor,
|
|
176
181
|
color = node.color,
|
|
177
182
|
underline = true
|
|
178
183
|
} = {}) => {
|
|
@@ -228,6 +233,28 @@ const applyStyles = (node, text, {
|
|
|
228
233
|
}
|
|
229
234
|
shouldAddColor = true;
|
|
230
235
|
}
|
|
236
|
+
if (chirurgicalColor && chirurgicalColor.color !== color) {
|
|
237
|
+
let stylized = "";
|
|
238
|
+
const before = text.slice(0, chirurgicalColor.start);
|
|
239
|
+
const middle = text.slice(chirurgicalColor.start, chirurgicalColor.end);
|
|
240
|
+
const after = text.slice(chirurgicalColor.end);
|
|
241
|
+
if (shouldAddUnderline) {
|
|
242
|
+
stylized += ANSI.effect(before, ANSI.UNDERLINE);
|
|
243
|
+
}
|
|
244
|
+
if (shouldAddColor) {
|
|
245
|
+
stylized = ANSI.color(before, color);
|
|
246
|
+
}
|
|
247
|
+
if (shouldAddColor) {
|
|
248
|
+
stylized += ANSI.color(middle, chirurgicalColor.color);
|
|
249
|
+
}
|
|
250
|
+
if (shouldAddUnderline) {
|
|
251
|
+
stylized += ANSI.effect(before, ANSI.UNDERLINE);
|
|
252
|
+
}
|
|
253
|
+
if (shouldAddColor) {
|
|
254
|
+
stylized += ANSI.color(after, color);
|
|
255
|
+
}
|
|
256
|
+
return stylized;
|
|
257
|
+
}
|
|
231
258
|
if (shouldAddUnderline) {
|
|
232
259
|
text = ANSI.effect(text, ANSI.UNDERLINE);
|
|
233
260
|
}
|
|
@@ -449,7 +476,7 @@ const renderComposite = (node, props) => {
|
|
|
449
476
|
maxDepthReached = nodeDepth > props.MAX_DEPTH_INSIDE_DIFF;
|
|
450
477
|
}
|
|
451
478
|
const compositePartsNode = node.childNodeMap.get("parts");
|
|
452
|
-
if (maxDepthReached) {
|
|
479
|
+
if (maxDepthReached || node.maxDiffReached) {
|
|
453
480
|
node.startMarker = node.endMarker = "";
|
|
454
481
|
if (node.isStringObject) {
|
|
455
482
|
const length = node.value.length;
|
|
@@ -458,11 +485,28 @@ const renderComposite = (node, props) => {
|
|
|
458
485
|
const indexedEntriesNode = compositePartsNode.childNodeMap.get("indexed_entries");
|
|
459
486
|
if (indexedEntriesNode) {
|
|
460
487
|
const length = indexedEntriesNode.childNodeMap.size;
|
|
461
|
-
|
|
488
|
+
const childrenColor = pickColorFromChildren(indexedEntriesNode) || node.color;
|
|
489
|
+
return truncateAndApplyColor("".concat(node.objectTag, "(").concat(length, ")"), node, props, {
|
|
490
|
+
chirurgicalColor: {
|
|
491
|
+
start: "".concat(node.objectTag, "(").length,
|
|
492
|
+
end: "".concat(node.objectTag, "(").concat(length).length,
|
|
493
|
+
color: childrenColor
|
|
494
|
+
}
|
|
495
|
+
});
|
|
462
496
|
}
|
|
463
497
|
const ownPropertiesNode = compositePartsNode.childNodeMap.get("own_properties");
|
|
498
|
+
if (!ownPropertiesNode) {
|
|
499
|
+
return truncateAndApplyColor("".concat(node.objectTag), node, props);
|
|
500
|
+
}
|
|
464
501
|
const ownPropertyCount = ownPropertiesNode.childNodeMap.size;
|
|
465
|
-
|
|
502
|
+
const childrenColor = pickColorFromChildren(ownPropertiesNode) || node.color;
|
|
503
|
+
return truncateAndApplyColor("".concat(node.objectTag, "(").concat(ownPropertyCount, ")"), node, props, {
|
|
504
|
+
chirurgicalColor: {
|
|
505
|
+
start: "".concat(node.objectTag, "(").length,
|
|
506
|
+
end: "".concat(node.objectTag, "(").concat(ownPropertyCount).length,
|
|
507
|
+
color: childrenColor
|
|
508
|
+
}
|
|
509
|
+
});
|
|
466
510
|
}
|
|
467
511
|
return compositePartsNode.render(props);
|
|
468
512
|
};
|
|
@@ -1025,7 +1069,7 @@ const renderChildrenMultiline = (node, props) => {
|
|
|
1025
1069
|
childIndexToDisplayArray = [0];
|
|
1026
1070
|
} else {
|
|
1027
1071
|
if (otherNode.placeholder) {
|
|
1028
|
-
setChildKeyToDisplaySetSolo(node
|
|
1072
|
+
setChildKeyToDisplaySetSolo(node);
|
|
1029
1073
|
} else {
|
|
1030
1074
|
setChildKeyToDisplaySetDuo(node, otherNode, props);
|
|
1031
1075
|
}
|
|
@@ -1127,13 +1171,13 @@ const renderChildrenMultiline = (node, props) => {
|
|
|
1127
1171
|
skippedChildIndex++;
|
|
1128
1172
|
const skippedChildKey = childrenKeys[skippedChildIndex];
|
|
1129
1173
|
const skippedChild = node.childNodeMap.get(skippedChildKey);
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
modifiedColor = skippedChild.color;
|
|
1133
|
-
}
|
|
1134
|
-
if (skippedChild.diffType === "solo") {
|
|
1174
|
+
const overallReasons = skippedChild.comparison.reasons.overall;
|
|
1175
|
+
if (overallReasons.added.size || overallReasons.removed.size) {
|
|
1135
1176
|
soloCount++;
|
|
1136
1177
|
soloColor = skippedChild.color;
|
|
1178
|
+
} else if (overallReasons.modified.size) {
|
|
1179
|
+
modifiedCount++;
|
|
1180
|
+
modifiedColor = skippedChild.color;
|
|
1137
1181
|
}
|
|
1138
1182
|
}
|
|
1139
1183
|
const allModified = modifiedCount === skippedCount;
|
|
@@ -1298,7 +1342,7 @@ const renderChildrenMultiline = (node, props) => {
|
|
|
1298
1342
|
diff += applyStyles(node, endMarker);
|
|
1299
1343
|
return diff;
|
|
1300
1344
|
};
|
|
1301
|
-
const setChildKeyToDisplaySetSolo =
|
|
1345
|
+
const setChildKeyToDisplaySetSolo = node => {
|
|
1302
1346
|
/*
|
|
1303
1347
|
* For a solo node:
|
|
1304
1348
|
* - All child has a diff (all added or removed)
|
|
@@ -1306,19 +1350,10 @@ const setChildKeyToDisplaySetSolo = (node, props) => {
|
|
|
1306
1350
|
*/
|
|
1307
1351
|
const childrenKeys = node.childrenKeys;
|
|
1308
1352
|
const childKeyToDisplaySet = new Set();
|
|
1309
|
-
const {
|
|
1310
|
-
maxDiff
|
|
1311
|
-
} = getMaxDiffOptions(node, props);
|
|
1312
|
-
let maxDiffReached = false;
|
|
1313
|
-
let diffCount = 0;
|
|
1314
1353
|
for (const childKey of childrenKeys) {
|
|
1315
|
-
if (maxDiffReached) {
|
|
1316
|
-
break;
|
|
1317
|
-
}
|
|
1318
1354
|
const childNode = node.childNodeMap.get(childKey);
|
|
1319
|
-
if (
|
|
1320
|
-
|
|
1321
|
-
maxDiffReached = diffCount > maxDiff;
|
|
1355
|
+
if (childNode.maxDiffReached) {
|
|
1356
|
+
break;
|
|
1322
1357
|
}
|
|
1323
1358
|
childKeyToDisplaySet.add(childKey);
|
|
1324
1359
|
}
|
|
@@ -1350,32 +1385,22 @@ const setChildKeyToDisplaySetDuo = (actualNode, expectNode, props) => {
|
|
|
1350
1385
|
firstChildWithDiffKey
|
|
1351
1386
|
} = referenceNode;
|
|
1352
1387
|
const {
|
|
1353
|
-
maxDiff,
|
|
1354
1388
|
maxChildBeforeDiff,
|
|
1355
1389
|
maxChildAfterDiff
|
|
1356
1390
|
} = getMaxDiffOptions(referenceNode, props);
|
|
1357
1391
|
const firstChildWithDiffIndex = childrenKeys.indexOf(firstChildWithDiffKey);
|
|
1358
1392
|
let childIndex = firstChildWithDiffIndex;
|
|
1359
|
-
let maxDiffReached = false;
|
|
1360
|
-
let diffCount = 0;
|
|
1361
1393
|
while (childIndex < childrenKeys.length) {
|
|
1362
|
-
if (maxDiffReached) {
|
|
1363
|
-
break;
|
|
1364
|
-
}
|
|
1365
1394
|
const childKey = childrenKeys[childIndex];
|
|
1366
1395
|
childIndex++;
|
|
1367
1396
|
const childNode = referenceNode.childNodeMap.get(childKey);
|
|
1368
|
-
if (
|
|
1369
|
-
|
|
1397
|
+
if (childNode.maxDiffReached) {
|
|
1398
|
+
break;
|
|
1370
1399
|
}
|
|
1371
1400
|
if (!childNode.comparison.hasAnyDiff) {
|
|
1372
1401
|
continue;
|
|
1373
1402
|
}
|
|
1374
1403
|
childKeyWithDiffSet.add(childKey);
|
|
1375
|
-
if (isSourceCodeProperty(childNode)) ; else {
|
|
1376
|
-
diffCount++;
|
|
1377
|
-
maxDiffReached = diffCount > maxDiff;
|
|
1378
|
-
}
|
|
1379
1404
|
}
|
|
1380
1405
|
for (const childKey of childKeyWithDiffSet) {
|
|
1381
1406
|
const childIndex = childrenKeys.indexOf(childKey);
|
|
@@ -1389,7 +1414,8 @@ const setChildKeyToDisplaySetDuo = (actualNode, expectNode, props) => {
|
|
|
1389
1414
|
}
|
|
1390
1415
|
let index = fromIndex;
|
|
1391
1416
|
while (index !== toIndex) {
|
|
1392
|
-
|
|
1417
|
+
const childKeyBefore = childrenKeys[index];
|
|
1418
|
+
referenceChildKeyToDisplaySet.add(childKeyBefore);
|
|
1393
1419
|
index++;
|
|
1394
1420
|
}
|
|
1395
1421
|
}
|
|
@@ -1404,7 +1430,12 @@ const setChildKeyToDisplaySetDuo = (actualNode, expectNode, props) => {
|
|
|
1404
1430
|
}
|
|
1405
1431
|
let index = fromIndex;
|
|
1406
1432
|
while (index !== toIndex) {
|
|
1407
|
-
|
|
1433
|
+
const childKeyAfter = childrenKeys[index];
|
|
1434
|
+
const childNodeAfter = referenceNode.childNodeMap.get(childKeyAfter);
|
|
1435
|
+
if (childNodeAfter.maxDiffReached) {
|
|
1436
|
+
break;
|
|
1437
|
+
}
|
|
1438
|
+
referenceChildKeyToDisplaySet.add(childKeyAfter);
|
|
1408
1439
|
index++;
|
|
1409
1440
|
}
|
|
1410
1441
|
}
|
|
@@ -1427,15 +1458,12 @@ const getMaxDiffOptions = (node, props) => {
|
|
|
1427
1458
|
maxDiffType = "prop"
|
|
1428
1459
|
} = node.multilineDiff;
|
|
1429
1460
|
const {
|
|
1430
|
-
MAX_DIFF_INSIDE_VALUE,
|
|
1431
1461
|
MAX_CONTEXT_BEFORE_DIFF,
|
|
1432
1462
|
MAX_CONTEXT_AFTER_DIFF
|
|
1433
1463
|
} = props;
|
|
1434
|
-
const maxDiff = typeof MAX_DIFF_INSIDE_VALUE === "number" ? MAX_DIFF_INSIDE_VALUE : MAX_DIFF_INSIDE_VALUE[maxDiffType];
|
|
1435
1464
|
const maxChildBeforeDiff = typeof MAX_CONTEXT_BEFORE_DIFF === "number" ? MAX_CONTEXT_BEFORE_DIFF : MAX_CONTEXT_BEFORE_DIFF[maxDiffType];
|
|
1436
1465
|
const maxChildAfterDiff = typeof MAX_CONTEXT_AFTER_DIFF === "number" ? MAX_CONTEXT_AFTER_DIFF : MAX_CONTEXT_AFTER_DIFF[maxDiffType];
|
|
1437
1466
|
return {
|
|
1438
|
-
maxDiff,
|
|
1439
1467
|
maxChildBeforeDiff,
|
|
1440
1468
|
maxChildAfterDiff
|
|
1441
1469
|
};
|
|
@@ -1503,6 +1531,18 @@ const shouldDisableSeparator = (childIndex, childrenKeys, {
|
|
|
1503
1531
|
}
|
|
1504
1532
|
return false;
|
|
1505
1533
|
};
|
|
1534
|
+
const pickColorFromChildren = node => {
|
|
1535
|
+
let color;
|
|
1536
|
+
for (const [, childNode] of node.childNodeMap) {
|
|
1537
|
+
if (childNode.diffType === "modified") {
|
|
1538
|
+
return childNode.color;
|
|
1539
|
+
}
|
|
1540
|
+
if (childNode.diffType === "solo") {
|
|
1541
|
+
color = childNode.color;
|
|
1542
|
+
}
|
|
1543
|
+
}
|
|
1544
|
+
return color;
|
|
1545
|
+
};
|
|
1506
1546
|
|
|
1507
1547
|
// canParseDate can be called on any string
|
|
1508
1548
|
// so we want to be sure it's a date before handling it as such
|
|
@@ -1993,8 +2033,6 @@ const symbolToDescription$1 = symbol => {
|
|
|
1993
2033
|
* This file is named "scratch" as a testimony of the fact it has been
|
|
1994
2034
|
* recoded from scratch around april 2024
|
|
1995
2035
|
*
|
|
1996
|
-
* To fix:
|
|
1997
|
-
* - Error: is a valid url ???
|
|
1998
2036
|
* Nice to have:
|
|
1999
2037
|
* - preact signals
|
|
2000
2038
|
* - a DOM node should be converted to outerHTML right?
|
|
@@ -2065,9 +2103,11 @@ const defaultOptions = {
|
|
|
2065
2103
|
expect: undefined,
|
|
2066
2104
|
MAX_DEPTH: 5,
|
|
2067
2105
|
MAX_DEPTH_INSIDE_DIFF: 2,
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2106
|
+
MAX_DIFF: 15,
|
|
2107
|
+
MAX_DIFF_PER_VALUE: {
|
|
2108
|
+
"prop": 2,
|
|
2109
|
+
"line": 1,
|
|
2110
|
+
"*": 5
|
|
2071
2111
|
},
|
|
2072
2112
|
MAX_CONTEXT_BEFORE_DIFF: {
|
|
2073
2113
|
prop: 2,
|
|
@@ -2078,6 +2118,8 @@ const defaultOptions = {
|
|
|
2078
2118
|
line: 3
|
|
2079
2119
|
},
|
|
2080
2120
|
MAX_COLUMNS: 100,
|
|
2121
|
+
order: "natural",
|
|
2122
|
+
// "natural", "sort"
|
|
2081
2123
|
forceMultilineDiff: false,
|
|
2082
2124
|
message: "",
|
|
2083
2125
|
details: ""
|
|
@@ -2115,10 +2157,12 @@ const createAssert = ({
|
|
|
2115
2157
|
expect,
|
|
2116
2158
|
MAX_DEPTH,
|
|
2117
2159
|
MAX_DEPTH_INSIDE_DIFF,
|
|
2118
|
-
|
|
2160
|
+
MAX_DIFF,
|
|
2161
|
+
MAX_DIFF_PER_VALUE,
|
|
2119
2162
|
MAX_CONTEXT_BEFORE_DIFF,
|
|
2120
2163
|
MAX_CONTEXT_AFTER_DIFF,
|
|
2121
2164
|
MAX_COLUMNS,
|
|
2165
|
+
order,
|
|
2122
2166
|
forceMultilineDiff,
|
|
2123
2167
|
message,
|
|
2124
2168
|
details
|
|
@@ -2131,7 +2175,8 @@ const createAssert = ({
|
|
|
2131
2175
|
getWellKnownValuePath,
|
|
2132
2176
|
tokenizeString,
|
|
2133
2177
|
measureStringWidth,
|
|
2134
|
-
assert
|
|
2178
|
+
assert,
|
|
2179
|
+
order
|
|
2135
2180
|
};
|
|
2136
2181
|
const actualRootNode = createRootNode({
|
|
2137
2182
|
context: {
|
|
@@ -2190,14 +2235,44 @@ const createAssert = ({
|
|
|
2190
2235
|
*/
|
|
2191
2236
|
let isNot = false;
|
|
2192
2237
|
let allowRecompare = false;
|
|
2193
|
-
|
|
2238
|
+
let diffCount = 0;
|
|
2239
|
+
let maxDiffReached = false;
|
|
2240
|
+
const compare = (actualNode, expectNode, {
|
|
2241
|
+
onDiffCallback
|
|
2242
|
+
} = {}) => {
|
|
2194
2243
|
if (actualNode.ignore && actualNode.comparison) {
|
|
2195
2244
|
return actualNode.comparison;
|
|
2196
2245
|
}
|
|
2197
2246
|
if (expectNode.ignore && expectNode.comparison) {
|
|
2198
2247
|
return expectNode.comparison;
|
|
2199
2248
|
}
|
|
2249
|
+
let maxDiffPerValue;
|
|
2250
|
+
if (typeof MAX_DIFF_PER_VALUE === "number") {
|
|
2251
|
+
maxDiffPerValue = MAX_DIFF_PER_VALUE;
|
|
2252
|
+
} else {
|
|
2253
|
+
const node = actualNode.placeholder ? expectNode : actualNode;
|
|
2254
|
+
const valueType = node.subgroup === "line_entries" ? "line" : node.subgroup === "own_properties" ? "prop" : node.subgroup === "indexed_entries" ? "index" : "other";
|
|
2255
|
+
if (valueType in MAX_DIFF_PER_VALUE) {
|
|
2256
|
+
maxDiffPerValue = MAX_DIFF_PER_VALUE[valueType];
|
|
2257
|
+
} else if ("*" in MAX_DIFF_PER_VALUE) {
|
|
2258
|
+
maxDiffPerValue = MAX_DIFF_PER_VALUE["*"];
|
|
2259
|
+
} else if ("prop" in MAX_DIFF_PER_VALUE) {
|
|
2260
|
+
maxDiffPerValue = MAX_DIFF_PER_VALUE.prop;
|
|
2261
|
+
} else {
|
|
2262
|
+
maxDiffPerValue = Infinity;
|
|
2263
|
+
}
|
|
2264
|
+
}
|
|
2265
|
+
let maxDiffPerValueReached = false;
|
|
2266
|
+
let diffPerValueCounter = 0;
|
|
2200
2267
|
const reasons = createReasons();
|
|
2268
|
+
if (maxDiffReached) {
|
|
2269
|
+
if (!actualNode.placeholder) {
|
|
2270
|
+
actualNode.maxDiffReached = true;
|
|
2271
|
+
}
|
|
2272
|
+
if (!expectNode.placeholder) {
|
|
2273
|
+
expectNode.maxDiffReached = true;
|
|
2274
|
+
}
|
|
2275
|
+
}
|
|
2201
2276
|
const comparison = {
|
|
2202
2277
|
actualNode,
|
|
2203
2278
|
expectNode,
|
|
@@ -2210,17 +2285,46 @@ const createAssert = ({
|
|
|
2210
2285
|
if (!expectNode.placeholder) {
|
|
2211
2286
|
expectNode.otherNode = actualNode;
|
|
2212
2287
|
}
|
|
2288
|
+
const onDiff = node => {
|
|
2289
|
+
if (isSourceCodeProperty(node)) {
|
|
2290
|
+
return;
|
|
2291
|
+
}
|
|
2292
|
+
diffCount++;
|
|
2293
|
+
if (!maxDiffReached && diffCount >= MAX_DIFF) {
|
|
2294
|
+
maxDiffReached = true;
|
|
2295
|
+
}
|
|
2296
|
+
onDiffCallback(node);
|
|
2297
|
+
};
|
|
2298
|
+
const onDuoDiff = node => {
|
|
2299
|
+
if (!node.isStandaloneDiff) {
|
|
2300
|
+
return;
|
|
2301
|
+
}
|
|
2302
|
+
onDiff(node);
|
|
2303
|
+
};
|
|
2304
|
+
const onSoloDiff = node => {
|
|
2305
|
+
if (!node.isStandaloneDiff) {
|
|
2306
|
+
return;
|
|
2307
|
+
}
|
|
2308
|
+
if (node.group === "entry_key") {
|
|
2309
|
+
// will be also reported by the value
|
|
2310
|
+
return;
|
|
2311
|
+
}
|
|
2312
|
+
onDiff(node);
|
|
2313
|
+
};
|
|
2213
2314
|
const onSelfDiff = reason => {
|
|
2214
2315
|
reasons.self.modified.add(reason);
|
|
2215
2316
|
causeSet.add(comparison);
|
|
2317
|
+
onDuoDiff(comparison.actualNode);
|
|
2216
2318
|
};
|
|
2217
2319
|
const onAdded = reason => {
|
|
2218
2320
|
reasons.self.added.add(reason);
|
|
2219
2321
|
causeSet.add(comparison);
|
|
2322
|
+
onSoloDiff(comparison.actualNode);
|
|
2220
2323
|
};
|
|
2221
2324
|
const onRemoved = reason => {
|
|
2222
2325
|
reasons.self.removed.add(reason);
|
|
2223
2326
|
causeSet.add(comparison);
|
|
2327
|
+
onSoloDiff(comparison.expectNode);
|
|
2224
2328
|
};
|
|
2225
2329
|
const subcompareDuo = (actualChildNode, expectChildNode, {
|
|
2226
2330
|
revertNot,
|
|
@@ -2233,7 +2337,23 @@ const createAssert = ({
|
|
|
2233
2337
|
if (isRecomparison) {
|
|
2234
2338
|
allowRecompare = true;
|
|
2235
2339
|
}
|
|
2236
|
-
|
|
2340
|
+
if (maxDiffPerValueReached) {
|
|
2341
|
+
if (!actualChildNode.placeholder) {
|
|
2342
|
+
actualChildNode.maxDiffReached = true;
|
|
2343
|
+
}
|
|
2344
|
+
if (!expectChildNode.placeholder) {
|
|
2345
|
+
expectChildNode.maxDiffReached = true;
|
|
2346
|
+
}
|
|
2347
|
+
}
|
|
2348
|
+
const childComparison = compare(actualChildNode, expectChildNode, {
|
|
2349
|
+
onDiffCallback: node => {
|
|
2350
|
+
onDiffCallback(node);
|
|
2351
|
+
diffPerValueCounter++;
|
|
2352
|
+
if (!maxDiffPerValueReached && diffPerValueCounter >= maxDiffPerValue) {
|
|
2353
|
+
maxDiffPerValueReached = true;
|
|
2354
|
+
}
|
|
2355
|
+
}
|
|
2356
|
+
});
|
|
2237
2357
|
isNot = isNotPrevious;
|
|
2238
2358
|
appendReasonGroup(comparison.reasons.inside, childComparison.reasons.overall);
|
|
2239
2359
|
return childComparison;
|
|
@@ -2248,92 +2368,100 @@ const createAssert = ({
|
|
|
2248
2368
|
const isSetEntriesComparison = actualNode.subgroup === "set_entries" && expectNode.subgroup === "set_entries";
|
|
2249
2369
|
const childComparisonMap = new Map();
|
|
2250
2370
|
const childComparisonDiffMap = new Map();
|
|
2371
|
+
const referenceNode = expectNode;
|
|
2372
|
+
const otherNode = actualNode;
|
|
2251
2373
|
{
|
|
2252
|
-
const
|
|
2253
|
-
let
|
|
2254
|
-
for (let [childKey,
|
|
2255
|
-
let
|
|
2374
|
+
const childrenKeys = [];
|
|
2375
|
+
let firstChildWithDiffKey;
|
|
2376
|
+
for (let [childKey, childNode] of referenceNode.childNodeMap) {
|
|
2377
|
+
let otherChildNode;
|
|
2256
2378
|
if (isSetEntriesComparison) {
|
|
2257
|
-
const
|
|
2258
|
-
for (const [,
|
|
2259
|
-
if (
|
|
2260
|
-
|
|
2379
|
+
const setValueNode = childNode;
|
|
2380
|
+
for (const [, otherSetValueNode] of otherNode.childNodeMap) {
|
|
2381
|
+
if (otherSetValueNode.value === setValueNode.value) {
|
|
2382
|
+
otherChildNode = otherSetValueNode;
|
|
2261
2383
|
break;
|
|
2262
2384
|
}
|
|
2263
2385
|
}
|
|
2264
2386
|
} else {
|
|
2265
|
-
|
|
2387
|
+
otherChildNode = otherNode.childNodeMap.get(childKey);
|
|
2266
2388
|
}
|
|
2267
|
-
if (
|
|
2268
|
-
const childComparison = subcompareDuo(
|
|
2389
|
+
if (childNode && otherChildNode) {
|
|
2390
|
+
const childComparison = subcompareDuo(otherChildNode, childNode);
|
|
2269
2391
|
childComparisonMap.set(childKey, childComparison);
|
|
2270
2392
|
if (childComparison.hasAnyDiff) {
|
|
2271
2393
|
childComparisonDiffMap.set(childKey, childComparison);
|
|
2272
2394
|
}
|
|
2273
|
-
if (!
|
|
2274
|
-
|
|
2275
|
-
if (childComparison.hasAnyDiff &&
|
|
2276
|
-
|
|
2395
|
+
if (!childNode.isHidden) {
|
|
2396
|
+
childrenKeys.push(childKey);
|
|
2397
|
+
if (childComparison.hasAnyDiff && firstChildWithDiffKey === undefined) {
|
|
2398
|
+
firstChildWithDiffKey = childKey;
|
|
2277
2399
|
}
|
|
2278
2400
|
}
|
|
2279
2401
|
continue;
|
|
2280
2402
|
}
|
|
2281
|
-
const
|
|
2282
|
-
childComparisonMap.set(childKey,
|
|
2283
|
-
childComparisonDiffMap.set(childKey,
|
|
2284
|
-
if (!
|
|
2285
|
-
|
|
2286
|
-
if (
|
|
2287
|
-
|
|
2403
|
+
const removedChildComparison = subcompareSolo(childNode, PLACEHOLDER_WHEN_ADDED_OR_REMOVED);
|
|
2404
|
+
childComparisonMap.set(childKey, removedChildComparison);
|
|
2405
|
+
childComparisonDiffMap.set(childKey, removedChildComparison);
|
|
2406
|
+
if (!childNode.isHidden) {
|
|
2407
|
+
childrenKeys.push(childKey);
|
|
2408
|
+
if (firstChildWithDiffKey === undefined) {
|
|
2409
|
+
firstChildWithDiffKey = childKey;
|
|
2288
2410
|
}
|
|
2289
2411
|
}
|
|
2290
2412
|
}
|
|
2291
|
-
|
|
2292
|
-
|
|
2413
|
+
if (referenceNode.context.order === "sort") {
|
|
2414
|
+
childrenKeys.sort();
|
|
2415
|
+
}
|
|
2416
|
+
referenceNode.childrenKeys = childrenKeys;
|
|
2417
|
+
referenceNode.firstChildWithDiffKey = firstChildWithDiffKey;
|
|
2293
2418
|
}
|
|
2294
2419
|
{
|
|
2295
|
-
const
|
|
2296
|
-
let
|
|
2297
|
-
for (let [childKey,
|
|
2420
|
+
const childrenKeys = [];
|
|
2421
|
+
let firstChildWithDiffKey;
|
|
2422
|
+
for (let [childKey, childNode] of otherNode.childNodeMap) {
|
|
2298
2423
|
if (isSetEntriesComparison) {
|
|
2299
|
-
const
|
|
2424
|
+
const setValueNode = childNode;
|
|
2300
2425
|
let hasEntry;
|
|
2301
|
-
for (const [,
|
|
2302
|
-
if (
|
|
2426
|
+
for (const [, referenceSetValueNode] of referenceNode.childNodeMap) {
|
|
2427
|
+
if (referenceSetValueNode.value === setValueNode.value) {
|
|
2303
2428
|
hasEntry = true;
|
|
2304
2429
|
break;
|
|
2305
2430
|
}
|
|
2306
2431
|
}
|
|
2307
2432
|
if (hasEntry) {
|
|
2308
|
-
if (!
|
|
2309
|
-
|
|
2433
|
+
if (!childNode.isHidden) {
|
|
2434
|
+
childrenKeys.push(childKey);
|
|
2310
2435
|
}
|
|
2311
2436
|
continue;
|
|
2312
2437
|
}
|
|
2313
2438
|
} else {
|
|
2314
2439
|
const childComparison = childComparisonMap.get(childKey);
|
|
2315
2440
|
if (childComparison) {
|
|
2316
|
-
if (!
|
|
2317
|
-
|
|
2318
|
-
if (childComparison.hasAnyDiff &&
|
|
2319
|
-
|
|
2441
|
+
if (!childNode.isHidden) {
|
|
2442
|
+
childrenKeys.push(childKey);
|
|
2443
|
+
if (childComparison.hasAnyDiff && firstChildWithDiffKey === undefined) {
|
|
2444
|
+
firstChildWithDiffKey = childKey;
|
|
2320
2445
|
}
|
|
2321
2446
|
}
|
|
2322
2447
|
continue;
|
|
2323
2448
|
}
|
|
2324
2449
|
}
|
|
2325
|
-
const
|
|
2326
|
-
childComparisonMap.set(childKey,
|
|
2327
|
-
childComparisonDiffMap.set(childKey,
|
|
2328
|
-
if (!
|
|
2329
|
-
|
|
2330
|
-
if (
|
|
2331
|
-
|
|
2450
|
+
const addedChildComparison = subcompareSolo(childNode, PLACEHOLDER_WHEN_ADDED_OR_REMOVED);
|
|
2451
|
+
childComparisonMap.set(childKey, addedChildComparison);
|
|
2452
|
+
childComparisonDiffMap.set(childKey, addedChildComparison);
|
|
2453
|
+
if (!childNode.isHidden) {
|
|
2454
|
+
childrenKeys.push(childKey);
|
|
2455
|
+
if (firstChildWithDiffKey === undefined) {
|
|
2456
|
+
firstChildWithDiffKey = childKey;
|
|
2332
2457
|
}
|
|
2333
2458
|
}
|
|
2334
2459
|
}
|
|
2335
|
-
|
|
2336
|
-
|
|
2460
|
+
if (otherNode.context.order === "sort") {
|
|
2461
|
+
childrenKeys.sort();
|
|
2462
|
+
}
|
|
2463
|
+
otherNode.childrenKeys = childrenKeys;
|
|
2464
|
+
otherNode.firstChildWithDiffKey = firstChildWithDiffKey;
|
|
2337
2465
|
}
|
|
2338
2466
|
actualNode.childComparisonDiffMap = childComparisonDiffMap;
|
|
2339
2467
|
expectNode.childComparisonDiffMap = childComparisonDiffMap;
|
|
@@ -2354,6 +2482,9 @@ const createAssert = ({
|
|
|
2354
2482
|
}
|
|
2355
2483
|
}
|
|
2356
2484
|
}
|
|
2485
|
+
if (node.context.order === "sort") {
|
|
2486
|
+
childrenKeys.sort();
|
|
2487
|
+
}
|
|
2357
2488
|
node.childrenKeys = childrenKeys;
|
|
2358
2489
|
node.firstChildWithDiffKey = firstChildWithDiffKey;
|
|
2359
2490
|
node.childComparisonDiffMap = childComparisonDiffMap;
|
|
@@ -2584,7 +2715,9 @@ const createAssert = ({
|
|
|
2584
2715
|
}
|
|
2585
2716
|
return comparison;
|
|
2586
2717
|
};
|
|
2587
|
-
const rootComparison = compare(actualRootNode, expectRootNode
|
|
2718
|
+
const rootComparison = compare(actualRootNode, expectRootNode, {
|
|
2719
|
+
onDiffCallback: () => {}
|
|
2720
|
+
});
|
|
2588
2721
|
if (!rootComparison.hasAnyDiff) {
|
|
2589
2722
|
return;
|
|
2590
2723
|
}
|
|
@@ -2670,7 +2803,6 @@ const createAssert = ({
|
|
|
2670
2803
|
const actualDiff = actualStartNode.render({
|
|
2671
2804
|
MAX_DEPTH,
|
|
2672
2805
|
MAX_DEPTH_INSIDE_DIFF,
|
|
2673
|
-
MAX_DIFF_INSIDE_VALUE,
|
|
2674
2806
|
MAX_CONTEXT_BEFORE_DIFF,
|
|
2675
2807
|
MAX_CONTEXT_AFTER_DIFF,
|
|
2676
2808
|
MAX_COLUMNS,
|
|
@@ -2687,7 +2819,6 @@ const createAssert = ({
|
|
|
2687
2819
|
const expectDiff = expectStartNode.render({
|
|
2688
2820
|
MAX_DEPTH,
|
|
2689
2821
|
MAX_DEPTH_INSIDE_DIFF,
|
|
2690
|
-
MAX_DIFF_INSIDE_VALUE,
|
|
2691
2822
|
MAX_CONTEXT_BEFORE_DIFF,
|
|
2692
2823
|
MAX_CONTEXT_AFTER_DIFF,
|
|
2693
2824
|
MAX_COLUMNS,
|
|
@@ -3227,7 +3358,8 @@ let createRootNode;
|
|
|
3227
3358
|
renderOptions = renderOptionsDefault,
|
|
3228
3359
|
onelineDiff = null,
|
|
3229
3360
|
multilineDiff = null,
|
|
3230
|
-
stringDiffPrecision = "per_line_and_per_char"
|
|
3361
|
+
stringDiffPrecision = "per_line_and_per_char",
|
|
3362
|
+
isStandaloneDiff = false
|
|
3231
3363
|
}) => {
|
|
3232
3364
|
const node = {
|
|
3233
3365
|
context,
|
|
@@ -3252,6 +3384,7 @@ let createRootNode;
|
|
|
3252
3384
|
isStringForUrl,
|
|
3253
3385
|
isStringForDate,
|
|
3254
3386
|
isBody,
|
|
3387
|
+
isStandaloneDiff,
|
|
3255
3388
|
// info
|
|
3256
3389
|
isCustomExpectation: false,
|
|
3257
3390
|
// info/primitive
|
|
@@ -3302,6 +3435,7 @@ let createRootNode;
|
|
|
3302
3435
|
rangeToDisplay: null,
|
|
3303
3436
|
displayedRange: null,
|
|
3304
3437
|
childKeyToDisplaySet: null,
|
|
3438
|
+
maxDiffReached: false,
|
|
3305
3439
|
diffType: "",
|
|
3306
3440
|
otherNode: null,
|
|
3307
3441
|
// END will be set by comparison
|
|
@@ -4514,14 +4648,16 @@ let createRootNode;
|
|
|
4514
4648
|
render: renderValue,
|
|
4515
4649
|
separatorMarker: " => ",
|
|
4516
4650
|
group: "entry_key",
|
|
4517
|
-
subgroup: "map_entry_key"
|
|
4651
|
+
subgroup: "map_entry_key",
|
|
4652
|
+
isStandaloneDiff: true
|
|
4518
4653
|
});
|
|
4519
4654
|
mapEntryNode.appendChild("entry_value", {
|
|
4520
4655
|
value: mapEntryValue,
|
|
4521
4656
|
render: renderValue,
|
|
4522
4657
|
separatorMarker: ",",
|
|
4523
4658
|
group: "entry_value",
|
|
4524
|
-
subgroup: "map_entry_value"
|
|
4659
|
+
subgroup: "map_entry_value",
|
|
4660
|
+
isStandaloneDiff: true
|
|
4525
4661
|
});
|
|
4526
4662
|
}
|
|
4527
4663
|
objectTagCounterMap.clear();
|
|
@@ -4544,7 +4680,8 @@ let createRootNode;
|
|
|
4544
4680
|
subgroup: "set_entry",
|
|
4545
4681
|
path: setEntriesNode.path.append(index, {
|
|
4546
4682
|
isIndexedEntry: true
|
|
4547
|
-
})
|
|
4683
|
+
}),
|
|
4684
|
+
isStandaloneDiff: true
|
|
4548
4685
|
});
|
|
4549
4686
|
index++;
|
|
4550
4687
|
}
|
|
@@ -4590,7 +4727,8 @@ let createRootNode;
|
|
|
4590
4727
|
render: renderValue,
|
|
4591
4728
|
separatorMarker: ",",
|
|
4592
4729
|
group: "entry_value",
|
|
4593
|
-
subgroup: "url_search_param_entry_value"
|
|
4730
|
+
subgroup: "url_search_param_entry_value",
|
|
4731
|
+
isStandaloneDiff: true
|
|
4594
4732
|
});
|
|
4595
4733
|
}
|
|
4596
4734
|
}
|
|
@@ -4760,7 +4898,8 @@ let createRootNode;
|
|
|
4760
4898
|
subgroup: "array_entry_value",
|
|
4761
4899
|
path: arrayEntriesNode.path.append(index, {
|
|
4762
4900
|
isIndexedEntry: true
|
|
4763
|
-
})
|
|
4901
|
+
}),
|
|
4902
|
+
isStandaloneDiff: true
|
|
4764
4903
|
});
|
|
4765
4904
|
index++;
|
|
4766
4905
|
}
|
|
@@ -4810,7 +4949,8 @@ let createRootNode;
|
|
|
4810
4949
|
subgroup: "typed_array_entry_value",
|
|
4811
4950
|
path: typedEntriesNode.path.append(index, {
|
|
4812
4951
|
isIndexedEntry: true
|
|
4813
|
-
})
|
|
4952
|
+
}),
|
|
4953
|
+
isStandaloneDiff: true
|
|
4814
4954
|
});
|
|
4815
4955
|
index++;
|
|
4816
4956
|
}
|
|
@@ -5047,7 +5187,8 @@ let createRootNode;
|
|
|
5047
5187
|
isSourceCode,
|
|
5048
5188
|
isBody,
|
|
5049
5189
|
isFunctionPrototype,
|
|
5050
|
-
isClassPrototype
|
|
5190
|
+
isClassPrototype,
|
|
5191
|
+
isStandaloneDiff: true
|
|
5051
5192
|
});
|
|
5052
5193
|
}
|
|
5053
5194
|
},
|
|
@@ -5232,6 +5373,7 @@ const createArgEntriesNode = (node, {
|
|
|
5232
5373
|
separatorMarker: ",",
|
|
5233
5374
|
path: node.path.append(key || argIndex),
|
|
5234
5375
|
depth: node.depth,
|
|
5376
|
+
isStandaloneDiff: true,
|
|
5235
5377
|
...valueParams
|
|
5236
5378
|
});
|
|
5237
5379
|
};
|