@jsenv/snapshot 2.11.37 → 2.13.1
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/snapshot",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.13.1",
|
|
4
4
|
"description": "Snapshot testing",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -30,14 +30,14 @@
|
|
|
30
30
|
"/src/"
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@jsenv/assert": "4.4.
|
|
34
|
-
"@jsenv/ast": "6.
|
|
35
|
-
"@jsenv/exception": "1.1.
|
|
36
|
-
"@jsenv/humanize": "1.
|
|
37
|
-
"@jsenv/filesystem": "4.
|
|
38
|
-
"@jsenv/terminal-recorder": "1.
|
|
39
|
-
"@jsenv/urls": "2.6.
|
|
40
|
-
"@jsenv/utils": "2.
|
|
33
|
+
"@jsenv/assert": "4.4.3",
|
|
34
|
+
"@jsenv/ast": "6.6.0",
|
|
35
|
+
"@jsenv/exception": "1.1.5",
|
|
36
|
+
"@jsenv/humanize": "1.3.0",
|
|
37
|
+
"@jsenv/filesystem": "4.14.0",
|
|
38
|
+
"@jsenv/terminal-recorder": "1.5.1",
|
|
39
|
+
"@jsenv/urls": "2.6.1",
|
|
40
|
+
"@jsenv/utils": "2.2.0",
|
|
41
41
|
"ansi-regex": "6.1.0",
|
|
42
42
|
"pixelmatch": "6.0.0",
|
|
43
43
|
"prettier": "3.4.2",
|
|
@@ -367,7 +367,13 @@ ${extraUrls.join("\n")}`);
|
|
|
367
367
|
try {
|
|
368
368
|
const directoryItemArray = readdirSync(directoryUrl);
|
|
369
369
|
for (const directoryItem of directoryItemArray) {
|
|
370
|
-
|
|
370
|
+
let directoryItemUrl;
|
|
371
|
+
if (directoryItem === "file:") {
|
|
372
|
+
// without this check it would create infinite loop
|
|
373
|
+
directoryItemUrl = new URL(`${directoryUrl}${directoryItem}`);
|
|
374
|
+
} else {
|
|
375
|
+
directoryItemUrl = new URL(directoryItem, directoryUrl);
|
|
376
|
+
}
|
|
371
377
|
let directoryItemStat;
|
|
372
378
|
try {
|
|
373
379
|
directoryItemStat = readEntryStatSync(directoryItemUrl);
|
|
@@ -156,6 +156,14 @@ export const replaceFluctuatingValues = (
|
|
|
156
156
|
if (Buffer.isBuffer(value)) {
|
|
157
157
|
return value;
|
|
158
158
|
}
|
|
159
|
+
if (value instanceof RegExp) {
|
|
160
|
+
let regexpSource = value.source;
|
|
161
|
+
if (regexpSource === "(?:)") {
|
|
162
|
+
regexpSource = "";
|
|
163
|
+
}
|
|
164
|
+
regexpSource = `/${regexpSource}/${value.flags}`;
|
|
165
|
+
return regexpSource;
|
|
166
|
+
}
|
|
159
167
|
const jsValueReplaced = replaceInObject(value, { replace: replaceThings });
|
|
160
168
|
return JSON.stringify(jsValueReplaced, null, " ");
|
|
161
169
|
}
|
|
@@ -188,7 +196,10 @@ const replaceInObject = (object, { replace }) => {
|
|
|
188
196
|
for (const keyToVisit of keysToVisit) {
|
|
189
197
|
const nestedValue = value[keyToVisit];
|
|
190
198
|
copy[keyToVisit] = deepCopy(nestedValue, {
|
|
191
|
-
shouldReplaceStrings:
|
|
199
|
+
shouldReplaceStrings:
|
|
200
|
+
shouldReplaceStrings ||
|
|
201
|
+
keyToVisit === "os" ||
|
|
202
|
+
keyToVisit === "date",
|
|
192
203
|
shouldReplaceNumbers:
|
|
193
204
|
shouldReplaceNumbers ||
|
|
194
205
|
keyToVisit === "timings" ||
|
|
@@ -227,12 +238,10 @@ const replaceHttpUrls = (source) => {
|
|
|
227
238
|
);
|
|
228
239
|
// we force "localhost" to "127.0.0.1"
|
|
229
240
|
// in case the machine does not have localhost mapping
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
},
|
|
235
|
-
);
|
|
241
|
+
// we also remove the port that can be dynamic
|
|
242
|
+
source = source.replace(/localhost(:\d+)?/g, () => {
|
|
243
|
+
return `127.0.0.1`;
|
|
244
|
+
});
|
|
236
245
|
// we force [::1] to "127.0.0.1"
|
|
237
246
|
// in case the machine does not have ipv6
|
|
238
247
|
source = source.replace(/(https?):\/\/\[::1\](:\d+)?/g, (match, protocol) => {
|