@chromatic-com/vitest 0.1.3 → 0.1.4

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/plugin.js +13 -5
  2. package/package.json +1 -1
package/dist/plugin.js CHANGED
@@ -3674,6 +3674,10 @@ var ArchiveFile = class {
3674
3674
  if (!queryString)
3675
3675
  return pathname;
3676
3676
  const safeQueryString = this.hash(queryString);
3677
+ const extension = path2.extname(pathname);
3678
+ if (extension) {
3679
+ return `${pathname.substring(0, pathname.length - extension.length)}-${safeQueryString}${extension}`;
3680
+ }
3677
3681
  return `${pathname}-${safeQueryString}`;
3678
3682
  }
3679
3683
  truncateFileName(pathname) {
@@ -3916,9 +3920,13 @@ var STORIES_FILE_EXT = "stories.json";
3916
3920
  var uniqueId = {
3917
3921
  value: 1
3918
3922
  };
3919
- function storiesFileName(testTitle) {
3923
+ function storiesFileName(testTitle, overwriteDuplicateNames = true) {
3924
+ let title = sanitize(testTitle);
3925
+ if (!overwriteDuplicateNames) {
3926
+ title += "-" + uniqueId.value++;
3927
+ }
3920
3928
  const fileName = [
3921
- sanitize(testTitle) + "-" + uniqueId.value++,
3929
+ title,
3922
3930
  STORIES_FILE_EXT
3923
3931
  ].join(".");
3924
3932
  const maxByteLength = MAX_FILE_NAME_BYTE_LENGTH - 25;
@@ -4019,7 +4027,7 @@ function findDefaultViewport(viewports) {
4019
4027
  __name(findDefaultViewport, "findDefaultViewport");
4020
4028
 
4021
4029
  // ../shared/src/write-archive/index.ts
4022
- async function writeTestResult(e2eTestInfo, domSnapshots, archive, chromaticStorybookParams) {
4030
+ async function writeTestResult(e2eTestInfo, domSnapshots, archive, chromaticStorybookParams, testRunner) {
4023
4031
  const { titlePath, outputDir, pageUrl } = e2eTestInfo;
4024
4032
  const titlePathWithoutFileExtensions = titlePath.map((pathPart) => (
4025
4033
  // make sure we remove file extensions, even if the file name doesn't have .spec or .test or.cy
@@ -4054,7 +4062,7 @@ async function writeTestResult(e2eTestInfo, domSnapshots, archive, chromaticStor
4054
4062
  const snapshotFile = snapshotFileName(snapshotId(title, name), domSnapshot.viewport);
4055
4063
  await outputFile(join(archiveDir, snapshotFile), mappedSnapshot);
4056
4064
  }));
4057
- const storiesFile = storiesFileName(title);
4065
+ const storiesFile = storiesFileName(title, testRunner !== "vitest");
4058
4066
  const storiesJson = createStories(title, domSnapshots, chromaticStorybookParams);
4059
4067
  await outputJSONFile(join(finalOutputDir, storiesFile), storiesJson);
4060
4068
  const errors = Object.entries(archive).filter(([, r]) => "error" in r);
@@ -4395,7 +4403,7 @@ function createCommands(options) {
4395
4403
  prefersReducedMotion: testOptions.prefersReducedMotion ?? options.prefersReducedMotion,
4396
4404
  cropToViewport: testOptions.cropToViewport ?? options.cropToViewport,
4397
4405
  ignoreSelectors: testOptions.ignoreSelectors ?? options.ignoreSelectors
4398
- });
4406
+ }, "vitest");
4399
4407
  },
4400
4408
  /**
4401
4409
  * Clear test state without writing test results.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chromatic-com/vitest",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Chromatic Visual Regression Testing for Vitest",
5
5
  "repository": {
6
6
  "type": "git",