@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.
- package/dist/setupFile.js +40 -20
- 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,
|
|
158
|
+
const { __chromatic_autoSnapshot: autoSnapshot, __chromatic_pendingTakeSnapshots: pendingTakeSnapshots, __chromatic_isRegistered: isRegistered } = task.meta;
|
|
137
159
|
if (!isRegistered) {
|
|
138
|
-
return
|
|
160
|
+
return;
|
|
139
161
|
}
|
|
140
162
|
if (pendingTakeSnapshots?.length) {
|
|
141
|
-
throw new
|
|
163
|
+
throw new PendingSnapshotsError(pendingTakeSnapshots);
|
|
142
164
|
}
|
|
143
|
-
if (!autoSnapshot
|
|
144
|
-
|
|
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
|
-
|
|
152
|
-
|
|
153
|
-
|
|
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
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
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
|
-
|
|
165
|
-
});
|
|
185
|
+
};
|