@vitest/snapshot 4.1.5 → 5.0.0-beta.2

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.
Files changed (2) hide show
  1. package/dist/index.js +5 -5
  2. package/package.json +7 -4
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: !!expectedSnapshot.data,
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,7 +1057,7 @@ class SnapshotClient {
1057
1057
  isInline,
1058
1058
  inlineSnapshot
1059
1059
  });
1060
- const reference = expectedSnapshot.data && snapshotState.snapshotUpdateState !== "all" ? adapter.parseExpected(expectedSnapshot.data) : undefined;
1060
+ const reference = expectedSnapshot.data !== undefined && snapshotState.snapshotUpdateState !== "all" ? adapter.parseExpected(expectedSnapshot.data) : undefined;
1061
1061
  const timedOut = timeout > 0 ? new Promise((r) => setTimeout(r, timeout)) : undefined;
1062
1062
  const stableResult = await getStableSnapshot({
1063
1063
  adapter,
@@ -1067,7 +1067,7 @@ class SnapshotClient {
1067
1067
  match: reference ? (captured) => adapter.match(captured, reference).pass : undefined
1068
1068
  });
1069
1069
  expectedSnapshot.markAsChecked();
1070
- if (!stableResult?.rendered) {
1070
+ if (stableResult?.rendered === undefined) {
1071
1071
  // the original caller `expect.poll` later manipulates error via `throwWithCause`,
1072
1072
  // so here we can directly throw `lastPollError` if exists.
1073
1073
  if (stableResult?.lastPollError) {
@@ -1081,7 +1081,7 @@ class SnapshotClient {
1081
1081
  // TODO: should `all` mode ignore parse error?
1082
1082
  // Sielently hiding the error and creating snaphsot full scratch isn't good either.
1083
1083
  // 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;
1084
+ const matchResult = expectedSnapshot.data !== undefined ? adapter.match(stableResult.captured, adapter.parseExpected(expectedSnapshot.data)) : undefined;
1085
1085
  const { actual, expected, key, pass } = snapshotState.processDomainSnapshot({
1086
1086
  testId,
1087
1087
  received: stableResult.rendered,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vitest/snapshot",
3
3
  "type": "module",
4
- "version": "4.1.5",
4
+ "version": "5.0.0-beta.2",
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": "4.1.5",
49
- "@vitest/utils": "4.1.5"
51
+ "@vitest/pretty-format": "5.0.0-beta.2",
52
+ "@vitest/utils": "5.0.0-beta.2"
50
53
  },
51
54
  "devDependencies": {
52
55
  "@types/natural-compare": "^1.4.3",