@vitest/snapshot 5.0.0-beta.1 → 5.0.0-beta.3
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/index.d.ts +3 -1
- package/dist/index.js +11 -7
- package/package.json +7 -4
package/dist/index.d.ts
CHANGED
|
@@ -27,7 +27,9 @@ interface AssertDomainOptions extends Omit<AssertOptions, "received"> {
|
|
|
27
27
|
adapter: DomainSnapshotAdapter<any, any>;
|
|
28
28
|
}
|
|
29
29
|
interface AssertDomainPollOptions extends Omit<AssertDomainOptions, "received"> {
|
|
30
|
-
poll: (
|
|
30
|
+
poll: (options: {
|
|
31
|
+
signal: AbortSignal;
|
|
32
|
+
}) => Promise<unknown> | unknown;
|
|
31
33
|
timeout?: number;
|
|
32
34
|
interval?: number;
|
|
33
35
|
}
|
package/dist/index.js
CHANGED
|
@@ -863,7 +863,7 @@ class SnapshotState {
|
|
|
863
863
|
key: expectedSnapshot.key,
|
|
864
864
|
count: expectedSnapshot.count,
|
|
865
865
|
pass: matchResult?.pass ?? false,
|
|
866
|
-
hasSnapshot:
|
|
866
|
+
hasSnapshot: expectedSnapshot.data !== undefined,
|
|
867
867
|
snapshotIsPersisted: isInline ? true : this._fileExists,
|
|
868
868
|
addValue: actualResolved,
|
|
869
869
|
actualDisplay: removeExtraLineBreaks(actualResolved),
|
|
@@ -1027,7 +1027,7 @@ class SnapshotClient {
|
|
|
1027
1027
|
inlineSnapshot
|
|
1028
1028
|
});
|
|
1029
1029
|
expectedSnapshot.markAsChecked();
|
|
1030
|
-
const matchResult = expectedSnapshot.data ? adapter.match(captured, adapter.parseExpected(expectedSnapshot.data)) : undefined;
|
|
1030
|
+
const matchResult = expectedSnapshot.data !== undefined ? adapter.match(captured, adapter.parseExpected(expectedSnapshot.data)) : undefined;
|
|
1031
1031
|
const { actual, expected, key, pass } = snapshotState.processDomainSnapshot({
|
|
1032
1032
|
testId,
|
|
1033
1033
|
received: rendered,
|
|
@@ -1057,17 +1057,21 @@ class SnapshotClient {
|
|
|
1057
1057
|
isInline,
|
|
1058
1058
|
inlineSnapshot
|
|
1059
1059
|
});
|
|
1060
|
-
const reference = expectedSnapshot.data && snapshotState.snapshotUpdateState !== "all" ? adapter.parseExpected(expectedSnapshot.data) : undefined;
|
|
1061
|
-
const
|
|
1060
|
+
const reference = expectedSnapshot.data !== undefined && snapshotState.snapshotUpdateState !== "all" ? adapter.parseExpected(expectedSnapshot.data) : undefined;
|
|
1061
|
+
const timeoutController = new AbortController();
|
|
1062
|
+
const timedOut = timeout > 0 ? new Promise((r) => setTimeout(() => {
|
|
1063
|
+
timeoutController.abort();
|
|
1064
|
+
r();
|
|
1065
|
+
}, timeout)) : undefined;
|
|
1062
1066
|
const stableResult = await getStableSnapshot({
|
|
1063
1067
|
adapter,
|
|
1064
|
-
poll,
|
|
1068
|
+
poll: () => poll({ signal: timeoutController.signal }),
|
|
1065
1069
|
interval,
|
|
1066
1070
|
timedOut,
|
|
1067
1071
|
match: reference ? (captured) => adapter.match(captured, reference).pass : undefined
|
|
1068
1072
|
});
|
|
1069
1073
|
expectedSnapshot.markAsChecked();
|
|
1070
|
-
if (
|
|
1074
|
+
if (stableResult?.rendered === undefined) {
|
|
1071
1075
|
// the original caller `expect.poll` later manipulates error via `throwWithCause`,
|
|
1072
1076
|
// so here we can directly throw `lastPollError` if exists.
|
|
1073
1077
|
if (stableResult?.lastPollError) {
|
|
@@ -1081,7 +1085,7 @@ class SnapshotClient {
|
|
|
1081
1085
|
// TODO: should `all` mode ignore parse error?
|
|
1082
1086
|
// Sielently hiding the error and creating snaphsot full scratch isn't good either.
|
|
1083
1087
|
// Users can fix or purge the broken snapshot manually and that decision affects how domain snapshot gets updated.
|
|
1084
|
-
const matchResult = expectedSnapshot.data ? adapter.match(stableResult.captured, adapter.parseExpected(expectedSnapshot.data)) : undefined;
|
|
1088
|
+
const matchResult = expectedSnapshot.data !== undefined ? adapter.match(stableResult.captured, adapter.parseExpected(expectedSnapshot.data)) : undefined;
|
|
1085
1089
|
const { actual, expected, key, pass } = snapshotState.processDomainSnapshot({
|
|
1086
1090
|
testId,
|
|
1087
1091
|
received: stableResult.rendered,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitest/snapshot",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "5.0.0-beta.
|
|
4
|
+
"version": "5.0.0-beta.3",
|
|
5
5
|
"description": "Vitest snapshot manager",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"funding": "https://opencollective.com/vitest",
|
|
@@ -22,18 +22,21 @@
|
|
|
22
22
|
"sideEffects": false,
|
|
23
23
|
"exports": {
|
|
24
24
|
".": {
|
|
25
|
+
"__vitest_source__": "./src/index.ts",
|
|
25
26
|
"types": "./dist/index.d.ts",
|
|
26
27
|
"default": "./dist/index.js"
|
|
27
28
|
},
|
|
28
29
|
"./environment": {
|
|
30
|
+
"__vitest_source__": "./src/environment.ts",
|
|
29
31
|
"types": "./dist/environment.d.ts",
|
|
30
32
|
"default": "./dist/environment.js"
|
|
31
33
|
},
|
|
32
34
|
"./manager": {
|
|
35
|
+
"__vitest_source__": "./src/manager.ts",
|
|
33
36
|
"types": "./dist/manager.d.ts",
|
|
34
37
|
"default": "./dist/manager.js"
|
|
35
38
|
},
|
|
36
|
-
"
|
|
39
|
+
"./package.json": "./package.json"
|
|
37
40
|
},
|
|
38
41
|
"main": "./dist/index.js",
|
|
39
42
|
"module": "./dist/index.js",
|
|
@@ -45,8 +48,8 @@
|
|
|
45
48
|
"dependencies": {
|
|
46
49
|
"magic-string": "^0.30.21",
|
|
47
50
|
"pathe": "^2.0.3",
|
|
48
|
-
"@vitest/pretty-format": "5.0.0-beta.
|
|
49
|
-
"@vitest/utils": "5.0.0-beta.
|
|
51
|
+
"@vitest/pretty-format": "5.0.0-beta.3",
|
|
52
|
+
"@vitest/utils": "5.0.0-beta.3"
|
|
50
53
|
},
|
|
51
54
|
"devDependencies": {
|
|
52
55
|
"@types/natural-compare": "^1.4.3",
|