@chromatic-com/vitest 0.1.4 → 0.1.5

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
@@ -4087,6 +4087,7 @@ var DEFAULT_GLOBAL_RESOURCE_ARCHIVE_TIMEOUT_MS = 1e4;
4087
4087
  // src/node/commands.ts
4088
4088
  import assert from "node:assert";
4089
4089
  import { resolve as resolve2 } from "node:path";
4090
+ import { storyNameFromExport as storyNameFromExport2, toId as toId2 } from "storybook/internal/csf";
4090
4091
 
4091
4092
  // src/node/NetworkIdleTracker.ts
4092
4093
  var NetworkIdleTimeoutError = class NetworkIdleTimeoutError2 extends Error {
@@ -4295,6 +4296,7 @@ __name(pluralize, "pluralize");
4295
4296
  function createCommands(options) {
4296
4297
  const resourceArchivers = /* @__PURE__ */ new Map();
4297
4298
  const networkIdleTrackers = /* @__PURE__ */ new Map();
4299
+ const savedResults = /* @__PURE__ */ new Set();
4298
4300
  const snapshots = /* @__PURE__ */ new Map();
4299
4301
  return {
4300
4302
  /**
@@ -4371,8 +4373,14 @@ function createCommands(options) {
4371
4373
  const { archive, sessionSnapshots } = await onTestCleanup(context, id);
4372
4374
  assert(sessionSnapshots, `No snapshots found for test ${id}`);
4373
4375
  const snapshotBuffers = {};
4376
+ const titlePath = testOptions.title ? [
4377
+ testOptions.title
4378
+ ] : getTitle(entity);
4374
4379
  for (const [name, { snapshot, viewport, pseudoClassIds }] of sessionSnapshots) {
4375
- const names = getSnapshotPrefix(entity).concat(name).join(" / ");
4380
+ const names = generateUniqueSnapshotName({
4381
+ snapshotName: getSnapshotPrefix(entity).concat(name),
4382
+ titlePath
4383
+ });
4376
4384
  snapshotBuffers[names] = {
4377
4385
  snapshot: Buffer.from(JSON.stringify(snapshot)),
4378
4386
  viewport,
@@ -4391,9 +4399,7 @@ function createCommands(options) {
4391
4399
  await writeTestResult({
4392
4400
  outputDir: resolve2(context.project.vitest.config.root, options.outputDirectory),
4393
4401
  pageUrl: context.page.url(),
4394
- titlePath: testOptions.title ? [
4395
- testOptions.title
4396
- ] : getTitle(entity)
4402
+ titlePath
4397
4403
  }, snapshotBuffers, archive, {
4398
4404
  delay: testOptions.delay ?? options.delay,
4399
4405
  diffIncludeAntiAliasing: testOptions.diffIncludeAntiAliasing ?? options.diffIncludeAntiAliasing,
@@ -4421,6 +4427,7 @@ function createCommands(options) {
4421
4427
  resourceArchivers.clear();
4422
4428
  networkIdleTrackers.clear();
4423
4429
  snapshots.clear();
4430
+ savedResults.clear();
4424
4431
  },
4425
4432
  /**
4426
4433
  * Get currently save snapshots. Used only during testing.
@@ -4445,6 +4452,21 @@ function createCommands(options) {
4445
4452
  };
4446
4453
  }
4447
4454
  __name(onTestCleanup, "onTestCleanup");
4455
+ function generateUniqueSnapshotName(options2) {
4456
+ const names = options2.snapshotName.join(" / ");
4457
+ const base = toId2(options2.titlePath.join(" / "), storyNameFromExport2(names));
4458
+ let key = base;
4459
+ let count = 1;
4460
+ while (savedResults.has(key)) {
4461
+ key = `${base} (${count++})`;
4462
+ }
4463
+ savedResults.add(key);
4464
+ if (count > 1) {
4465
+ return `${names} (${count})`;
4466
+ }
4467
+ return names;
4468
+ }
4469
+ __name(generateUniqueSnapshotName, "generateUniqueSnapshotName");
4448
4470
  }
4449
4471
  __name(createCommands, "createCommands");
4450
4472
  function getTitle(test) {
@@ -1,20 +1,5 @@
1
- /** @type {import('@storybook/server-webpack5').StorybookConfig} */
2
- declare const _default: {
3
- stories: string[];
4
- managerEntries: string[];
5
- previewAnnotations: string[];
6
- framework: {
7
- name: string;
8
- options: {};
9
- };
10
- core: {
11
- builder: string;
12
- renderer: string;
13
- };
14
- staticDirs: string[];
15
- features: {
16
- sidebarOnboardingChecklist: boolean;
17
- };
18
- };
1
+ import { StorybookConfig } from '@storybook/server-webpack5';
2
+
3
+ declare const _default: StorybookConfig;
19
4
 
20
5
  export { _default as default };
@@ -54,6 +54,12 @@ var main_default = {
54
54
  ],
55
55
  features: {
56
56
  sidebarOnboardingChecklist: false
57
+ },
58
+ webpackFinal: async (config) => {
59
+ config.target = [
60
+ "web"
61
+ ];
62
+ return config;
57
63
  }
58
64
  };
59
65
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chromatic-com/vitest",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Chromatic Visual Regression Testing for Vitest",
5
5
  "repository": {
6
6
  "type": "git",