@chromatic-com/vitest 0.0.2 → 0.0.3-1daee81-20260429112817

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/plugin.js CHANGED
@@ -4155,7 +4155,7 @@ function createCommands(options) {
4155
4155
  };
4156
4156
  }
4157
4157
  await writeTestResult({
4158
- outputDir: resolve(context.project.config.root, options.outputDirectory),
4158
+ outputDir: resolve(context.project.vitest.config.root, options.outputDirectory),
4159
4159
  pageUrl: context.page.url(),
4160
4160
  titlePath: getNames(entity)
4161
4161
  }, snapshotBuffers, archive, {
@@ -4223,6 +4223,10 @@ function getNames(test) {
4223
4223
  if (current.type === "module") {
4224
4224
  names.unshift(current.relativeModuleId);
4225
4225
  }
4226
+ const hasManyProjects = test.project.vitest.projects.length > 1;
4227
+ if (hasManyProjects && test.project.name) {
4228
+ names.unshift(test.project.name);
4229
+ }
4226
4230
  return names;
4227
4231
  }
4228
4232
  __name(getNames, "getNames");
@@ -4288,7 +4292,7 @@ function chromaticPlugin(userOptions = {}) {
4288
4292
  await project.browser?.triggerCommand("__chromatic_reset", {});
4289
4293
  });
4290
4294
  function clean() {
4291
- rmSync(resolve2(project.config.root, options.outputDirectory, "chromatic-archives"), {
4295
+ rmSync(resolve2(project.vitest.config.root, options.outputDirectory, "chromatic-archives"), {
4292
4296
  recursive: true,
4293
4297
  force: true
4294
4298
  });
package/dist/setupFile.js CHANGED
@@ -2,7 +2,7 @@ var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
3
 
4
4
  // src/browser/setupFile.ts
5
- import { beforeEach } from "vitest";
5
+ import { afterEach, beforeEach } from "vitest";
6
6
  import { commands as commands3 } from "vitest/browser";
7
7
 
8
8
  // src/browser/public/takeSnapshot.ts
@@ -111,33 +111,37 @@ beforeEach(async ({ task }) => {
111
111
  const hasMatchingTag = task.tags?.some((tag) => options.tags?.includes(tag));
112
112
  if (!hasMatchingTag) {
113
113
  task.meta.__chromatic_isRegistered = false;
114
- return cleanup;
114
+ return;
115
115
  }
116
116
  }
117
117
  task.meta.__chromatic_isRegistered = true;
118
118
  task.meta.__chromatic_isTakeSnapshotCalled = false;
119
119
  task.meta.__chromatic_autoSnapshot ??= !options.disableAutoSnapshot;
120
120
  await commands3.__chromatic_interceptFetch(task.id);
121
- return /* @__PURE__ */ __name(async function afterEach() {
122
- const { __chromatic_autoSnapshot: autoSnapshot, __chromatic_isTakeSnapshotCalled: isTakeSnapshotCalled, __chromatic_pendingTakeSnapshots: pendingTakeSnapshots } = task.meta;
123
- if (pendingTakeSnapshots?.length) {
124
- throw new AggregateError(pendingTakeSnapshots.map((call) => call.error), `${pendingTakeSnapshots.length} unawaited takeSnapshot() call(s)`);
125
- }
126
- if (!autoSnapshot && !isTakeSnapshotCalled) {
127
- await commands3.__chromatic_stopWithoutSnapshots(task.id);
128
- return cleanup();
129
- }
130
- if (options.resourceArchiveTimeout !== 0) {
131
- await waitForIdleNetwork(options.resourceArchiveTimeout);
132
- }
133
- if (autoSnapshot) {
134
- await takeSnapshot(void 0, {
135
- ignoreUnawaited: true
136
- });
137
- }
138
- await commands3.__chromatic_writeTestResult(task.id);
121
+ });
122
+ afterEach(async ({ task }) => {
123
+ const { __chromatic_autoSnapshot: autoSnapshot, __chromatic_isTakeSnapshotCalled: isTakeSnapshotCalled, __chromatic_pendingTakeSnapshots: pendingTakeSnapshots, __chromatic_isRegistered: isRegistered } = task.meta;
124
+ if (!isRegistered) {
125
+ return cleanup();
126
+ }
127
+ if (pendingTakeSnapshots?.length) {
128
+ throw new AggregateError(pendingTakeSnapshots.map((call) => call.error), `${pendingTakeSnapshots.length} unawaited takeSnapshot() call(s)`);
129
+ }
130
+ if (!autoSnapshot && !isTakeSnapshotCalled) {
131
+ await commands3.__chromatic_stopWithoutSnapshots(task.id);
139
132
  return cleanup();
140
- }, "afterEach");
133
+ }
134
+ const options = await commands3.__chromatic_getOptions();
135
+ if (options.resourceArchiveTimeout !== 0) {
136
+ await waitForIdleNetwork(options.resourceArchiveTimeout);
137
+ }
138
+ if (autoSnapshot) {
139
+ await takeSnapshot(void 0, {
140
+ ignoreUnawaited: true
141
+ });
142
+ }
143
+ await commands3.__chromatic_writeTestResult(task.id);
144
+ return cleanup();
141
145
  function cleanup() {
142
146
  task.meta.__chromatic_autoSnapshot = void 0;
143
147
  task.meta.__chromatic_isTakeSnapshotCalled = void 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chromatic-com/vitest",
3
- "version": "0.0.2",
3
+ "version": "0.0.3-1daee81-20260429112817",
4
4
  "description": "Chromatic Visual Regression Testing for Vitest",
5
5
  "repository": {
6
6
  "type": "git",