vitest-image-snapshot 0.6.47 → 0.6.48

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.
@@ -4,7 +4,6 @@ import * as path from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
5
  import * as http from "node:http";
6
6
  import isCI from "is-ci";
7
-
8
7
  //#region src/DiffReport.ts
9
8
  const templatesDir = path.join(path.dirname(fileURLToPath(import.meta.url)), "templates");
10
9
  /** Clear the diff report directory if it exists. */
@@ -132,7 +131,6 @@ function diffCellHTML(diffPath) {
132
131
  </a>
133
132
  <div class="label">Diff</div>`;
134
133
  }
135
-
136
134
  //#endregion
137
135
  //#region src/ImageSnapshotReporter.ts
138
136
  const autoOpenValues = [
@@ -255,6 +253,5 @@ function captureFailure(testCase, data, message) {
255
253
  }
256
254
  };
257
255
  }
258
-
259
256
  //#endregion
260
- export { clearDiffReport as n, generateDiffReport as r, ImageSnapshotReporter as t };
257
+ export { clearDiffReport as n, generateDiffReport as r, ImageSnapshotReporter as t };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { n as ImageSnapshotReporter, r as ImageSnapshotReporterOptions, t as AutoOpen } from "./ImageSnapshotReporter-CRMgr4HQ.js";
1
+ import { n as ImageSnapshotReporter, r as ImageSnapshotReporterOptions, t as AutoOpen } from "./ImageSnapshotReporter-D3jHkOX3.js";
2
2
 
3
3
  //#region src/ImageComparison.d.ts
4
4
  /** nodejs compatible interface to DOM ImageData */
package/dist/index.js CHANGED
@@ -1,11 +1,9 @@
1
- import { n as clearDiffReport, r as generateDiffReport, t as ImageSnapshotReporter } from "./ImageSnapshotReporter-ByFxF05b.js";
1
+ import { n as clearDiffReport, r as generateDiffReport, t as ImageSnapshotReporter } from "./ImageSnapshotReporter-D7WPlzM3.js";
2
2
  import * as fs from "node:fs";
3
3
  import * as path from "node:path";
4
4
  import pixelmatch from "pixelmatch";
5
5
  import { PNG } from "pngjs";
6
- import { expect } from "vitest";
7
- import { getCurrentTest } from "vitest/suite";
8
-
6
+ import { TestRunner, expect } from "vitest";
9
7
  //#region src/ImageComparison.ts
10
8
  async function compareImages(reference, actual, options = {}) {
11
9
  const { threshold = .1, allowedPixelRatio = 0, allowedPixels = 0, includeAA = true } = options;
@@ -60,7 +58,6 @@ function toPixelData(input) {
60
58
  height: input.height
61
59
  };
62
60
  }
63
-
64
61
  //#endregion
65
62
  //#region src/PNGUtil.ts
66
63
  /** Convert standard browser ImageData to PNG Buffer for comparison. */
@@ -73,7 +70,6 @@ function pngBuffer(imageData) {
73
70
  png.data = Buffer.from(imageData.data);
74
71
  return PNG.sync.write(png);
75
72
  }
76
-
77
73
  //#endregion
78
74
  //#region src/SnapshotManager.ts
79
75
  /** Manage reference/actual/diff snapshot files. */
@@ -127,7 +123,6 @@ var ImageSnapshotManager = class {
127
123
  await fs.promises.writeFile(filepath, buffer);
128
124
  }
129
125
  };
130
-
131
126
  //#endregion
132
127
  //#region src/ImageSnapshotMatcher.ts
133
128
  /** Register toMatchImage() matcher with Vitest */
@@ -152,7 +147,7 @@ async function toMatchImage(received, nameOrOptions) {
152
147
  };
153
148
  }
154
149
  if (!comparison.pass) {
155
- const currentTest = getCurrentTest();
150
+ const currentTest = TestRunner.getCurrentTest();
156
151
  if (currentTest) currentTest.meta.imageSnapshotFailure = {
157
152
  actualPath: manager.actualPath(snapshotName),
158
153
  expectedPath: manager.referencePath(snapshotName),
@@ -197,6 +192,5 @@ async function missingSnapshot(manager, actualBuffer, snapshotName) {
197
192
  message: () => `No snapshot found: ${snapshotName}. Run with -u to create.`
198
193
  };
199
194
  }
200
-
201
195
  //#endregion
202
- export { ImageSnapshotManager, ImageSnapshotReporter, clearDiffReport, compareImages, generateDiffReport, imageMatcher, pngBuffer };
196
+ export { ImageSnapshotManager, ImageSnapshotReporter, clearDiffReport, compareImages, generateDiffReport, imageMatcher, pngBuffer };
@@ -1,2 +1,2 @@
1
- import { n as ImageSnapshotReporter } from "./ImageSnapshotReporter-CRMgr4HQ.js";
1
+ import { n as ImageSnapshotReporter } from "./ImageSnapshotReporter-D3jHkOX3.js";
2
2
  export { ImageSnapshotReporter as default };
package/dist/reporter.js CHANGED
@@ -1,7 +1,5 @@
1
- import { t as ImageSnapshotReporter } from "./ImageSnapshotReporter-ByFxF05b.js";
2
-
1
+ import { t as ImageSnapshotReporter } from "./ImageSnapshotReporter-D7WPlzM3.js";
3
2
  //#region src/reporter.ts
4
3
  var reporter_default = ImageSnapshotReporter;
5
-
6
4
  //#endregion
7
- export { reporter_default as default };
5
+ export { reporter_default as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitest-image-snapshot",
3
- "version": "0.6.47",
3
+ "version": "0.6.48",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",
@@ -27,7 +27,7 @@
27
27
  "@types/pngjs": "^6.0.0"
28
28
  },
29
29
  "peerDependencies": {
30
- "vitest": "^4.0.18"
30
+ "vitest": "^4.1.0"
31
31
  },
32
32
  "license": "MIT",
33
33
  "keywords": [
@@ -1,5 +1,4 @@
1
- import { expect } from "vitest";
2
- import { getCurrentTest } from "vitest/suite";
1
+ import { expect, TestRunner } from "vitest";
3
2
  import {
4
3
  type ComparisonOptions,
5
4
  compareImages,
@@ -78,7 +77,7 @@ async function toMatchImage(
78
77
 
79
78
  // Store failure metadata for reporter
80
79
  if (!comparison.pass) {
81
- const currentTest = getCurrentTest();
80
+ const currentTest = TestRunner.getCurrentTest();
82
81
  if (currentTest) {
83
82
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
84
83
  (currentTest.meta as any).imageSnapshotFailure = {