@cronn/lib-file-snapshots 1.0.0 → 1.0.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/dist/index.d.mts +0 -8
- package/dist/index.mjs +1 -8
- package/package.json +7 -6
package/dist/index.d.mts
CHANGED
|
@@ -4,12 +4,6 @@ interface SnapshotSerializer {
|
|
|
4
4
|
* The file extension associated with the serialized value
|
|
5
5
|
*/
|
|
6
6
|
readonly fileExtension: string;
|
|
7
|
-
/**
|
|
8
|
-
* Returns true when value can be serialized
|
|
9
|
-
*
|
|
10
|
-
* @param value The value to be serialized
|
|
11
|
-
*/
|
|
12
|
-
canSerialize(value: unknown): boolean;
|
|
13
7
|
/**
|
|
14
8
|
* Serializes value
|
|
15
9
|
*
|
|
@@ -50,7 +44,6 @@ declare class JsonSerializer implements SnapshotSerializer {
|
|
|
50
44
|
private readonly normalizers;
|
|
51
45
|
private readonly indentSize;
|
|
52
46
|
constructor(options?: JsonSerializerOptions);
|
|
53
|
-
canSerialize(_value: unknown): boolean;
|
|
54
47
|
serialize(value: unknown): string;
|
|
55
48
|
private normalizeValueRecursive;
|
|
56
49
|
private normalizeNumber;
|
|
@@ -82,7 +75,6 @@ declare class TextSerializer implements SnapshotSerializer {
|
|
|
82
75
|
readonly fileExtension: string;
|
|
83
76
|
private readonly normalizers;
|
|
84
77
|
constructor(options?: TextSerializerOptions);
|
|
85
|
-
canSerialize(value: unknown): value is string;
|
|
86
78
|
serialize(value: unknown): string;
|
|
87
79
|
private normalizeValue;
|
|
88
80
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -65,9 +65,6 @@ var JsonSerializer = class {
|
|
|
65
65
|
this.normalizers = options.normalizers ?? [];
|
|
66
66
|
this.indentSize = options.indentSize ?? 2;
|
|
67
67
|
}
|
|
68
|
-
canSerialize(_value) {
|
|
69
|
-
return true;
|
|
70
|
-
}
|
|
71
68
|
serialize(value) {
|
|
72
69
|
const jsonValue = this.normalizeValueRecursive(value);
|
|
73
70
|
return addTrailingNewLine(JSON.stringify(jsonValue, void 0, this.indentSize));
|
|
@@ -155,11 +152,8 @@ var TextSerializer = class {
|
|
|
155
152
|
this.normalizers = options.normalizers ?? [];
|
|
156
153
|
this.fileExtension = options.fileExtension ?? "txt";
|
|
157
154
|
}
|
|
158
|
-
canSerialize(value) {
|
|
159
|
-
return isString(value);
|
|
160
|
-
}
|
|
161
155
|
serialize(value) {
|
|
162
|
-
if (!
|
|
156
|
+
if (!isString(value)) throw new Error(`Value of type ${typeof value} cannot be serialized as text. Only strings are supported.`);
|
|
163
157
|
return addTrailingNewLine(this.normalizeValue(value));
|
|
164
158
|
}
|
|
165
159
|
normalizeValue(value) {
|
|
@@ -189,7 +183,6 @@ var ValidationFileMatcher = class {
|
|
|
189
183
|
return this.updateSnapshots === "all" || this.isValidationFileMissing && this.updateSnapshots === "missing";
|
|
190
184
|
}
|
|
191
185
|
matchFileSnapshot(actual) {
|
|
192
|
-
if (!this.serializer.canSerialize(actual)) throw new Error(`Cannot serialize value of type ${typeof actual}`);
|
|
193
186
|
const serializedActual = this.serializer.serialize(actual);
|
|
194
187
|
const expected = this.resolveExpected(serializedActual);
|
|
195
188
|
return this.createMatcherResult({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cronn/lib-file-snapshots",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "The library agnostic core for testing file snapshots",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"file snapshots"
|
|
@@ -45,16 +45,17 @@
|
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@arethetypeswrong/core": "0.18.2",
|
|
47
47
|
"@trivago/prettier-plugin-sort-imports": "6.0.2",
|
|
48
|
-
"@
|
|
49
|
-
"@
|
|
48
|
+
"@types/node": "24.11.0",
|
|
49
|
+
"@typescript/native-preview": "7.0.0-dev.20260302.1",
|
|
50
50
|
"@vitest/coverage-v8": "4.0.18",
|
|
51
|
-
"eslint": "10.0.
|
|
51
|
+
"eslint": "10.0.2",
|
|
52
52
|
"eslint-config-prettier": "10.1.8",
|
|
53
|
+
"eslint-plugin-check-file": "3.3.1",
|
|
53
54
|
"eslint-plugin-unused-imports": "4.4.1",
|
|
54
55
|
"prettier": "3.8.1",
|
|
55
|
-
"publint": "0.3.
|
|
56
|
+
"publint": "0.3.18",
|
|
56
57
|
"tsdown": "0.20.3",
|
|
57
|
-
"typescript-eslint": "8.56.
|
|
58
|
+
"typescript-eslint": "8.56.1",
|
|
58
59
|
"vitest": "4.0.18",
|
|
59
60
|
"@cronn/shared-configs": "0.0.0"
|
|
60
61
|
},
|