@jsenv/snapshot 2.13.9 → 2.14.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/snapshot",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.14.0",
|
|
4
4
|
"description": "Snapshot testing",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -31,14 +31,14 @@
|
|
|
31
31
|
],
|
|
32
32
|
"sideEffects": false,
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@jsenv/assert": "4.4.
|
|
35
|
-
"@jsenv/ast": "6.6.
|
|
34
|
+
"@jsenv/assert": "4.4.5",
|
|
35
|
+
"@jsenv/ast": "6.6.7",
|
|
36
36
|
"@jsenv/exception": "1.1.7",
|
|
37
|
-
"@jsenv/humanize": "1.
|
|
38
|
-
"@jsenv/filesystem": "4.14.
|
|
39
|
-
"@jsenv/terminal-recorder": "1.5.
|
|
40
|
-
"@jsenv/urls": "2.7.
|
|
41
|
-
"@jsenv/utils": "2.
|
|
37
|
+
"@jsenv/humanize": "1.4.0",
|
|
38
|
+
"@jsenv/filesystem": "4.14.6",
|
|
39
|
+
"@jsenv/terminal-recorder": "1.5.9",
|
|
40
|
+
"@jsenv/urls": "2.7.1",
|
|
41
|
+
"@jsenv/utils": "2.3.0",
|
|
42
42
|
"ansi-regex": "6.1.0",
|
|
43
43
|
"pixelmatch": "7.1.0",
|
|
44
44
|
"prettier": "3.5.3",
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// https://github.com/tschaub/mock-fs/issues/348
|
|
5
5
|
|
|
6
6
|
import {
|
|
7
|
-
|
|
7
|
+
compareFileUrls,
|
|
8
8
|
removeDirectorySync,
|
|
9
9
|
removeFileSync,
|
|
10
10
|
writeFileSync,
|
|
@@ -335,12 +335,7 @@ export const spyFilesystemCalls = (
|
|
|
335
335
|
}
|
|
336
336
|
fileRestoreMap.clear();
|
|
337
337
|
const dirUrls = Array.from(dirRestoreMap.keys());
|
|
338
|
-
dirUrls.sort(
|
|
339
|
-
return comparePathnames(
|
|
340
|
-
new URL(left).pathname,
|
|
341
|
-
new URL(right).pathname,
|
|
342
|
-
);
|
|
343
|
-
});
|
|
338
|
+
dirUrls.sort(compareFileUrls);
|
|
344
339
|
for (const dirUrl of dirUrls) {
|
|
345
340
|
const restore = dirRestoreMap.get(dirUrl);
|
|
346
341
|
restore();
|
|
@@ -31,10 +31,17 @@ import { renderSideEffects, renderSmallLink } from "./render_side_effects.js";
|
|
|
31
31
|
* Urls of filesystem side effects will be relative to this base directory
|
|
32
32
|
* Default to the directory containing @sourceFileUrl
|
|
33
33
|
*/
|
|
34
|
+
let preconfiguredOptions = null;
|
|
34
35
|
export const snapshotTests = async (
|
|
35
36
|
sourceFileUrl,
|
|
36
37
|
fnRegisteringTest,
|
|
37
|
-
{
|
|
38
|
+
options = {},
|
|
39
|
+
) => {
|
|
40
|
+
if (preconfiguredOptions) {
|
|
41
|
+
Object.assign(options, preconfiguredOptions);
|
|
42
|
+
preconfiguredOptions = null;
|
|
43
|
+
}
|
|
44
|
+
let {
|
|
38
45
|
outFilePattern = "./_[source_filename]/[filename]",
|
|
39
46
|
filesystemActions,
|
|
40
47
|
rootDirectoryUrl,
|
|
@@ -43,11 +50,10 @@ export const snapshotTests = async (
|
|
|
43
50
|
logEffects,
|
|
44
51
|
filesystemEffects,
|
|
45
52
|
throwWhenDiff = process.env.CI,
|
|
46
|
-
} =
|
|
47
|
-
) => {
|
|
53
|
+
} = options;
|
|
48
54
|
filesystemActions = {
|
|
49
55
|
"**": "compare",
|
|
50
|
-
...filesystemActions,
|
|
56
|
+
...options.filesystemActions,
|
|
51
57
|
"**/*.svg": "compare_presence_only",
|
|
52
58
|
};
|
|
53
59
|
|
|
@@ -222,6 +228,17 @@ export const snapshotTests = async (
|
|
|
222
228
|
|
|
223
229
|
return { dirUrlMap, sideEffectsMap };
|
|
224
230
|
};
|
|
231
|
+
// preConfigure is just so that when we update the snapshot test options
|
|
232
|
+
// it does not influence too much the formatting
|
|
233
|
+
// snapshotTests(import.meta.url, ({ test }) => { }, options)
|
|
234
|
+
// becomes
|
|
235
|
+
// snapshotTests.prefConfigure(options)
|
|
236
|
+
// snapshotTests(import.meta.url, ({ test }) => { })
|
|
237
|
+
// which are equivalent
|
|
238
|
+
|
|
239
|
+
snapshotTests.prefConfigure = (options) => {
|
|
240
|
+
preconfiguredOptions = options;
|
|
241
|
+
};
|
|
225
242
|
|
|
226
243
|
// see https://github.com/parshap/node-sanitize-filename/blob/master/index.js
|
|
227
244
|
const asValidFilename = (string) => {
|