@cronn/lib-file-snapshots 0.14.0 → 0.16.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/dist/index.d.ts +9 -7
- package/dist/index.js +6 -6
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -67,10 +67,16 @@ interface TextSerializerOptions {
|
|
|
67
67
|
* Custom normalizers to apply before serialization
|
|
68
68
|
*/
|
|
69
69
|
normalizers?: Array<TextNormalizer>;
|
|
70
|
+
/**
|
|
71
|
+
* File extension used for storing the text file
|
|
72
|
+
*
|
|
73
|
+
* @default "txt"
|
|
74
|
+
*/
|
|
75
|
+
fileExtension?: string;
|
|
70
76
|
}
|
|
71
77
|
type TextNormalizer = (value: string) => string;
|
|
72
78
|
declare class TextSerializer implements SnapshotSerializer {
|
|
73
|
-
readonly fileExtension
|
|
79
|
+
readonly fileExtension: string;
|
|
74
80
|
private readonly normalizers;
|
|
75
81
|
constructor(options?: TextSerializerOptions);
|
|
76
82
|
canSerialize(value: unknown): value is string;
|
|
@@ -81,16 +87,12 @@ declare class TextSerializer implements SnapshotSerializer {
|
|
|
81
87
|
interface ValidationFileMatcherConfig {
|
|
82
88
|
/**
|
|
83
89
|
* Directory in which golden masters are stored
|
|
84
|
-
*
|
|
85
|
-
* @default "data/test/validation"
|
|
86
90
|
*/
|
|
87
|
-
validationDir
|
|
91
|
+
validationDir: string;
|
|
88
92
|
/**
|
|
89
93
|
* Directory in which file snapshots from test runs are stored
|
|
90
|
-
*
|
|
91
|
-
* @default "data/test/output"
|
|
92
94
|
*/
|
|
93
|
-
outputDir
|
|
95
|
+
outputDir: string;
|
|
94
96
|
/**
|
|
95
97
|
* The full path to the snapshot file
|
|
96
98
|
*
|
package/dist/index.js
CHANGED
|
@@ -214,10 +214,11 @@ var JsonSerializer = class {
|
|
|
214
214
|
|
|
215
215
|
// src/serializers/text-serializer.ts
|
|
216
216
|
var TextSerializer = class {
|
|
217
|
-
fileExtension
|
|
217
|
+
fileExtension;
|
|
218
218
|
normalizers;
|
|
219
219
|
constructor(options = {}) {
|
|
220
220
|
this.normalizers = options.normalizers ?? [];
|
|
221
|
+
this.fileExtension = options.fileExtension ?? "txt";
|
|
221
222
|
}
|
|
222
223
|
canSerialize(value) {
|
|
223
224
|
return isString(value);
|
|
@@ -272,12 +273,11 @@ var ValidationFileMatcher = class {
|
|
|
272
273
|
});
|
|
273
274
|
}
|
|
274
275
|
buildFilePaths(config) {
|
|
275
|
-
const validationDir = config
|
|
276
|
-
const
|
|
277
|
-
const filePathWithExtenion = `${config.filePath}.${config.serializer.fileExtension}`;
|
|
276
|
+
const { validationDir, outputDir, filePath, serializer } = config;
|
|
277
|
+
const filePathWithExtension = `${filePath}.${serializer.fileExtension}`;
|
|
278
278
|
return {
|
|
279
|
-
outputFilePath: path2.join(outputDir,
|
|
280
|
-
validationFilePath: path2.join(validationDir,
|
|
279
|
+
outputFilePath: path2.join(outputDir, filePathWithExtension),
|
|
280
|
+
validationFilePath: path2.join(validationDir, filePathWithExtension)
|
|
281
281
|
};
|
|
282
282
|
}
|
|
283
283
|
readValidationFile() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cronn/lib-file-snapshots",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"description": "The library agnostic core for testing file snapshots",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"file snapshots"
|
|
@@ -33,15 +33,15 @@
|
|
|
33
33
|
],
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@trivago/prettier-plugin-sort-imports": "5.2.2",
|
|
36
|
-
"@types/node": "22.18.
|
|
36
|
+
"@types/node": "22.18.6",
|
|
37
37
|
"@vitest/coverage-istanbul": "3.2.4",
|
|
38
|
-
"eslint": "9.
|
|
38
|
+
"eslint": "9.36.0",
|
|
39
39
|
"eslint-config-prettier": "10.1.8",
|
|
40
40
|
"eslint-plugin-unused-imports": "4.2.0",
|
|
41
41
|
"prettier": "3.6.2",
|
|
42
42
|
"tsup": "8.5.0",
|
|
43
43
|
"typescript": "5.9.2",
|
|
44
|
-
"typescript-eslint": "8.
|
|
44
|
+
"typescript-eslint": "8.44.0",
|
|
45
45
|
"vitest": "3.2.4",
|
|
46
46
|
"@cronn/shared-configs": "0.0.0"
|
|
47
47
|
},
|