@vitest/snapshot 3.0.8 → 3.0.9
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.d-DHdQ1Csl.d.ts +22 -0
- package/dist/environment.d.ts +11 -11
- package/dist/index.d.ts +100 -111
- package/dist/manager.d.ts +11 -11
- package/dist/rawSnapshot.d-lFsMJFUd.d.ts +61 -0
- package/package.json +3 -3
- package/dist/environment-Ddx0EDtY.d.ts +0 -22
- package/dist/rawSnapshot-DOKg5unn.d.ts +0 -61
@@ -0,0 +1,22 @@
|
|
1
|
+
interface ParsedStack {
|
2
|
+
method: string;
|
3
|
+
file: string;
|
4
|
+
line: number;
|
5
|
+
column: number;
|
6
|
+
}
|
7
|
+
|
8
|
+
interface SnapshotEnvironment {
|
9
|
+
getVersion: () => string;
|
10
|
+
getHeader: () => string;
|
11
|
+
resolvePath: (filepath: string) => Promise<string>;
|
12
|
+
resolveRawPath: (testPath: string, rawPath: string) => Promise<string>;
|
13
|
+
saveSnapshotFile: (filepath: string, snapshot: string) => Promise<void>;
|
14
|
+
readSnapshotFile: (filepath: string) => Promise<string | null>;
|
15
|
+
removeSnapshotFile: (filepath: string) => Promise<void>;
|
16
|
+
processStackTrace?: (stack: ParsedStack) => ParsedStack;
|
17
|
+
}
|
18
|
+
interface SnapshotEnvironmentOptions {
|
19
|
+
snapshotsDirName?: string;
|
20
|
+
}
|
21
|
+
|
22
|
+
export type { ParsedStack as P, SnapshotEnvironment as S, SnapshotEnvironmentOptions as a };
|
package/dist/environment.d.ts
CHANGED
@@ -1,16 +1,16 @@
|
|
1
|
-
import { S as SnapshotEnvironment, a as SnapshotEnvironmentOptions } from './environment-
|
1
|
+
import { S as SnapshotEnvironment, a as SnapshotEnvironmentOptions } from './environment.d-DHdQ1Csl.js';
|
2
2
|
|
3
3
|
declare class NodeSnapshotEnvironment implements SnapshotEnvironment {
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
4
|
+
private options;
|
5
|
+
constructor(options?: SnapshotEnvironmentOptions);
|
6
|
+
getVersion(): string;
|
7
|
+
getHeader(): string;
|
8
|
+
resolveRawPath(testPath: string, rawPath: string): Promise<string>;
|
9
|
+
resolvePath(filepath: string): Promise<string>;
|
10
|
+
prepareDirectory(dirPath: string): Promise<void>;
|
11
|
+
saveSnapshotFile(filepath: string, snapshot: string): Promise<void>;
|
12
|
+
readSnapshotFile(filepath: string): Promise<string | null>;
|
13
|
+
removeSnapshotFile(filepath: string): Promise<void>;
|
14
14
|
}
|
15
15
|
|
16
16
|
export { NodeSnapshotEnvironment, SnapshotEnvironment };
|
package/dist/index.d.ts
CHANGED
@@ -1,139 +1,128 @@
|
|
1
|
-
import { S as SnapshotStateOptions, a as SnapshotMatchOptions, b as SnapshotResult, R as RawSnapshotInfo } from './rawSnapshot-
|
2
|
-
export { c as SnapshotData, d as SnapshotSerializer, e as SnapshotSummary, f as SnapshotUpdateState, U as UncheckedSnapshot } from './rawSnapshot-
|
3
|
-
import { S as SnapshotEnvironment } from './environment-
|
1
|
+
import { S as SnapshotStateOptions, a as SnapshotMatchOptions, b as SnapshotResult, R as RawSnapshotInfo } from './rawSnapshot.d-lFsMJFUd.js';
|
2
|
+
export { c as SnapshotData, d as SnapshotSerializer, e as SnapshotSummary, f as SnapshotUpdateState, U as UncheckedSnapshot } from './rawSnapshot.d-lFsMJFUd.js';
|
3
|
+
import { S as SnapshotEnvironment, P as ParsedStack } from './environment.d-DHdQ1Csl.js';
|
4
4
|
import { Plugin, Plugins } from '@vitest/pretty-format';
|
5
5
|
|
6
|
-
interface ParsedStack {
|
7
|
-
method: string;
|
8
|
-
file: string;
|
9
|
-
line: number;
|
10
|
-
column: number;
|
11
|
-
}
|
12
|
-
|
13
6
|
/**
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
7
|
+
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
8
|
+
*
|
9
|
+
* This source code is licensed under the MIT license found in the
|
10
|
+
* LICENSE file in the root directory of this source tree.
|
11
|
+
*/
|
19
12
|
|
20
|
-
declare class DefaultMap<
|
21
|
-
|
22
|
-
|
23
|
-
|
13
|
+
declare class DefaultMap<
|
14
|
+
K,
|
15
|
+
V
|
16
|
+
> extends Map<K, V> {
|
17
|
+
private defaultFn;
|
18
|
+
constructor(defaultFn: (key: K) => V, entries?: Iterable<readonly [K, V]>);
|
19
|
+
get(key: K): V;
|
24
20
|
}
|
25
21
|
declare class CounterMap<K> extends DefaultMap<K, number> {
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
22
|
+
constructor();
|
23
|
+
_total: number | undefined;
|
24
|
+
valueOf(): number;
|
25
|
+
increment(key: K): void;
|
26
|
+
total(): number;
|
31
27
|
}
|
32
28
|
|
33
|
-
/**
|
34
|
-
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
35
|
-
*
|
36
|
-
* This source code is licensed under the MIT license found in the
|
37
|
-
* LICENSE file in the root directory of this source tree.
|
38
|
-
*/
|
39
|
-
|
40
29
|
interface SnapshotReturnOptions {
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
30
|
+
actual: string;
|
31
|
+
count: number;
|
32
|
+
expected?: string;
|
33
|
+
key: string;
|
34
|
+
pass: boolean;
|
46
35
|
}
|
47
36
|
interface SaveStatus {
|
48
|
-
|
49
|
-
|
37
|
+
deleted: boolean;
|
38
|
+
saved: boolean;
|
50
39
|
}
|
51
40
|
declare class SnapshotState {
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
41
|
+
testFilePath: string;
|
42
|
+
snapshotPath: string;
|
43
|
+
private _counters;
|
44
|
+
private _dirty;
|
45
|
+
private _updateSnapshot;
|
46
|
+
private _snapshotData;
|
47
|
+
private _initialData;
|
48
|
+
private _inlineSnapshots;
|
49
|
+
private _inlineSnapshotStacks;
|
50
|
+
private _testIdToKeys;
|
51
|
+
private _rawSnapshots;
|
52
|
+
private _uncheckedKeys;
|
53
|
+
private _snapshotFormat;
|
54
|
+
private _environment;
|
55
|
+
private _fileExists;
|
56
|
+
expand: boolean;
|
57
|
+
private _added;
|
58
|
+
private _matched;
|
59
|
+
private _unmatched;
|
60
|
+
private _updated;
|
61
|
+
get added(): CounterMap<string>;
|
62
|
+
set added(value: number);
|
63
|
+
get matched(): CounterMap<string>;
|
64
|
+
set matched(value: number);
|
65
|
+
get unmatched(): CounterMap<string>;
|
66
|
+
set unmatched(value: number);
|
67
|
+
get updated(): CounterMap<string>;
|
68
|
+
set updated(value: number);
|
69
|
+
private constructor();
|
70
|
+
static create(testFilePath: string, options: SnapshotStateOptions): Promise<SnapshotState>;
|
71
|
+
get environment(): SnapshotEnvironment;
|
72
|
+
markSnapshotsAsCheckedForTest(testName: string): void;
|
73
|
+
clearTest(testId: string): void;
|
74
|
+
protected _inferInlineSnapshotStack(stacks: ParsedStack[]): ParsedStack | null;
|
75
|
+
private _addSnapshot;
|
76
|
+
save(): Promise<SaveStatus>;
|
77
|
+
getUncheckedCount(): number;
|
78
|
+
getUncheckedKeys(): Array<string>;
|
79
|
+
removeUncheckedKeys(): void;
|
80
|
+
match({ testId, testName, received, key, inlineSnapshot, isInline, error, rawSnapshot }: SnapshotMatchOptions): SnapshotReturnOptions;
|
81
|
+
pack(): Promise<SnapshotResult>;
|
93
82
|
}
|
94
83
|
|
95
84
|
interface AssertOptions {
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
85
|
+
received: unknown;
|
86
|
+
filepath: string;
|
87
|
+
name: string;
|
88
|
+
/**
|
89
|
+
* Not required but needed for `SnapshotClient.clearTest` to implement test-retry behavior.
|
90
|
+
* @default name
|
91
|
+
*/
|
92
|
+
testId?: string;
|
93
|
+
message?: string;
|
94
|
+
isInline?: boolean;
|
95
|
+
properties?: object;
|
96
|
+
inlineSnapshot?: string;
|
97
|
+
error?: Error;
|
98
|
+
errorMessage?: string;
|
99
|
+
rawSnapshot?: RawSnapshotInfo;
|
111
100
|
}
|
112
101
|
interface SnapshotClientOptions {
|
113
|
-
|
102
|
+
isEqual?: (received: unknown, expected: unknown) => boolean;
|
114
103
|
}
|
115
104
|
declare class SnapshotClient {
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
105
|
+
private options;
|
106
|
+
snapshotStateMap: Map<string, SnapshotState>;
|
107
|
+
constructor(options?: SnapshotClientOptions);
|
108
|
+
setup(filepath: string, options: SnapshotStateOptions): Promise<void>;
|
109
|
+
finish(filepath: string): Promise<SnapshotResult>;
|
110
|
+
skipTest(filepath: string, testName: string): void;
|
111
|
+
clearTest(filepath: string, testId: string): void;
|
112
|
+
getSnapshotState(filepath: string): SnapshotState;
|
113
|
+
assert(options: AssertOptions): void;
|
114
|
+
assertRaw(options: AssertOptions): Promise<void>;
|
115
|
+
clear(): void;
|
127
116
|
}
|
128
117
|
|
129
118
|
declare function stripSnapshotIndentation(inlineSnapshot: string): string;
|
130
119
|
|
131
120
|
/**
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
121
|
+
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
122
|
+
*
|
123
|
+
* This source code is licensed under the MIT license found in the
|
124
|
+
* LICENSE file in the root directory of this source tree.
|
125
|
+
*/
|
137
126
|
|
138
127
|
declare function addSerializer(plugin: Plugin): void;
|
139
128
|
declare function getSerializers(): Plugins;
|
package/dist/manager.d.ts
CHANGED
@@ -1,18 +1,18 @@
|
|
1
|
-
import { S as SnapshotStateOptions, e as SnapshotSummary, b as SnapshotResult } from './rawSnapshot-
|
1
|
+
import { S as SnapshotStateOptions, e as SnapshotSummary, b as SnapshotResult } from './rawSnapshot.d-lFsMJFUd.js';
|
2
2
|
import '@vitest/pretty-format';
|
3
|
-
import './environment-
|
3
|
+
import './environment.d-DHdQ1Csl.js';
|
4
4
|
|
5
5
|
declare class SnapshotManager {
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
6
|
+
options: Omit<SnapshotStateOptions, "snapshotEnvironment">;
|
7
|
+
summary: SnapshotSummary;
|
8
|
+
extension: string;
|
9
|
+
constructor(options: Omit<SnapshotStateOptions, "snapshotEnvironment">);
|
10
|
+
clear(): void;
|
11
|
+
add(result: SnapshotResult): void;
|
12
|
+
resolvePath<T = any>(testPath: string, context?: T): string;
|
13
|
+
resolveRawPath(testPath: string, rawPath: string): string;
|
14
14
|
}
|
15
|
-
declare function emptySummary(options: Omit<SnapshotStateOptions,
|
15
|
+
declare function emptySummary(options: Omit<SnapshotStateOptions, "snapshotEnvironment">): SnapshotSummary;
|
16
16
|
declare function addSnapshotResult(summary: SnapshotSummary, result: SnapshotResult): void;
|
17
17
|
|
18
18
|
export { SnapshotManager, addSnapshotResult, emptySummary };
|
@@ -0,0 +1,61 @@
|
|
1
|
+
import { OptionsReceived, Plugin } from '@vitest/pretty-format';
|
2
|
+
import { S as SnapshotEnvironment } from './environment.d-DHdQ1Csl.js';
|
3
|
+
|
4
|
+
type SnapshotData = Record<string, string>;
|
5
|
+
type SnapshotUpdateState = "all" | "new" | "none";
|
6
|
+
type SnapshotSerializer = Plugin;
|
7
|
+
interface SnapshotStateOptions {
|
8
|
+
updateSnapshot: SnapshotUpdateState;
|
9
|
+
snapshotEnvironment: SnapshotEnvironment;
|
10
|
+
expand?: boolean;
|
11
|
+
snapshotFormat?: OptionsReceived;
|
12
|
+
resolveSnapshotPath?: (path: string, extension: string, context?: any) => string;
|
13
|
+
}
|
14
|
+
interface SnapshotMatchOptions {
|
15
|
+
testId: string;
|
16
|
+
testName: string;
|
17
|
+
received: unknown;
|
18
|
+
key?: string;
|
19
|
+
inlineSnapshot?: string;
|
20
|
+
isInline: boolean;
|
21
|
+
error?: Error;
|
22
|
+
rawSnapshot?: RawSnapshotInfo;
|
23
|
+
}
|
24
|
+
interface SnapshotResult {
|
25
|
+
filepath: string;
|
26
|
+
added: number;
|
27
|
+
fileDeleted: boolean;
|
28
|
+
matched: number;
|
29
|
+
unchecked: number;
|
30
|
+
uncheckedKeys: Array<string>;
|
31
|
+
unmatched: number;
|
32
|
+
updated: number;
|
33
|
+
}
|
34
|
+
interface UncheckedSnapshot {
|
35
|
+
filePath: string;
|
36
|
+
keys: Array<string>;
|
37
|
+
}
|
38
|
+
interface SnapshotSummary {
|
39
|
+
added: number;
|
40
|
+
didUpdate: boolean;
|
41
|
+
failure: boolean;
|
42
|
+
filesAdded: number;
|
43
|
+
filesRemoved: number;
|
44
|
+
filesRemovedList: Array<string>;
|
45
|
+
filesUnmatched: number;
|
46
|
+
filesUpdated: number;
|
47
|
+
matched: number;
|
48
|
+
total: number;
|
49
|
+
unchecked: number;
|
50
|
+
uncheckedKeysByFile: Array<UncheckedSnapshot>;
|
51
|
+
unmatched: number;
|
52
|
+
updated: number;
|
53
|
+
}
|
54
|
+
|
55
|
+
interface RawSnapshotInfo {
|
56
|
+
file: string;
|
57
|
+
readonly?: boolean;
|
58
|
+
content?: string;
|
59
|
+
}
|
60
|
+
|
61
|
+
export type { RawSnapshotInfo as R, SnapshotStateOptions as S, UncheckedSnapshot as U, SnapshotMatchOptions as a, SnapshotResult as b, SnapshotData as c, SnapshotSerializer as d, SnapshotSummary as e, SnapshotUpdateState as f };
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@vitest/snapshot",
|
3
3
|
"type": "module",
|
4
|
-
"version": "3.0.
|
4
|
+
"version": "3.0.9",
|
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.0.
|
43
|
+
"@vitest/pretty-format": "3.0.9"
|
44
44
|
},
|
45
45
|
"devDependencies": {
|
46
46
|
"@types/natural-compare": "^1.4.3",
|
47
47
|
"natural-compare": "^1.4.0",
|
48
|
-
"@vitest/utils": "3.0.
|
48
|
+
"@vitest/utils": "3.0.9"
|
49
49
|
},
|
50
50
|
"scripts": {
|
51
51
|
"build": "rimraf dist && rollup -c",
|
@@ -1,22 +0,0 @@
|
|
1
|
-
interface ParsedStack {
|
2
|
-
method: string;
|
3
|
-
file: string;
|
4
|
-
line: number;
|
5
|
-
column: number;
|
6
|
-
}
|
7
|
-
|
8
|
-
interface SnapshotEnvironment {
|
9
|
-
getVersion: () => string;
|
10
|
-
getHeader: () => string;
|
11
|
-
resolvePath: (filepath: string) => Promise<string>;
|
12
|
-
resolveRawPath: (testPath: string, rawPath: string) => Promise<string>;
|
13
|
-
saveSnapshotFile: (filepath: string, snapshot: string) => Promise<void>;
|
14
|
-
readSnapshotFile: (filepath: string) => Promise<string | null>;
|
15
|
-
removeSnapshotFile: (filepath: string) => Promise<void>;
|
16
|
-
processStackTrace?: (stack: ParsedStack) => ParsedStack;
|
17
|
-
}
|
18
|
-
interface SnapshotEnvironmentOptions {
|
19
|
-
snapshotsDirName?: string;
|
20
|
-
}
|
21
|
-
|
22
|
-
export type { SnapshotEnvironment as S, SnapshotEnvironmentOptions as a };
|
@@ -1,61 +0,0 @@
|
|
1
|
-
import { OptionsReceived, Plugin } from '@vitest/pretty-format';
|
2
|
-
import { S as SnapshotEnvironment } from './environment-Ddx0EDtY.js';
|
3
|
-
|
4
|
-
type SnapshotData = Record<string, string>;
|
5
|
-
type SnapshotUpdateState = 'all' | 'new' | 'none';
|
6
|
-
type SnapshotSerializer = Plugin;
|
7
|
-
interface SnapshotStateOptions {
|
8
|
-
updateSnapshot: SnapshotUpdateState;
|
9
|
-
snapshotEnvironment: SnapshotEnvironment;
|
10
|
-
expand?: boolean;
|
11
|
-
snapshotFormat?: OptionsReceived;
|
12
|
-
resolveSnapshotPath?: (path: string, extension: string, context?: any) => string;
|
13
|
-
}
|
14
|
-
interface SnapshotMatchOptions {
|
15
|
-
testId: string;
|
16
|
-
testName: string;
|
17
|
-
received: unknown;
|
18
|
-
key?: string;
|
19
|
-
inlineSnapshot?: string;
|
20
|
-
isInline: boolean;
|
21
|
-
error?: Error;
|
22
|
-
rawSnapshot?: RawSnapshotInfo;
|
23
|
-
}
|
24
|
-
interface SnapshotResult {
|
25
|
-
filepath: string;
|
26
|
-
added: number;
|
27
|
-
fileDeleted: boolean;
|
28
|
-
matched: number;
|
29
|
-
unchecked: number;
|
30
|
-
uncheckedKeys: Array<string>;
|
31
|
-
unmatched: number;
|
32
|
-
updated: number;
|
33
|
-
}
|
34
|
-
interface UncheckedSnapshot {
|
35
|
-
filePath: string;
|
36
|
-
keys: Array<string>;
|
37
|
-
}
|
38
|
-
interface SnapshotSummary {
|
39
|
-
added: number;
|
40
|
-
didUpdate: boolean;
|
41
|
-
failure: boolean;
|
42
|
-
filesAdded: number;
|
43
|
-
filesRemoved: number;
|
44
|
-
filesRemovedList: Array<string>;
|
45
|
-
filesUnmatched: number;
|
46
|
-
filesUpdated: number;
|
47
|
-
matched: number;
|
48
|
-
total: number;
|
49
|
-
unchecked: number;
|
50
|
-
uncheckedKeysByFile: Array<UncheckedSnapshot>;
|
51
|
-
unmatched: number;
|
52
|
-
updated: number;
|
53
|
-
}
|
54
|
-
|
55
|
-
interface RawSnapshotInfo {
|
56
|
-
file: string;
|
57
|
-
readonly?: boolean;
|
58
|
-
content?: string;
|
59
|
-
}
|
60
|
-
|
61
|
-
export type { RawSnapshotInfo as R, SnapshotStateOptions as S, UncheckedSnapshot as U, SnapshotMatchOptions as a, SnapshotResult as b, SnapshotData as c, SnapshotSerializer as d, SnapshotSummary as e, SnapshotUpdateState as f };
|