@chromatic-com/vitest 0.1.2 → 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 +23 -7
  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);
@@ -4219,10 +4227,18 @@ var ChromaticReporter = class _ChromaticReporter {
4219
4227
  if (this.options.builtInReporter !== "default" && this.options.builtInReporter !== "tree") {
4220
4228
  return;
4221
4229
  }
4230
+ let noSlowTests = true;
4231
+ for (const testCase of testModule.children.allTests()) {
4232
+ if (testCase.diagnostic()?.slow) {
4233
+ noSlowTests = false;
4234
+ break;
4235
+ }
4236
+ }
4237
+ const indentProjectName = noSlowTests && this.options.builtInReporter === "default";
4222
4238
  this.logSnapshots({
4223
4239
  count: this.snapshotCountPerEntity.get(testModule.id) ?? 0,
4224
- indentation: this.options.builtInReporter === "default" ? 3 : 2,
4225
- projectName: this.options.builtInReporter === "default" && testModule.project.name
4240
+ indentation: indentProjectName ? 3 : 2,
4241
+ projectName: indentProjectName && testModule.project.name
4226
4242
  });
4227
4243
  }
4228
4244
  onTestRunEnd() {
@@ -4387,7 +4403,7 @@ function createCommands(options) {
4387
4403
  prefersReducedMotion: testOptions.prefersReducedMotion ?? options.prefersReducedMotion,
4388
4404
  cropToViewport: testOptions.cropToViewport ?? options.cropToViewport,
4389
4405
  ignoreSelectors: testOptions.ignoreSelectors ?? options.ignoreSelectors
4390
- });
4406
+ }, "vitest");
4391
4407
  },
4392
4408
  /**
4393
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.2",
3
+ "version": "0.1.4",
4
4
  "description": "Chromatic Visual Regression Testing for Vitest",
5
5
  "repository": {
6
6
  "type": "git",