@rspack/test-tools 1.4.2 → 1.4.4
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/helper/setup-env.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// @ts-nocheck
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
// @ts-nocheck
|
|
4
|
+
const path = require("node:path");
|
|
5
|
+
// Setup environment variable for binding testing
|
|
6
|
+
if (process.env.RSPACK_BINDING_BUILDER_TESTING) {
|
|
7
|
+
process.env.RSPACK_BINDING = path.resolve(__dirname, "../../node_modules/@rspack/binding-testing");
|
|
8
|
+
}
|
|
4
9
|
if (process.env.ALTERNATIVE_SORT) {
|
|
5
10
|
const oldSort = Array.prototype.sort;
|
|
6
11
|
Array.prototype.sort = function (cmp) {
|
|
@@ -136,7 +136,12 @@ class HotSnapshotProcessor extends hot_1.HotProcessor {
|
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
|
-
const replaceContent = (
|
|
139
|
+
const replaceContent = (rawStr) => {
|
|
140
|
+
let str = rawStr;
|
|
141
|
+
const replaceContentConfig = context.getTestConfig().snapshotContent;
|
|
142
|
+
if (replaceContentConfig) {
|
|
143
|
+
str = replaceContentConfig(str);
|
|
144
|
+
}
|
|
140
145
|
return (0, placeholder_1.normalizePlaceholder)(Object.entries(hashes)
|
|
141
146
|
.reduce((str, [raw, replacement]) => {
|
|
142
147
|
return str.split(raw).join(replacement);
|
|
@@ -45,7 +45,11 @@ class SnapshotProcessor extends basic_1.BasicProcessor {
|
|
|
45
45
|
.filter(([file]) => snapshotFileFilter(file))
|
|
46
46
|
.map(([file, source]) => {
|
|
47
47
|
const tag = node_path_1.default.extname(file).slice(1) || "txt";
|
|
48
|
-
|
|
48
|
+
let content = this.serializeEachFile(source.source().toString());
|
|
49
|
+
const testConfig = context.getTestConfig();
|
|
50
|
+
if (testConfig.snapshotContent) {
|
|
51
|
+
content = testConfig.snapshotContent(content);
|
|
52
|
+
}
|
|
49
53
|
return `\`\`\`${tag} title=${file}\n${content}\n\`\`\``;
|
|
50
54
|
});
|
|
51
55
|
fileContents.sort();
|
package/dist/type.d.ts
CHANGED
|
@@ -148,6 +148,7 @@ export type TTestConfig<T extends ECompilerType> = {
|
|
|
148
148
|
modules?: Record<string, Object>;
|
|
149
149
|
timeout?: number;
|
|
150
150
|
concurrent?: boolean;
|
|
151
|
+
snapshotContent?(content: string): string;
|
|
151
152
|
checkSteps?: boolean;
|
|
152
153
|
};
|
|
153
154
|
export type TTestFilter<T extends ECompilerType> = (creatorConfig: Record<string, unknown>, testConfig: TTestConfig<T>) => boolean | string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rspack/test-tools",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Test tools for rspack",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -96,9 +96,10 @@
|
|
|
96
96
|
"typescript": "^5.8.3",
|
|
97
97
|
"wast-loader": "^1.14.1",
|
|
98
98
|
"worker-rspack-loader": "^3.1.2",
|
|
99
|
-
"@rspack/cli": "1.4.
|
|
100
|
-
"@rspack/
|
|
101
|
-
"@rspack/test-tools": "1.4.
|
|
99
|
+
"@rspack/cli": "1.4.4",
|
|
100
|
+
"@rspack/binding-testing": "1.4.1",
|
|
101
|
+
"@rspack/test-tools": "1.4.4",
|
|
102
|
+
"@rspack/core": "1.4.4"
|
|
102
103
|
},
|
|
103
104
|
"peerDependencies": {
|
|
104
105
|
"@rspack/core": ">=1.0.0"
|