vitest-image-snapshot 0.6.50 → 0.6.51

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/README.md CHANGED
@@ -246,7 +246,7 @@ test("canvas output matches snapshot", async () => {
246
246
 
247
247
  ## Build Version
248
248
  **vitest-image-snapshot** is currently
249
- part of the [wesl-js](https://github.com/wgsl-tooling-wg/wesl-js/) monorepo.
249
+ part of the [wesl-js](https://github.com/webgpu-tools/wesl-js/) monorepo.
250
250
  (It'll eventually move to it's own repo).
251
251
 
252
252
  ## Contributions
@@ -5,7 +5,13 @@ import { fileURLToPath } from "node:url";
5
5
  import * as http from "node:http";
6
6
  import isCI from "is-ci";
7
7
  //#region src/DiffReport.ts
8
- const templatesDir = path.join(path.dirname(fileURLToPath(import.meta.url)), "templates");
8
+ const autoOpenValues = [
9
+ "always",
10
+ "failures",
11
+ "never"
12
+ ];
13
+ const thisDir = path.dirname(fileURLToPath(import.meta.url));
14
+ const templatesDir = path.join(thisDir, "templates");
9
15
  /** Clear the diff report directory if it exists. */
10
16
  async function clearDiffReport(reportDir) {
11
17
  if (fs.existsSync(reportDir)) await fs.promises.rm(reportDir, { recursive: true });
@@ -25,7 +31,7 @@ async function generateDiffReport(failures, config) {
25
31
  const outputPath = path.join(reportDir, "index.html");
26
32
  await fs.promises.writeFile(outputPath, html, "utf-8");
27
33
  if (failures.length > 0 && !liveReload) console.log(`\n Image diff report: ${outputPath}`);
28
- if (autoOpen === "never" || autoOpen === "failures" && failures.length === 0) return;
34
+ if (!(autoOpen === "always" || autoOpen === "failures" && failures.length > 0)) return;
29
35
  try {
30
36
  exec(`${{
31
37
  darwin: "open",
@@ -82,7 +88,7 @@ function createReportHTML(failures, liveReload) {
82
88
  timestamp: escapeHtml(timestamp),
83
89
  script
84
90
  });
85
- const rows = failures.map((failure) => createRowHTML(failure)).join("\n");
91
+ const rows = failures.map(createRowHTML).join("\n");
86
92
  return renderTemplate(loadTemplate("report-failure.hbs"), {
87
93
  totalFailures: String(totalFailures),
88
94
  testPlural: totalFailures === 1 ? "test" : "tests",
@@ -133,11 +139,6 @@ function diffCellHTML(diffPath) {
133
139
  }
134
140
  //#endregion
135
141
  //#region src/ImageSnapshotReporter.ts
136
- const autoOpenValues = [
137
- "always",
138
- "failures",
139
- "never"
140
- ];
141
142
  /** Vitest reporter that generates HTML diff reports for image snapshot failures */
142
143
  var ImageSnapshotReporter = class {
143
144
  failuresByFile = /* @__PURE__ */ new Map();
@@ -171,7 +172,7 @@ var ImageSnapshotReporter = class {
171
172
  startServer() {
172
173
  const reportDir = this.resolveReportDir();
173
174
  const server = http.createServer((req, res) => {
174
- const url = req.url === "/" ? "/index.html" : req.url || "/index.html";
175
+ const url = !req.url || req.url === "/" ? "/index.html" : req.url;
175
176
  const filePath = path.join(reportDir, url);
176
177
  fs.stat(filePath, (statErr, stats) => {
177
178
  if (statErr) {
@@ -180,7 +181,12 @@ var ImageSnapshotReporter = class {
180
181
  return;
181
182
  }
182
183
  const ext = path.extname(filePath);
183
- const contentType = ext === ".html" ? "text/html" : ext === ".css" ? "text/css" : ext === ".png" ? "image/png" : "application/octet-stream";
184
+ const contentType = {
185
+ ".html": "text/html",
186
+ ".css": "text/css",
187
+ ".png": "image/png",
188
+ ".js": "text/javascript"
189
+ }[ext] ?? "application/octet-stream";
184
190
  const headers = {
185
191
  "Content-Type": contentType,
186
192
  "Last-Modified": stats.mtime.toUTCString()
@@ -213,11 +219,10 @@ var ImageSnapshotReporter = class {
213
219
  onTestCaseResult(testCase) {
214
220
  const result = testCase.result();
215
221
  if (result?.state !== "failed") return;
216
- const meta = testCase.meta();
217
- if (!meta.imageSnapshotFailure) return;
218
- const error = result.errors?.[0];
219
- const failure = captureFailure(testCase, meta.imageSnapshotFailure, error?.message || "");
220
- const moduleId = testCase.module.moduleId;
222
+ const { imageSnapshotFailure } = testCase.meta();
223
+ if (!imageSnapshotFailure) return;
224
+ const failure = captureFailure(testCase, imageSnapshotFailure, result.errors?.[0]?.message || "");
225
+ const { moduleId } = testCase.module;
221
226
  const existing = this.failuresByFile.get(moduleId) || [];
222
227
  this.failuresByFile.set(moduleId, [...existing, failure]);
223
228
  }
@@ -235,16 +240,18 @@ var ImageSnapshotReporter = class {
235
240
  return path.isAbsolute(this.reportPath) ? this.reportPath : path.join(configRoot, this.reportPath);
236
241
  }
237
242
  };
243
+ /** Build a failure record from test metadata for the diff report. */
238
244
  function captureFailure(testCase, data, message) {
239
245
  const snapshotName = data.actualPath.match(/([^/]+)\.png$/)?.[1] || "unknown";
246
+ const { mismatchedPixels, mismatchedPixelRatio } = data;
240
247
  return {
241
248
  testName: testCase.fullName || testCase.name,
242
249
  snapshotName,
243
250
  comparison: {
244
251
  pass: false,
245
252
  message,
246
- mismatchedPixels: data.mismatchedPixels,
247
- mismatchedPixelRatio: data.mismatchedPixelRatio
253
+ mismatchedPixels,
254
+ mismatchedPixelRatio
248
255
  },
249
256
  paths: {
250
257
  reference: data.expectedPath,
@@ -254,4 +261,4 @@ function captureFailure(testCase, data, message) {
254
261
  };
255
262
  }
256
263
  //#endregion
257
- export { clearDiffReport as n, generateDiffReport as r, ImageSnapshotReporter as t };
264
+ export { generateDiffReport as i, autoOpenValues as n, clearDiffReport as r, ImageSnapshotReporter as t };
@@ -0,0 +1,91 @@
1
+ import { Reporter, TestCase, TestSpecification, Vitest } from "vitest/node";
2
+
3
+ //#region src/ImageComparison.d.ts
4
+ /** nodejs compatible interface to DOM ImageData */
5
+ interface ImageData {
6
+ readonly data: Uint8ClampedArray;
7
+ readonly width: number;
8
+ readonly height: number;
9
+ readonly colorSpace: "srgb" | "display-p3";
10
+ }
11
+ /** Options controlling image comparison thresholds and behavior. */
12
+ interface ComparisonOptions {
13
+ /** Color difference threshold (0-1). Default: 0.1 */
14
+ threshold?: number;
15
+ /** Max ratio of pixels allowed to differ (0-1). Default: 0 */
16
+ allowedPixelRatio?: number;
17
+ /** Max absolute number of pixels allowed to differ. Default: 0 */
18
+ allowedPixels?: number;
19
+ /** If true, disables detecting and ignoring anti-aliased pixels. Default: true */
20
+ includeAA?: boolean;
21
+ }
22
+ interface ComparisonResult {
23
+ pass: boolean;
24
+ diffBuffer?: Buffer;
25
+ message: string;
26
+ mismatchedPixels: number;
27
+ mismatchedPixelRatio: number;
28
+ }
29
+ declare function compareImages(reference: ImageData | Buffer, actual: ImageData | Buffer, options?: ComparisonOptions): Promise<ComparisonResult>;
30
+ //#endregion
31
+ //#region src/DiffReport.d.ts
32
+ declare const autoOpenValues: readonly ["always", "failures", "never"];
33
+ type AutoOpen = (typeof autoOpenValues)[number];
34
+ /** Failed image snapshot with comparison results and file paths. */
35
+ interface ImageSnapshotFailure {
36
+ testName: string;
37
+ snapshotName: string;
38
+ comparison: ComparisonResult;
39
+ paths: {
40
+ reference: string;
41
+ actual: string;
42
+ diff: string;
43
+ };
44
+ }
45
+ /** Configuration for HTML diff report generation. */
46
+ interface DiffReportConfig {
47
+ /** Auto-open report in browser. Default: "failures" or "never" in CI */
48
+ autoOpen: AutoOpen;
49
+ /** Directory path for generated HTML report (absolute or relative). */
50
+ reportDir: string;
51
+ /** Vitest config root for calculating relative paths when copying images */
52
+ configRoot: string;
53
+ /** Enable live reload script in HTML. Default: false */
54
+ liveReload?: boolean;
55
+ }
56
+ /** Clear the diff report directory if it exists. */
57
+ declare function clearDiffReport(reportDir: string): Promise<void>;
58
+ /** Generate HTML diff report for image snapshot results. */
59
+ declare function generateDiffReport(failures: ImageSnapshotFailure[], config: DiffReportConfig): Promise<void>;
60
+ //#endregion
61
+ //#region src/ImageSnapshotReporter.d.ts
62
+ interface ImageSnapshotReporterOptions {
63
+ /** Auto-open report in browser. Default: "failures" or "never" in CI */
64
+ autoOpen?: AutoOpen;
65
+ /** Report directory (relative to config.root or absolute) */
66
+ reportPath?: string;
67
+ /** Port for live-reload server. Set to 0 to disable. Default: 4343 */
68
+ port?: number;
69
+ }
70
+ /** Vitest reporter that generates HTML diff reports for image snapshot failures */
71
+ declare class ImageSnapshotReporter implements Reporter {
72
+ private failuresByFile;
73
+ private vitest;
74
+ private reportPath?;
75
+ private autoOpen;
76
+ private port;
77
+ private serverStarted;
78
+ constructor(options?: ImageSnapshotReporterOptions);
79
+ /** Resolve autoOpen setting with priority: CI override > env var > config option > default */
80
+ private resolveAutoOpen;
81
+ /** Parse and validate IMAGE_DIFF_AUTO_OPEN environment variable */
82
+ private envAutoOpen;
83
+ onInit(vitest: Vitest): void;
84
+ private startServer;
85
+ onTestRunStart(specifications: ReadonlyArray<TestSpecification>): void;
86
+ onTestCaseResult(testCase: TestCase): void;
87
+ onTestRunEnd(): Promise<void>;
88
+ private resolveReportDir;
89
+ }
90
+ //#endregion
91
+ export { ImageSnapshotFailure as a, generateDiffReport as c, ImageData as d, compareImages as f, DiffReportConfig as i, ComparisonOptions as l, ImageSnapshotReporterOptions as n, autoOpenValues as o, AutoOpen as r, clearDiffReport as s, ImageSnapshotReporter as t, ComparisonResult as u };
package/dist/index.d.ts CHANGED
@@ -1,61 +1,5 @@
1
- import { n as ImageSnapshotReporter, r as ImageSnapshotReporterOptions, t as AutoOpen } from "./ImageSnapshotReporter-D3jHkOX3.js";
1
+ import { a as ImageSnapshotFailure, c as generateDiffReport, d as ImageData, f as compareImages, i as DiffReportConfig, l as ComparisonOptions, n as ImageSnapshotReporterOptions, o as autoOpenValues, r as AutoOpen, s as clearDiffReport, t as ImageSnapshotReporter, u as ComparisonResult } from "./ImageSnapshotReporter-D6HJydo6.js";
2
2
 
3
- //#region src/ImageComparison.d.ts
4
- /** nodejs compatible interface to DOM ImageData */
5
- interface ImageData {
6
- readonly data: Uint8ClampedArray;
7
- readonly width: number;
8
- readonly height: number;
9
- readonly colorSpace: "srgb" | "display-p3";
10
- }
11
- /** Options controlling image comparison thresholds and behavior. */
12
- interface ComparisonOptions {
13
- /** Color difference threshold (0-1). Default: 0.1 */
14
- threshold?: number;
15
- /** Max ratio of pixels allowed to differ (0-1). Default: 0 */
16
- allowedPixelRatio?: number;
17
- /** Max absolute number of pixels allowed to differ. Default: 0 */
18
- allowedPixels?: number;
19
- /** If true, disables detecting and ignoring anti-aliased pixels. Default: true */
20
- includeAA?: boolean;
21
- }
22
- interface ComparisonResult {
23
- pass: boolean;
24
- diffBuffer?: Buffer;
25
- message: string;
26
- mismatchedPixels: number;
27
- mismatchedPixelRatio: number;
28
- }
29
- declare function compareImages(reference: ImageData | Buffer, actual: ImageData | Buffer, options?: ComparisonOptions): Promise<ComparisonResult>;
30
- //#endregion
31
- //#region src/DiffReport.d.ts
32
- /** Failed image snapshot with comparison results and file paths. */
33
- interface ImageSnapshotFailure {
34
- testName: string;
35
- snapshotName: string;
36
- comparison: ComparisonResult;
37
- paths: {
38
- reference: string;
39
- actual: string;
40
- diff: string;
41
- };
42
- }
43
- /** Configuration for HTML diff report generation. */
44
- interface DiffReportConfig {
45
- /** Auto-open report in browser. Default: "failures" or "never" in CI */
46
- autoOpen: AutoOpen;
47
- /** Directory path for generated HTML report (absolute or relative). */
48
- reportDir: string;
49
- /** Vitest config root for calculating relative paths when copying images */
50
- configRoot: string;
51
- /** Enable live reload script in HTML. Default: false */
52
- liveReload?: boolean;
53
- }
54
- /** Clear the diff report directory if it exists. */
55
- declare function clearDiffReport(reportDir: string): Promise<void>;
56
- /** Generate HTML diff report for image snapshot results. */
57
- declare function generateDiffReport(failures: ImageSnapshotFailure[], config: DiffReportConfig): Promise<void>;
58
- //#endregion
59
3
  //#region src/ImageSnapshotMatcher.d.ts
60
4
  interface MatchImageOptions extends ComparisonOptions {
61
5
  name?: string;
@@ -101,4 +45,4 @@ declare module "vitest" {
101
45
  }
102
46
  }
103
47
  //#endregion
104
- export { AutoOpen, ComparisonOptions, ComparisonResult, DiffReportConfig, ImageData, ImageSnapshotFailure, ImageSnapshotManager, ImageSnapshotReporter, ImageSnapshotReporterOptions, MatchImageOptions, SnapshotConfig, clearDiffReport, compareImages, generateDiffReport, imageMatcher, pngBuffer };
48
+ export { AutoOpen, ComparisonOptions, ComparisonResult, DiffReportConfig, ImageData, ImageSnapshotFailure, ImageSnapshotManager, ImageSnapshotReporter, ImageSnapshotReporterOptions, MatchImageOptions, SnapshotConfig, autoOpenValues, clearDiffReport, compareImages, generateDiffReport, imageMatcher, pngBuffer };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { n as clearDiffReport, r as generateDiffReport, t as ImageSnapshotReporter } from "./ImageSnapshotReporter-D7WPlzM3.js";
1
+ import { i as generateDiffReport, n as autoOpenValues, r as clearDiffReport, t as ImageSnapshotReporter } from "./ImageSnapshotReporter-B3evIi81.js";
2
2
  import * as fs from "node:fs";
3
3
  import * as path from "node:path";
4
4
  import pixelmatch from "pixelmatch";
@@ -199,4 +199,4 @@ async function missingSnapshot(manager, actualBuffer, snapshotName) {
199
199
  };
200
200
  }
201
201
  //#endregion
202
- export { ImageSnapshotManager, ImageSnapshotReporter, clearDiffReport, compareImages, generateDiffReport, imageMatcher, pngBuffer };
202
+ export { ImageSnapshotManager, ImageSnapshotReporter, autoOpenValues, clearDiffReport, compareImages, generateDiffReport, imageMatcher, pngBuffer };
@@ -1,2 +1,2 @@
1
- import { n as ImageSnapshotReporter } from "./ImageSnapshotReporter-D3jHkOX3.js";
1
+ import { t as ImageSnapshotReporter } from "./ImageSnapshotReporter-D6HJydo6.js";
2
2
  export { ImageSnapshotReporter as default };
package/dist/reporter.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as ImageSnapshotReporter } from "./ImageSnapshotReporter-D7WPlzM3.js";
1
+ import { t as ImageSnapshotReporter } from "./ImageSnapshotReporter-B3evIi81.js";
2
2
  //#region src/reporter.ts
3
3
  var reporter_default = ImageSnapshotReporter;
4
4
  //#endregion
package/package.json CHANGED
@@ -1,17 +1,21 @@
1
1
  {
2
2
  "name": "vitest-image-snapshot",
3
- "version": "0.6.50",
3
+ "version": "0.6.51",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",
7
7
  "src"
8
8
  ],
9
- "repository": "github:wgsl-tooling-wg/wesl-js",
9
+ "repository": "github:webgpu-tools/wesl-js",
10
10
  "exports": {
11
11
  ".": {
12
12
  "types": "./dist/index.d.ts",
13
13
  "import": "./dist/index.js"
14
14
  },
15
+ "./core": {
16
+ "types": "./dist/core/index.d.ts",
17
+ "import": "./dist/core/index.js"
18
+ },
15
19
  "./reporter": {
16
20
  "types": "./dist/reporter.d.ts",
17
21
  "import": "./dist/reporter.js"
package/src/DiffReport.ts CHANGED
@@ -3,12 +3,12 @@ import * as fs from "node:fs";
3
3
  import * as path from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
5
  import type { ComparisonResult } from "./ImageComparison.ts";
6
- import type { AutoOpen } from "./ImageSnapshotReporter.ts";
7
6
 
8
- const templatesDir = path.join(
9
- path.dirname(fileURLToPath(import.meta.url)),
10
- "templates",
11
- );
7
+ export const autoOpenValues = ["always", "failures", "never"] as const;
8
+ export type AutoOpen = (typeof autoOpenValues)[number];
9
+
10
+ const thisDir = path.dirname(fileURLToPath(import.meta.url));
11
+ const templatesDir = path.join(thisDir, "templates");
12
12
 
13
13
  /** Failed image snapshot with comparison results and file paths. */
14
14
  export interface ImageSnapshotFailure {
@@ -64,11 +64,11 @@ export async function generateDiffReport(
64
64
  );
65
65
  }
66
66
 
67
- const withCopiedImages =
67
+ const copied =
68
68
  failures.length > 0
69
69
  ? await copyImagesToReport(failures, reportDir, configRoot)
70
70
  : [];
71
- const html = createReportHTML(withCopiedImages, liveReload);
71
+ const html = createReportHTML(copied, liveReload);
72
72
  const outputPath = path.join(reportDir, "index.html");
73
73
 
74
74
  await fs.promises.writeFile(outputPath, html, "utf-8");
@@ -78,14 +78,10 @@ export async function generateDiffReport(
78
78
  console.log(`\n Image diff report: ${outputPath}`);
79
79
  }
80
80
 
81
- if (
82
- autoOpen === "never" ||
83
- (autoOpen === "failures" && failures.length === 0)
84
- ) {
85
- return;
86
- }
81
+ const shouldOpen =
82
+ autoOpen === "always" || (autoOpen === "failures" && failures.length > 0);
83
+ if (!shouldOpen) return;
87
84
 
88
- // open the browser to view the report
89
85
  try {
90
86
  const commands: Record<string, string> = { darwin: "open", win32: "start" };
91
87
  const cmd = commands[process.platform] ?? "xdg-open";
@@ -145,7 +141,6 @@ function renderTemplate(
145
141
  result = result.replaceAll(`{{${key}}}`, value);
146
142
  }
147
143
 
148
- // Check for any unreplaced placeholders
149
144
  const unreplaced = result.match(/\{\{(\w+)\}\}/g);
150
145
  if (unreplaced) {
151
146
  const keys = unreplaced.map(m => m.slice(2, -2)).join(", ");
@@ -170,7 +165,7 @@ function createReportHTML(
170
165
  });
171
166
  }
172
167
 
173
- const rows = failures.map(failure => createRowHTML(failure)).join("\n");
168
+ const rows = failures.map(createRowHTML).join("\n");
174
169
 
175
170
  return renderTemplate(loadTemplate("report-failure.hbs"), {
176
171
  totalFailures: String(totalFailures),
@@ -8,10 +8,12 @@ import type {
8
8
  TestSpecification,
9
9
  Vitest,
10
10
  } from "vitest/node";
11
- import { generateDiffReport, type ImageSnapshotFailure } from "./DiffReport.ts";
12
-
13
- const autoOpenValues = ["always", "failures", "never"] as const;
14
- export type AutoOpen = (typeof autoOpenValues)[number];
11
+ import {
12
+ type AutoOpen,
13
+ autoOpenValues,
14
+ generateDiffReport,
15
+ type ImageSnapshotFailure,
16
+ } from "./DiffReport.ts";
15
17
 
16
18
  /** Metadata captured when image snapshot test fails, used to generate HTML report. */
17
19
  interface ImageSnapshotFailureData {
@@ -78,7 +80,7 @@ export class ImageSnapshotReporter implements Reporter {
78
80
  private startServer() {
79
81
  const reportDir = this.resolveReportDir();
80
82
  const server = http.createServer((req, res) => {
81
- const url = req.url === "/" ? "/index.html" : req.url || "/index.html";
83
+ const url = !req.url || req.url === "/" ? "/index.html" : req.url;
82
84
  const filePath = path.join(reportDir, url);
83
85
 
84
86
  fs.stat(filePath, (statErr, stats) => {
@@ -89,14 +91,13 @@ export class ImageSnapshotReporter implements Reporter {
89
91
  }
90
92
 
91
93
  const ext = path.extname(filePath);
92
- const contentType =
93
- ext === ".html"
94
- ? "text/html"
95
- : ext === ".css"
96
- ? "text/css"
97
- : ext === ".png"
98
- ? "image/png"
99
- : "application/octet-stream";
94
+ const mimeTypes: Record<string, string> = {
95
+ ".html": "text/html",
96
+ ".css": "text/css",
97
+ ".png": "image/png",
98
+ ".js": "text/javascript",
99
+ };
100
+ const contentType = mimeTypes[ext] ?? "application/octet-stream";
100
101
  const headers = {
101
102
  "Content-Type": contentType,
102
103
  "Last-Modified": stats.mtime.toUTCString(),
@@ -140,18 +141,13 @@ export class ImageSnapshotReporter implements Reporter {
140
141
  const result = testCase.result();
141
142
  if (result?.state !== "failed") return;
142
143
 
143
- const meta = testCase.meta() as {
144
- imageSnapshotFailure?: ImageSnapshotFailureData;
145
- };
146
- if (!meta.imageSnapshotFailure) return;
147
-
148
- const error = result.errors?.[0];
149
- const failure = captureFailure(
150
- testCase,
151
- meta.imageSnapshotFailure,
152
- error?.message || "",
153
- );
154
- const moduleId = testCase.module.moduleId;
144
+ type Meta = { imageSnapshotFailure?: ImageSnapshotFailureData };
145
+ const { imageSnapshotFailure } = testCase.meta() as Meta;
146
+ if (!imageSnapshotFailure) return;
147
+
148
+ const message = result.errors?.[0]?.message || "";
149
+ const failure = captureFailure(testCase, imageSnapshotFailure, message);
150
+ const { moduleId } = testCase.module;
155
151
  const existing = this.failuresByFile.get(moduleId) || [];
156
152
  this.failuresByFile.set(moduleId, [...existing, failure]);
157
153
  }
@@ -177,21 +173,22 @@ export class ImageSnapshotReporter implements Reporter {
177
173
  }
178
174
  }
179
175
 
176
+ /** Build a failure record from test metadata for the diff report. */
180
177
  function captureFailure(
181
178
  testCase: TestCase,
182
179
  data: ImageSnapshotFailureData,
183
180
  message: string,
184
181
  ): ImageSnapshotFailure {
185
182
  const snapshotName = data.actualPath.match(/([^/]+)\.png$/)?.[1] || "unknown";
186
-
183
+ const { mismatchedPixels, mismatchedPixelRatio } = data;
187
184
  return {
188
185
  testName: testCase.fullName || testCase.name,
189
186
  snapshotName,
190
187
  comparison: {
191
188
  pass: false,
192
189
  message,
193
- mismatchedPixels: data.mismatchedPixels,
194
- mismatchedPixelRatio: data.mismatchedPixelRatio,
190
+ mismatchedPixels,
191
+ mismatchedPixelRatio,
195
192
  },
196
193
  paths: {
197
194
  reference: data.expectedPath,
@@ -0,0 +1,4 @@
1
+ export * from "../DiffReport.ts";
2
+ export * from "../ImageComparison.ts";
3
+ export * from "../PNGUtil.ts";
4
+ export * from "../SnapshotManager.ts";
@@ -1,35 +0,0 @@
1
- import { Reporter, TestCase, TestSpecification, Vitest } from "vitest/node";
2
-
3
- //#region src/ImageSnapshotReporter.d.ts
4
- declare const autoOpenValues: readonly ["always", "failures", "never"];
5
- type AutoOpen = (typeof autoOpenValues)[number];
6
- interface ImageSnapshotReporterOptions {
7
- /** Auto-open report in browser. Default: "failures" or "never" in CI */
8
- autoOpen?: AutoOpen;
9
- /** Report directory (relative to config.root or absolute) */
10
- reportPath?: string;
11
- /** Port for live-reload server. Set to 0 to disable. Default: 4343 */
12
- port?: number;
13
- }
14
- /** Vitest reporter that generates HTML diff reports for image snapshot failures */
15
- declare class ImageSnapshotReporter implements Reporter {
16
- private failuresByFile;
17
- private vitest;
18
- private reportPath?;
19
- private autoOpen;
20
- private port;
21
- private serverStarted;
22
- constructor(options?: ImageSnapshotReporterOptions);
23
- /** Resolve autoOpen setting with priority: CI override > env var > config option > default */
24
- private resolveAutoOpen;
25
- /** Parse and validate IMAGE_DIFF_AUTO_OPEN environment variable */
26
- private envAutoOpen;
27
- onInit(vitest: Vitest): void;
28
- private startServer;
29
- onTestRunStart(specifications: ReadonlyArray<TestSpecification>): void;
30
- onTestCaseResult(testCase: TestCase): void;
31
- onTestRunEnd(): Promise<void>;
32
- private resolveReportDir;
33
- }
34
- //#endregion
35
- export { ImageSnapshotReporter as n, ImageSnapshotReporterOptions as r, AutoOpen as t };