@jsenv/snapshot 1.2.8 → 1.3.1

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": "1.2.8",
3
+ "version": "1.3.1",
4
4
  "description": "Snapshot testing",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -35,11 +35,11 @@
35
35
  "test": "node --conditions=development ./scripts/test.mjs"
36
36
  },
37
37
  "dependencies": {
38
- "@jsenv/filesystem": "4.6.5",
39
- "@jsenv/urls": "2.2.3",
38
+ "@jsenv/filesystem": "4.6.7",
39
+ "@jsenv/urls": "2.2.5",
40
40
  "@jsenv/utils": "2.1.1",
41
- "@jsenv/assert": "3.0.3",
42
- "prettier": "3.2.4"
41
+ "@jsenv/assert": "4.0.1",
42
+ "prettier": "3.3.2"
43
43
  },
44
44
  "devDependencies": {
45
45
  "strip-ansi": "7.1.0"
@@ -13,7 +13,6 @@ import { urlToFilename, urlToRelativeUrl } from "@jsenv/urls";
13
13
  import { CONTENT_TYPE } from "@jsenv/utils/src/content_type/content_type.js";
14
14
 
15
15
  import { assert } from "@jsenv/assert";
16
- import { getStringAssertionErrorInfo } from "@jsenv/assert/src/error_info/strings.js";
17
16
 
18
17
  export const takeFileSnapshot = (fileUrl) => {
19
18
  fileUrl = assertAndNormalizeFileUrl(fileUrl);
@@ -53,7 +52,7 @@ const createFileSnapshot = (fileUrl) => {
53
52
  throw e;
54
53
  }
55
54
  if (!fileSnapshot.stat.isFile()) {
56
- throw new Error(`file expected at ${fileUrl}`);
55
+ throw new Error(`file expect at ${fileUrl}`);
57
56
  }
58
57
 
59
58
  const isTextual = CONTENT_TYPE.isTextual(
@@ -113,20 +112,13 @@ ${fileUrl}`);
113
112
  if (actualFileContent === expectedFileContent) {
114
113
  return;
115
114
  }
116
- const errorInfo = getStringAssertionErrorInfo({
115
+ assert({
116
+ message: failureMessage,
117
+ details: fileUrl,
117
118
  actual: actualFileContent,
118
- expected: expectedFileContent,
119
- name: `file content`,
120
- format: assert.format,
119
+ expect: expectedFileContent,
120
+ forceMultilineDiff: true,
121
121
  });
122
- const fileContentStringAssertionError =
123
- assert.createAssertionError(`${failureMessage}
124
- --- reason ---
125
- ${errorInfo.message}
126
- --- file ---
127
- ${fileUrl}`);
128
- fileContentStringAssertionError.name = errorInfo.type;
129
- throw fileContentStringAssertionError;
130
122
  };
131
123
 
132
124
  export const takeDirectorySnapshot = (directoryUrl) => {
@@ -170,10 +162,10 @@ export const takeDirectorySnapshot = (directoryUrl) => {
170
162
  if (missingFileCount === 1) {
171
163
  const fileMissingAssertionError =
172
164
  assert.createAssertionError(`${failureMessage}
173
- --- reason ---
174
- "${missingRelativeUrls[0]}" is missing
175
- --- file missing ---
176
- ${missingUrls[0]}`);
165
+ --- reason ---
166
+ "${missingRelativeUrls[0]}" is missing
167
+ --- file missing ---
168
+ ${missingUrls[0]}`);
177
169
  fileMissingAssertionError.name = "FileMissingAssertionError";
178
170
  throw fileMissingAssertionError;
179
171
  }
@@ -280,12 +272,12 @@ const createDirectorySnapshot = (directoryUrl) => {
280
272
  if (e.code === "ENOTDIR") {
281
273
  // trailing slash is forced on directoryUrl
282
274
  // as a result Node.js throw ENOTDIR when doing "stat" operation
283
- throw new Error(`directory expected at ${directoryUrl}`);
275
+ throw new Error(`directory expect at ${directoryUrl}`);
284
276
  }
285
277
  throw e;
286
278
  }
287
279
  if (!directorySnapshot.stat.isDirectory()) {
288
- throw new Error(`directory expected at ${directoryUrl}`);
280
+ throw new Error(`directory expect at ${directoryUrl}`);
289
281
  }
290
282
 
291
283
  const entryNames = readdirSync(directoryUrl);