@jsenv/snapshot 2.7.3 → 2.7.5
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.7.
|
|
3
|
+
"version": "2.7.5",
|
|
4
4
|
"description": "Snapshot testing",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -33,12 +33,12 @@
|
|
|
33
33
|
"test": "node --conditions=development ./scripts/test.mjs"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@jsenv/assert": "4.1.
|
|
37
|
-
"@jsenv/ast": "6.2.
|
|
36
|
+
"@jsenv/assert": "4.1.14",
|
|
37
|
+
"@jsenv/ast": "6.2.13",
|
|
38
38
|
"@jsenv/exception": "1.0.1",
|
|
39
|
-
"@jsenv/filesystem": "4.9.
|
|
40
|
-
"@jsenv/terminal-recorder": "1.4.
|
|
41
|
-
"@jsenv/urls": "2.5.
|
|
39
|
+
"@jsenv/filesystem": "4.9.9",
|
|
40
|
+
"@jsenv/terminal-recorder": "1.4.3",
|
|
41
|
+
"@jsenv/urls": "2.5.2",
|
|
42
42
|
"@jsenv/utils": "2.1.2",
|
|
43
43
|
"ansi-regex": "6.0.1",
|
|
44
44
|
"pixelmatch": "6.0.0",
|
|
@@ -47,6 +47,18 @@ export const replaceFluctuatingValues = (
|
|
|
47
47
|
);
|
|
48
48
|
return value;
|
|
49
49
|
};
|
|
50
|
+
const replaceSizes = (value) => {
|
|
51
|
+
// the size of files might slighly differ from an OS to an other
|
|
52
|
+
// we round the floats to make them predictable
|
|
53
|
+
// (happens for HTML files where one char is added on linux)
|
|
54
|
+
value = value.replace(
|
|
55
|
+
/(?<!\d|\.)(\d+(?:\.\d+)?)(\s*)(B|kB|MB)\b/g,
|
|
56
|
+
(match, size, space, unit) => {
|
|
57
|
+
return `${Math.round(parseFloat(size))}${space}${unit}`;
|
|
58
|
+
},
|
|
59
|
+
);
|
|
60
|
+
return value;
|
|
61
|
+
};
|
|
50
62
|
const replaceThings = (value) => {
|
|
51
63
|
if (stringType === "filesystem") {
|
|
52
64
|
return replaceFilesystemWellKnownValues(value);
|
|
@@ -59,6 +71,7 @@ export const replaceFluctuatingValues = (
|
|
|
59
71
|
});
|
|
60
72
|
value = replaceHttpUrls(value);
|
|
61
73
|
value = replaceDurations(value);
|
|
74
|
+
value = replaceSizes(value);
|
|
62
75
|
return value;
|
|
63
76
|
};
|
|
64
77
|
if (stringType === "html" || stringType === "svg") {
|
|
@@ -259,7 +259,7 @@ export const createCaptureSideEffects = ({
|
|
|
259
259
|
});
|
|
260
260
|
};
|
|
261
261
|
const onFinally = () => {
|
|
262
|
-
delete process.env.
|
|
262
|
+
delete process.env.CAPTURING_SIDE_EFFECTS;
|
|
263
263
|
functionExecutingCount--;
|
|
264
264
|
for (const finallyCallback of finallyCallbackSet) {
|
|
265
265
|
finallyCallback(sideEffects);
|
|
@@ -267,7 +267,7 @@ export const createCaptureSideEffects = ({
|
|
|
267
267
|
finallyCallbackSet.clear();
|
|
268
268
|
};
|
|
269
269
|
|
|
270
|
-
process.env.
|
|
270
|
+
process.env.CAPTURING_SIDE_EFFECTS = "1";
|
|
271
271
|
functionExecutingCount++;
|
|
272
272
|
let returnedPromise = false;
|
|
273
273
|
try {
|
|
@@ -86,7 +86,6 @@ export const spyFilesystemCalls = (
|
|
|
86
86
|
onWriteDirectory(directoryUrl);
|
|
87
87
|
}
|
|
88
88
|
};
|
|
89
|
-
const beforeUndoCallbackSet = new Set();
|
|
90
89
|
const restoreCallbackSet = new Set();
|
|
91
90
|
|
|
92
91
|
const getFileStateWithinHook = (fileUrl) => {
|
|
@@ -207,18 +206,11 @@ export const spyFilesystemCalls = (
|
|
|
207
206
|
unlinkHook.remove();
|
|
208
207
|
});
|
|
209
208
|
return {
|
|
210
|
-
addBeforeUndoCallback: (callback) => {
|
|
211
|
-
beforeUndoCallbackSet.add(callback);
|
|
212
|
-
},
|
|
213
209
|
restore: () => {
|
|
214
210
|
for (const restoreCallback of restoreCallbackSet) {
|
|
215
211
|
restoreCallback();
|
|
216
212
|
}
|
|
217
213
|
restoreCallbackSet.clear();
|
|
218
|
-
for (const beforeUndoCallback of beforeUndoCallbackSet) {
|
|
219
|
-
beforeUndoCallback();
|
|
220
|
-
}
|
|
221
|
-
beforeUndoCallbackSet.clear();
|
|
222
214
|
for (const [, restore] of fileRestoreMap) {
|
|
223
215
|
restore();
|
|
224
216
|
}
|