@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/manager.js CHANGED
@@ -1,76 +1,73 @@
1
1
  import { join, dirname, basename, resolve, isAbsolute } from 'pathe';
2
2
 
3
3
  class SnapshotManager {
4
- constructor(options) {
5
- this.options = options;
6
- this.clear();
7
- }
8
- summary;
9
- extension = ".snap";
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(
19
- join(dirname(testPath), "__snapshots__"),
20
- `${basename(testPath)}${this.extension}`
21
- );
22
- });
23
- const path = resolver(testPath, this.extension, context);
24
- return path;
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
- const summary = {
32
- added: 0,
33
- failure: false,
34
- filesAdded: 0,
35
- filesRemoved: 0,
36
- filesRemovedList: [],
37
- filesUnmatched: 0,
38
- filesUpdated: 0,
39
- matched: 0,
40
- total: 0,
41
- unchecked: 0,
42
- uncheckedKeysByFile: [],
43
- unmatched: 0,
44
- updated: 0,
45
- didUpdate: options.updateSnapshot === "all"
46
- };
47
- return summary;
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
- if (result.added) {
51
- summary.filesAdded++;
52
- }
53
- if (result.fileDeleted) {
54
- summary.filesRemoved++;
55
- }
56
- if (result.unmatched) {
57
- summary.filesUnmatched++;
58
- }
59
- if (result.updated) {
60
- summary.filesUpdated++;
61
- }
62
- summary.added += result.added;
63
- summary.matched += result.matched;
64
- summary.unchecked += result.unchecked;
65
- if (result.uncheckedKeys && result.uncheckedKeys.length > 0) {
66
- summary.uncheckedKeysByFile.push({
67
- filePath: result.filepath,
68
- keys: result.uncheckedKeys
69
- });
70
- }
71
- summary.unmatched += result.unmatched;
72
- summary.updated += result.updated;
73
- summary.total += result.added + result.matched + result.unmatched + result.updated;
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-beta.1",
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-beta.1"
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-beta.1"
48
+ "@vitest/utils": "3.1.0"
49
49
  },
50
50
  "scripts": {
51
51
  "build": "rimraf dist && rollup -c",