@vitest/snapshot 3.1.0-beta.1 → 3.1.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/dist/environment.js +33 -36
- package/dist/index.js +899 -998
- package/dist/manager.js +63 -66
- package/package.json +3 -3
package/dist/manager.js
CHANGED
@@ -1,76 +1,73 @@
|
|
1
1
|
import { join, dirname, basename, resolve, isAbsolute } from 'pathe';
|
2
2
|
|
3
3
|
class SnapshotManager {
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
resolveRawPath(testPath, rawPath) {
|
27
|
-
return isAbsolute(rawPath) ? rawPath : resolve(dirname(testPath), rawPath);
|
28
|
-
}
|
4
|
+
summary;
|
5
|
+
extension = ".snap";
|
6
|
+
constructor(options) {
|
7
|
+
this.options = options;
|
8
|
+
this.clear();
|
9
|
+
}
|
10
|
+
clear() {
|
11
|
+
this.summary = emptySummary(this.options);
|
12
|
+
}
|
13
|
+
add(result) {
|
14
|
+
addSnapshotResult(this.summary, result);
|
15
|
+
}
|
16
|
+
resolvePath(testPath, context) {
|
17
|
+
const resolver = this.options.resolveSnapshotPath || (() => {
|
18
|
+
return join(join(dirname(testPath), "__snapshots__"), `${basename(testPath)}${this.extension}`);
|
19
|
+
});
|
20
|
+
const path = resolver(testPath, this.extension, context);
|
21
|
+
return path;
|
22
|
+
}
|
23
|
+
resolveRawPath(testPath, rawPath) {
|
24
|
+
return isAbsolute(rawPath) ? rawPath : resolve(dirname(testPath), rawPath);
|
25
|
+
}
|
29
26
|
}
|
30
27
|
function emptySummary(options) {
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
28
|
+
const summary = {
|
29
|
+
added: 0,
|
30
|
+
failure: false,
|
31
|
+
filesAdded: 0,
|
32
|
+
filesRemoved: 0,
|
33
|
+
filesRemovedList: [],
|
34
|
+
filesUnmatched: 0,
|
35
|
+
filesUpdated: 0,
|
36
|
+
matched: 0,
|
37
|
+
total: 0,
|
38
|
+
unchecked: 0,
|
39
|
+
uncheckedKeysByFile: [],
|
40
|
+
unmatched: 0,
|
41
|
+
updated: 0,
|
42
|
+
didUpdate: options.updateSnapshot === "all"
|
43
|
+
};
|
44
|
+
return summary;
|
48
45
|
}
|
49
46
|
function addSnapshotResult(summary, result) {
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
47
|
+
if (result.added) {
|
48
|
+
summary.filesAdded++;
|
49
|
+
}
|
50
|
+
if (result.fileDeleted) {
|
51
|
+
summary.filesRemoved++;
|
52
|
+
}
|
53
|
+
if (result.unmatched) {
|
54
|
+
summary.filesUnmatched++;
|
55
|
+
}
|
56
|
+
if (result.updated) {
|
57
|
+
summary.filesUpdated++;
|
58
|
+
}
|
59
|
+
summary.added += result.added;
|
60
|
+
summary.matched += result.matched;
|
61
|
+
summary.unchecked += result.unchecked;
|
62
|
+
if (result.uncheckedKeys && result.uncheckedKeys.length > 0) {
|
63
|
+
summary.uncheckedKeysByFile.push({
|
64
|
+
filePath: result.filepath,
|
65
|
+
keys: result.uncheckedKeys
|
66
|
+
});
|
67
|
+
}
|
68
|
+
summary.unmatched += result.unmatched;
|
69
|
+
summary.updated += result.updated;
|
70
|
+
summary.total += result.added + result.matched + result.unmatched + result.updated;
|
74
71
|
}
|
75
72
|
|
76
73
|
export { SnapshotManager, addSnapshotResult, emptySummary };
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@vitest/snapshot",
|
3
3
|
"type": "module",
|
4
|
-
"version": "3.1.0
|
4
|
+
"version": "3.1.0",
|
5
5
|
"description": "Vitest snapshot manager",
|
6
6
|
"license": "MIT",
|
7
7
|
"funding": "https://opencollective.com/vitest",
|
@@ -40,12 +40,12 @@
|
|
40
40
|
"dependencies": {
|
41
41
|
"magic-string": "^0.30.17",
|
42
42
|
"pathe": "^2.0.3",
|
43
|
-
"@vitest/pretty-format": "3.1.0
|
43
|
+
"@vitest/pretty-format": "3.1.0"
|
44
44
|
},
|
45
45
|
"devDependencies": {
|
46
46
|
"@types/natural-compare": "^1.4.3",
|
47
47
|
"natural-compare": "^1.4.0",
|
48
|
-
"@vitest/utils": "3.1.0
|
48
|
+
"@vitest/utils": "3.1.0"
|
49
49
|
},
|
50
50
|
"scripts": {
|
51
51
|
"build": "rimraf dist && rollup -c",
|