@chromatic-com/vitest 0.0.3 → 0.0.4-6948707-20260504115221

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/setupFile.js +40 -20
  2. package/package.json +1 -1
package/dist/setupFile.js CHANGED
@@ -124,42 +124,62 @@ beforeEach(async ({ task }) => {
124
124
  const hasMatchingTag = task.tags?.some((tag) => options.tags?.includes(tag));
125
125
  if (!hasMatchingTag) {
126
126
  task.meta.__chromatic_isRegistered = false;
127
- return;
127
+ return cleanup;
128
128
  }
129
129
  }
130
130
  task.meta.__chromatic_isRegistered = true;
131
131
  task.meta.__chromatic_isTakeSnapshotCalled = false;
132
132
  task.meta.__chromatic_autoSnapshot ??= !options.disableAutoSnapshot;
133
133
  await commands3.__chromatic_interceptFetch(task.id);
134
+ return /* @__PURE__ */ __name(async function beforeEachCleanup() {
135
+ const { __chromatic_isTakeSnapshotCalled: isTakeSnapshotCalled, __chromatic_pendingTakeSnapshots: pendingTakeSnapshots, __chromatic_isRegistered: isRegistered } = task.meta;
136
+ if (!isRegistered) {
137
+ return cleanup();
138
+ }
139
+ if (pendingTakeSnapshots?.length) {
140
+ throw new PendingSnapshotsError(pendingTakeSnapshots);
141
+ }
142
+ if (!isTakeSnapshotCalled) {
143
+ await commands3.__chromatic_stopWithoutSnapshots(task.id);
144
+ return cleanup();
145
+ }
146
+ await commands3.__chromatic_writeTestResult(task.id);
147
+ return cleanup();
148
+ }, "beforeEachCleanup");
149
+ function cleanup() {
150
+ task.meta.__chromatic_autoSnapshot = void 0;
151
+ task.meta.__chromatic_isTakeSnapshotCalled = void 0;
152
+ task.meta.__chromatic_isRegistered = void 0;
153
+ task.meta.__chromatic_pendingTakeSnapshots = void 0;
154
+ }
155
+ __name(cleanup, "cleanup");
134
156
  });
135
157
  afterEach(async ({ task }) => {
136
- const { __chromatic_autoSnapshot: autoSnapshot, __chromatic_isTakeSnapshotCalled: isTakeSnapshotCalled, __chromatic_pendingTakeSnapshots: pendingTakeSnapshots, __chromatic_isRegistered: isRegistered } = task.meta;
158
+ const { __chromatic_autoSnapshot: autoSnapshot, __chromatic_pendingTakeSnapshots: pendingTakeSnapshots, __chromatic_isRegistered: isRegistered } = task.meta;
137
159
  if (!isRegistered) {
138
- return cleanup();
160
+ return;
139
161
  }
140
162
  if (pendingTakeSnapshots?.length) {
141
- throw new AggregateError(pendingTakeSnapshots.map((call) => call.error), `${pendingTakeSnapshots.length} unawaited takeSnapshot() call(s)`);
163
+ throw new PendingSnapshotsError(pendingTakeSnapshots);
142
164
  }
143
- if (!autoSnapshot && !isTakeSnapshotCalled) {
144
- await commands3.__chromatic_stopWithoutSnapshots(task.id);
145
- return cleanup();
165
+ if (!autoSnapshot) {
166
+ return;
146
167
  }
147
168
  const options = await commands3.__chromatic_getOptions();
148
169
  if (options.resourceArchiveTimeout !== 0) {
149
170
  await waitForIdleNetwork(options.resourceArchiveTimeout);
150
171
  }
151
- if (autoSnapshot) {
152
- await takeSnapshot(void 0, {
153
- ignoreUnawaited: true
154
- });
172
+ await takeSnapshot(void 0, {
173
+ ignoreUnawaited: true
174
+ });
175
+ });
176
+ var PendingSnapshotsError = class PendingSnapshotsError2 extends AggregateError {
177
+ static {
178
+ __name(this, "PendingSnapshotsError");
155
179
  }
156
- await commands3.__chromatic_writeTestResult(task.id);
157
- return cleanup();
158
- function cleanup() {
159
- task.meta.__chromatic_autoSnapshot = void 0;
160
- task.meta.__chromatic_isTakeSnapshotCalled = void 0;
161
- task.meta.__chromatic_isRegistered = void 0;
162
- task.meta.__chromatic_pendingTakeSnapshots = void 0;
180
+ pendingCalls;
181
+ constructor(pendingCalls) {
182
+ super(pendingCalls.map((call) => call.error), `${pendingCalls.length} unawaited takeSnapshot() call(s)`), this.pendingCalls = pendingCalls;
183
+ this.name = "PendingSnapshotsError";
163
184
  }
164
- __name(cleanup, "cleanup");
165
- });
185
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chromatic-com/vitest",
3
- "version": "0.0.3",
3
+ "version": "0.0.4-6948707-20260504115221",
4
4
  "description": "Chromatic Visual Regression Testing for Vitest",
5
5
  "repository": {
6
6
  "type": "git",