@depup/vitest__snapshot 4.1.0-depup.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/LICENSE +21 -0
- package/README.md +25 -0
- package/changes.json +5 -0
- package/dist/environment.d-DOJxxZV9.d.ts +17 -0
- package/dist/environment.d.ts +17 -0
- package/dist/environment.js +40 -0
- package/dist/index.d.ts +131 -0
- package/dist/index.js +908 -0
- package/dist/manager.d.ts +19 -0
- package/dist/manager.js +73 -0
- package/dist/rawSnapshot.d-U2kJUxDr.d.ts +61 -0
- package/environment.d.ts +1 -0
- package/manager.d.ts +1 -0
- package/package.json +73 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021-Present VoidZero Inc. and Vitest contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# @depup/vitest__snapshot
|
|
2
|
+
|
|
3
|
+
> Dependency-bumped version of [@vitest/snapshot](https://www.npmjs.com/package/@vitest/snapshot)
|
|
4
|
+
|
|
5
|
+
Generated by [DepUp](https://github.com/depup/npm) -- all production
|
|
6
|
+
dependencies bumped to latest versions.
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install @depup/vitest__snapshot
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
| Field | Value |
|
|
15
|
+
|-------|-------|
|
|
16
|
+
| Original | [@vitest/snapshot](https://www.npmjs.com/package/@vitest/snapshot) @ 4.1.0 |
|
|
17
|
+
| Processed | 2026-03-17 |
|
|
18
|
+
| Smoke test | passed |
|
|
19
|
+
| Deps updated | 0 |
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
Source: https://github.com/depup/npm | Original: https://www.npmjs.com/package/@vitest/snapshot
|
|
24
|
+
|
|
25
|
+
License inherited from the original package.
|
package/changes.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ParsedStack } from '@vitest/utils';
|
|
2
|
+
|
|
3
|
+
interface SnapshotEnvironment {
|
|
4
|
+
getVersion: () => string;
|
|
5
|
+
getHeader: () => string;
|
|
6
|
+
resolvePath: (filepath: string) => Promise<string>;
|
|
7
|
+
resolveRawPath: (testPath: string, rawPath: string) => Promise<string>;
|
|
8
|
+
saveSnapshotFile: (filepath: string, snapshot: string) => Promise<void>;
|
|
9
|
+
readSnapshotFile: (filepath: string) => Promise<string | null>;
|
|
10
|
+
removeSnapshotFile: (filepath: string) => Promise<void>;
|
|
11
|
+
processStackTrace?: (stack: ParsedStack) => ParsedStack;
|
|
12
|
+
}
|
|
13
|
+
interface SnapshotEnvironmentOptions {
|
|
14
|
+
snapshotsDirName?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type { SnapshotEnvironment as S, SnapshotEnvironmentOptions as a };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { S as SnapshotEnvironment, a as SnapshotEnvironmentOptions } from './environment.d-DOJxxZV9.js';
|
|
2
|
+
import '@vitest/utils';
|
|
3
|
+
|
|
4
|
+
declare class NodeSnapshotEnvironment implements SnapshotEnvironment {
|
|
5
|
+
private options;
|
|
6
|
+
constructor(options?: SnapshotEnvironmentOptions);
|
|
7
|
+
getVersion(): string;
|
|
8
|
+
getHeader(): string;
|
|
9
|
+
resolveRawPath(testPath: string, rawPath: string): Promise<string>;
|
|
10
|
+
resolvePath(filepath: string): Promise<string>;
|
|
11
|
+
prepareDirectory(dirPath: string): Promise<void>;
|
|
12
|
+
saveSnapshotFile(filepath: string, snapshot: string): Promise<void>;
|
|
13
|
+
readSnapshotFile(filepath: string): Promise<string | null>;
|
|
14
|
+
removeSnapshotFile(filepath: string): Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { NodeSnapshotEnvironment, SnapshotEnvironment };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { promises, existsSync } from 'node:fs';
|
|
2
|
+
import { isAbsolute, resolve, dirname, join, basename } from 'pathe';
|
|
3
|
+
|
|
4
|
+
class NodeSnapshotEnvironment {
|
|
5
|
+
constructor(options = {}) {
|
|
6
|
+
this.options = options;
|
|
7
|
+
}
|
|
8
|
+
getVersion() {
|
|
9
|
+
return "1";
|
|
10
|
+
}
|
|
11
|
+
getHeader() {
|
|
12
|
+
return `// Snapshot v${this.getVersion()}`;
|
|
13
|
+
}
|
|
14
|
+
async resolveRawPath(testPath, rawPath) {
|
|
15
|
+
return isAbsolute(rawPath) ? rawPath : resolve(dirname(testPath), rawPath);
|
|
16
|
+
}
|
|
17
|
+
async resolvePath(filepath) {
|
|
18
|
+
return join(join(dirname(filepath), this.options.snapshotsDirName ?? "__snapshots__"), `${basename(filepath)}.snap`);
|
|
19
|
+
}
|
|
20
|
+
async prepareDirectory(dirPath) {
|
|
21
|
+
await promises.mkdir(dirPath, { recursive: true });
|
|
22
|
+
}
|
|
23
|
+
async saveSnapshotFile(filepath, snapshot) {
|
|
24
|
+
await promises.mkdir(dirname(filepath), { recursive: true });
|
|
25
|
+
await promises.writeFile(filepath, snapshot, "utf-8");
|
|
26
|
+
}
|
|
27
|
+
async readSnapshotFile(filepath) {
|
|
28
|
+
if (!existsSync(filepath)) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
return promises.readFile(filepath, "utf-8");
|
|
32
|
+
}
|
|
33
|
+
async removeSnapshotFile(filepath) {
|
|
34
|
+
if (existsSync(filepath)) {
|
|
35
|
+
await promises.unlink(filepath);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export { NodeSnapshotEnvironment };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { S as SnapshotStateOptions, a as SnapshotMatchOptions, b as SnapshotResult, R as RawSnapshotInfo } from './rawSnapshot.d-U2kJUxDr.js';
|
|
2
|
+
export { c as SnapshotData, d as SnapshotSerializer, e as SnapshotSummary, f as SnapshotUpdateState, U as UncheckedSnapshot } from './rawSnapshot.d-U2kJUxDr.js';
|
|
3
|
+
import { ParsedStack } from '@vitest/utils';
|
|
4
|
+
import { S as SnapshotEnvironment } from './environment.d-DOJxxZV9.js';
|
|
5
|
+
import { Plugin, Plugins } from '@vitest/pretty-format';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
|
9
|
+
*
|
|
10
|
+
* This source code is licensed under the MIT license found in the
|
|
11
|
+
* LICENSE file in the root directory of this source tree.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
declare class DefaultMap<
|
|
15
|
+
K,
|
|
16
|
+
V
|
|
17
|
+
> extends Map<K, V> {
|
|
18
|
+
private defaultFn;
|
|
19
|
+
constructor(defaultFn: (key: K) => V, entries?: Iterable<readonly [K, V]>);
|
|
20
|
+
get(key: K): V;
|
|
21
|
+
}
|
|
22
|
+
declare class CounterMap<K> extends DefaultMap<K, number> {
|
|
23
|
+
constructor();
|
|
24
|
+
_total: number | undefined;
|
|
25
|
+
valueOf(): number;
|
|
26
|
+
increment(key: K): void;
|
|
27
|
+
total(): number;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
interface SnapshotReturnOptions {
|
|
31
|
+
actual: string;
|
|
32
|
+
count: number;
|
|
33
|
+
expected?: string;
|
|
34
|
+
key: string;
|
|
35
|
+
pass: boolean;
|
|
36
|
+
}
|
|
37
|
+
interface SaveStatus {
|
|
38
|
+
deleted: boolean;
|
|
39
|
+
saved: boolean;
|
|
40
|
+
}
|
|
41
|
+
declare class SnapshotState {
|
|
42
|
+
testFilePath: string;
|
|
43
|
+
snapshotPath: string;
|
|
44
|
+
private _counters;
|
|
45
|
+
private _dirty;
|
|
46
|
+
private _updateSnapshot;
|
|
47
|
+
private _snapshotData;
|
|
48
|
+
private _initialData;
|
|
49
|
+
private _inlineSnapshots;
|
|
50
|
+
private _inlineSnapshotStacks;
|
|
51
|
+
private _testIdToKeys;
|
|
52
|
+
private _rawSnapshots;
|
|
53
|
+
private _uncheckedKeys;
|
|
54
|
+
private _snapshotFormat;
|
|
55
|
+
private _environment;
|
|
56
|
+
private _fileExists;
|
|
57
|
+
expand: boolean;
|
|
58
|
+
private _added;
|
|
59
|
+
private _matched;
|
|
60
|
+
private _unmatched;
|
|
61
|
+
private _updated;
|
|
62
|
+
get added(): CounterMap<string>;
|
|
63
|
+
set added(value: number);
|
|
64
|
+
get matched(): CounterMap<string>;
|
|
65
|
+
set matched(value: number);
|
|
66
|
+
get unmatched(): CounterMap<string>;
|
|
67
|
+
set unmatched(value: number);
|
|
68
|
+
get updated(): CounterMap<string>;
|
|
69
|
+
set updated(value: number);
|
|
70
|
+
private constructor();
|
|
71
|
+
static create(testFilePath: string, options: SnapshotStateOptions): Promise<SnapshotState>;
|
|
72
|
+
get environment(): SnapshotEnvironment;
|
|
73
|
+
markSnapshotsAsCheckedForTest(testName: string): void;
|
|
74
|
+
clearTest(testId: string): void;
|
|
75
|
+
protected _inferInlineSnapshotStack(stacks: ParsedStack[]): ParsedStack | null;
|
|
76
|
+
private _addSnapshot;
|
|
77
|
+
save(): Promise<SaveStatus>;
|
|
78
|
+
getUncheckedCount(): number;
|
|
79
|
+
getUncheckedKeys(): Array<string>;
|
|
80
|
+
removeUncheckedKeys(): void;
|
|
81
|
+
match({ testId, testName, received, key, inlineSnapshot, isInline, error, rawSnapshot }: SnapshotMatchOptions): SnapshotReturnOptions;
|
|
82
|
+
pack(): Promise<SnapshotResult>;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
interface AssertOptions {
|
|
86
|
+
received: unknown;
|
|
87
|
+
filepath: string;
|
|
88
|
+
name: string;
|
|
89
|
+
/**
|
|
90
|
+
* Not required but needed for `SnapshotClient.clearTest` to implement test-retry behavior.
|
|
91
|
+
* @default name
|
|
92
|
+
*/
|
|
93
|
+
testId?: string;
|
|
94
|
+
message?: string;
|
|
95
|
+
isInline?: boolean;
|
|
96
|
+
properties?: object;
|
|
97
|
+
inlineSnapshot?: string;
|
|
98
|
+
error?: Error;
|
|
99
|
+
errorMessage?: string;
|
|
100
|
+
rawSnapshot?: RawSnapshotInfo;
|
|
101
|
+
}
|
|
102
|
+
interface SnapshotClientOptions {
|
|
103
|
+
isEqual?: (received: unknown, expected: unknown) => boolean;
|
|
104
|
+
}
|
|
105
|
+
declare class SnapshotClient {
|
|
106
|
+
private options;
|
|
107
|
+
snapshotStateMap: Map<string, SnapshotState>;
|
|
108
|
+
constructor(options?: SnapshotClientOptions);
|
|
109
|
+
setup(filepath: string, options: SnapshotStateOptions): Promise<void>;
|
|
110
|
+
finish(filepath: string): Promise<SnapshotResult>;
|
|
111
|
+
skipTest(filepath: string, testName: string): void;
|
|
112
|
+
clearTest(filepath: string, testId: string): void;
|
|
113
|
+
getSnapshotState(filepath: string): SnapshotState;
|
|
114
|
+
assert(options: AssertOptions): void;
|
|
115
|
+
assertRaw(options: AssertOptions): Promise<void>;
|
|
116
|
+
clear(): void;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
declare function stripSnapshotIndentation(inlineSnapshot: string): string;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
|
123
|
+
*
|
|
124
|
+
* This source code is licensed under the MIT license found in the
|
|
125
|
+
* LICENSE file in the root directory of this source tree.
|
|
126
|
+
*/
|
|
127
|
+
|
|
128
|
+
declare function addSerializer(plugin: Plugin): void;
|
|
129
|
+
declare function getSerializers(): Plugins;
|
|
130
|
+
|
|
131
|
+
export { SnapshotClient, SnapshotEnvironment, SnapshotMatchOptions, SnapshotResult, SnapshotState, SnapshotStateOptions, addSerializer, getSerializers, stripSnapshotIndentation };
|