@jsenv/snapshot 2.9.11 → 2.10.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/snapshot",
3
- "version": "2.9.11",
3
+ "version": "2.10.0",
4
4
  "description": "Snapshot testing",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -38,7 +38,7 @@
38
38
  "@jsenv/exception": "1.1.2",
39
39
  "@jsenv/humanize": "1.2.8",
40
40
  "@jsenv/filesystem": "4.10.2",
41
- "@jsenv/terminal-recorder": "1.4.6",
41
+ "@jsenv/terminal-recorder": "1.4.7",
42
42
  "@jsenv/urls": "2.5.2",
43
43
  "@jsenv/utils": "2.1.2",
44
44
  "ansi-regex": "6.0.1",
@@ -1,3 +1,4 @@
1
+ import { assert } from "@jsenv/assert";
1
2
  import {
2
3
  assertAndNormalizeDirectoryUrl,
3
4
  assertAndNormalizeFileUrl,
@@ -16,8 +17,6 @@ import {
16
17
  import { CONTENT_TYPE } from "@jsenv/utils/src/content_type/content_type.js";
17
18
  import { readdirSync, readFileSync, statSync } from "node:fs";
18
19
  import { fileURLToPath } from "node:url";
19
-
20
- import { assert } from "@jsenv/assert";
21
20
  import { comparePngFiles } from "./compare_png_files.js";
22
21
  import {
23
22
  ExtraFileAssertionError,
@@ -267,6 +266,23 @@ const createDirectorySnapshot = (
267
266
  const nextDirectoryContentSnapshot =
268
267
  nextDirectorySnapshot.contentSnapshot;
269
268
  const nextRelativeUrls = Object.keys(nextDirectoryContentSnapshot);
269
+ // first compare the content
270
+ {
271
+ for (const relativeUrl of relativeUrls) {
272
+ if (!shouldCompareFileContent(new URL(relativeUrl, directoryUrl))) {
273
+ continue;
274
+ }
275
+ const snapshot = directoryContentSnapshot[relativeUrl];
276
+ const nextSnapshot = nextDirectoryContentSnapshot[relativeUrl];
277
+ if (nextSnapshot) {
278
+ snapshot.compare(nextSnapshot, {
279
+ throwWhenDiff: relativeUrl.endsWith(".gif")
280
+ ? false
281
+ : throwWhenDiff,
282
+ });
283
+ }
284
+ }
285
+ }
270
286
  // missing content
271
287
  if (throwWhenDiff) {
272
288
  const missingRelativeUrls = relativeUrls.filter(
@@ -323,23 +339,6 @@ ${extraUrls.join("\n")}`);
323
339
  throw extraFileAssertionError;
324
340
  }
325
341
  }
326
- // content
327
- {
328
- for (const relativeUrl of relativeUrls) {
329
- if (!shouldCompareFileContent(new URL(relativeUrl, directoryUrl))) {
330
- continue;
331
- }
332
- const snapshot = directoryContentSnapshot[relativeUrl];
333
- const nextSnapshot = nextDirectoryContentSnapshot[relativeUrl];
334
- if (nextSnapshot) {
335
- snapshot.compare(nextSnapshot, {
336
- throwWhenDiff: relativeUrl.endsWith(".gif")
337
- ? false
338
- : throwWhenDiff,
339
- });
340
- }
341
- }
342
- }
343
342
  },
344
343
  };
345
344
  try {