@rspack-canary/test-tools 1.5.9-canary-bddc650e-20251012024608 → 1.5.9-canary-a915dabc-20251013174148
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/case/builtin.js +0 -22
- package/dist/case/common.js +5 -1
- package/dist/case/error.js +1 -1
- package/dist/case/hook.js +2 -2
- package/dist/case/normal.js +1 -1
- package/dist/compare/compare.js +6 -3
- package/dist/helper/expect/placeholder.js +7 -7
- package/dist/helper/expect/to-match-file-snapshot.d.ts +0 -1
- package/dist/helper/legacy/supportsTextDecoder.d.ts +2 -0
- package/dist/helper/legacy/supportsTextDecoder.js +10 -0
- package/dist/runner/node/index.js +4 -0
- package/dist/runner/web/fake.js +6 -3
- package/dist/runner/web/jsdom.js +0 -4
- package/dist/type.d.ts +8 -0
- package/package.json +5 -5
package/dist/case/builtin.js
CHANGED
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.createBuiltinCase = createBuiltinCase;
|
|
7
7
|
exports.defaultOptions = defaultOptions;
|
|
8
8
|
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
-
const core_1 = require("@rspack/core");
|
|
10
9
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
11
10
|
const webpack_merge_1 = require("webpack-merge");
|
|
12
11
|
const helper_1 = require("../helper");
|
|
@@ -164,27 +163,6 @@ function defaultOptions(context) {
|
|
|
164
163
|
}
|
|
165
164
|
defaultOptions = (0, webpack_merge_1.merge)(defaultOptions, caseOptions);
|
|
166
165
|
}
|
|
167
|
-
// TODO: remove builtin compatible code
|
|
168
|
-
const defineOptions = defaultOptions.builtins?.define;
|
|
169
|
-
if (defineOptions) {
|
|
170
|
-
defaultOptions.plugins.push(new core_1.rspack.DefinePlugin(defineOptions));
|
|
171
|
-
}
|
|
172
|
-
const provideOptions = defaultOptions.builtins?.provide;
|
|
173
|
-
if (provideOptions) {
|
|
174
|
-
defaultOptions.plugins.push(new core_1.rspack.ProvidePlugin(provideOptions));
|
|
175
|
-
}
|
|
176
|
-
const htmlOptions = defaultOptions.builtins?.html;
|
|
177
|
-
if (htmlOptions) {
|
|
178
|
-
if (Array.isArray(htmlOptions)) {
|
|
179
|
-
for (const item of htmlOptions) {
|
|
180
|
-
defaultOptions.plugins.push(new core_1.rspack.HtmlRspackPlugin(item));
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
else {
|
|
184
|
-
defaultOptions.plugins.push(new core_1.rspack.HtmlRspackPlugin(htmlOptions));
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
delete defaultOptions.builtins;
|
|
188
166
|
if (!global.printLogger) {
|
|
189
167
|
defaultOptions.infrastructureLogging = {
|
|
190
168
|
level: "error"
|
package/dist/case/common.js
CHANGED
|
@@ -81,7 +81,11 @@ async function run(env, context, name, findBundle) {
|
|
|
81
81
|
const results = context.getValue(name, "modules") || [];
|
|
82
82
|
await Promise.all(results);
|
|
83
83
|
if (typeof testConfig.afterExecute === "function") {
|
|
84
|
-
|
|
84
|
+
let options = compiler.getOptions();
|
|
85
|
+
if (Array.isArray(options) && options.length === 1) {
|
|
86
|
+
options = options[0];
|
|
87
|
+
}
|
|
88
|
+
testConfig.afterExecute(options);
|
|
85
89
|
}
|
|
86
90
|
}
|
|
87
91
|
async function check(env, context, name) {
|
package/dist/case/error.js
CHANGED
|
@@ -71,7 +71,7 @@ function createErrorCase(name, src, dist, testConfig) {
|
|
|
71
71
|
}
|
|
72
72
|
function options(context, custom) {
|
|
73
73
|
let options = {
|
|
74
|
-
context: node_path_1.default.resolve(
|
|
74
|
+
context: node_path_1.default.resolve(__TEST_FIXTURES_PATH__, "errors"),
|
|
75
75
|
mode: "none",
|
|
76
76
|
devtool: false,
|
|
77
77
|
optimization: {
|
package/dist/case/hook.js
CHANGED
|
@@ -14,8 +14,8 @@ const webpack_merge_1 = __importDefault(require("webpack-merge"));
|
|
|
14
14
|
const context_1 = require("../test/context");
|
|
15
15
|
const creator_1 = require("../test/creator");
|
|
16
16
|
const common_1 = require("./common");
|
|
17
|
-
const srcDir =
|
|
18
|
-
const distDir = node_path_1.default.resolve(
|
|
17
|
+
const srcDir = __TEST_FIXTURES_PATH__;
|
|
18
|
+
const distDir = node_path_1.default.resolve(__TEST_DIST_PATH__, "hook");
|
|
19
19
|
const creator = new creator_1.BasicCaseCreator({
|
|
20
20
|
clean: true,
|
|
21
21
|
describe: true,
|
package/dist/case/normal.js
CHANGED
|
@@ -13,7 +13,7 @@ const core_1 = require("@rspack/core");
|
|
|
13
13
|
const creator_1 = require("../test/creator");
|
|
14
14
|
const common_1 = require("./common");
|
|
15
15
|
const runner_1 = require("./runner");
|
|
16
|
-
const NORMAL_CASES_ROOT = node_path_1.default.resolve(
|
|
16
|
+
const NORMAL_CASES_ROOT = node_path_1.default.resolve(__TEST_PATH__, "normalCases");
|
|
17
17
|
const createCaseOptions = (hot, mode) => {
|
|
18
18
|
return {
|
|
19
19
|
clean: true,
|
package/dist/compare/compare.js
CHANGED
|
@@ -13,7 +13,6 @@ const helper_1 = require("../helper");
|
|
|
13
13
|
const type_1 = require("../type");
|
|
14
14
|
const format_code_1 = require("./format-code");
|
|
15
15
|
const replace_runtime_module_name_1 = require("./replace-runtime-module-name");
|
|
16
|
-
const WORKSPACE = node_path_1.default.resolve(__dirname, "../../../..");
|
|
17
16
|
function compareFile(sourceFile, distFile, compareOptions) {
|
|
18
17
|
const result = {
|
|
19
18
|
type: type_1.ECompareResultType.Same,
|
|
@@ -49,7 +48,9 @@ function compareFile(sourceFile, distFile, compareOptions) {
|
|
|
49
48
|
}
|
|
50
49
|
return res;
|
|
51
50
|
}
|
|
52
|
-
const sourceContent = (0, replace_runtime_module_name_1.replaceRuntimeModuleName)(fs_extra_1.default
|
|
51
|
+
const sourceContent = (0, replace_runtime_module_name_1.replaceRuntimeModuleName)(fs_extra_1.default
|
|
52
|
+
.readFileSync(sourceFile, "utf-8")
|
|
53
|
+
.replaceAll(__ROOT_PATH__, "__WORKSPACE__"));
|
|
53
54
|
const sourceModules = (0, helper_1.parseModules)(sourceContent, {
|
|
54
55
|
bootstrap: compareOptions.bootstrap,
|
|
55
56
|
renameModule: compareOptions.renameModule
|
|
@@ -66,7 +67,9 @@ function compareFile(sourceFile, distFile, compareOptions) {
|
|
|
66
67
|
distModules = JSON.parse(fs_extra_1.default.readFileSync(compareOptions.snapshot, "utf-8"));
|
|
67
68
|
}
|
|
68
69
|
else {
|
|
69
|
-
const distContent = (0, replace_runtime_module_name_1.replaceRuntimeModuleName)(fs_extra_1.default
|
|
70
|
+
const distContent = (0, replace_runtime_module_name_1.replaceRuntimeModuleName)(fs_extra_1.default
|
|
71
|
+
.readFileSync(distFile, "utf-8")
|
|
72
|
+
.replaceAll(__ROOT_PATH__, "__WORKSPACE__"));
|
|
70
73
|
distModules = (0, helper_1.parseModules)(distContent, {
|
|
71
74
|
bootstrap: compareOptions.bootstrap,
|
|
72
75
|
renameModule: compareOptions.renameModule
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.normalizePlaceholder = void 0;
|
|
7
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
8
4
|
const path_serializer_1 = require("path-serializer");
|
|
9
5
|
// 1. escapeEOL \r\n -> \n
|
|
10
6
|
// 2. replace <RSPACK_ROOT> etc
|
|
@@ -13,14 +9,18 @@ const placeholderSerializer = (0, path_serializer_1.createSnapshotSerializer)({
|
|
|
13
9
|
root: __dirname.includes("node_modules")
|
|
14
10
|
? // Use `process.cwd()` when using outside Rspack
|
|
15
11
|
process.cwd()
|
|
16
|
-
:
|
|
12
|
+
: __ROOT_PATH__,
|
|
17
13
|
replace: [
|
|
18
14
|
{
|
|
19
|
-
match:
|
|
15
|
+
match: __RSPACK_TEST_TOOLS_PATH__,
|
|
20
16
|
mark: "test_tools_root"
|
|
21
17
|
},
|
|
22
18
|
{
|
|
23
|
-
match:
|
|
19
|
+
match: __TEST_PATH__,
|
|
20
|
+
mark: "test_root"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
match: __RSPACK_PATH__,
|
|
24
24
|
mark: "rspack_root"
|
|
25
25
|
},
|
|
26
26
|
{
|
|
@@ -42,6 +42,7 @@ const node_path_1 = __importDefault(require("node:path"));
|
|
|
42
42
|
const node_url_1 = require("node:url");
|
|
43
43
|
const node_vm_1 = __importStar(require("node:vm"));
|
|
44
44
|
const asModule_1 = __importDefault(require("../../helper/legacy/asModule"));
|
|
45
|
+
const createFakeWorker_1 = __importDefault(require("../../helper/legacy/createFakeWorker"));
|
|
45
46
|
const urlToRelativePath_1 = __importDefault(require("../../helper/legacy/urlToRelativePath"));
|
|
46
47
|
const type_1 = require("../../type");
|
|
47
48
|
const isRelativePath = (p) => /^\.\.?\//.test(p);
|
|
@@ -165,6 +166,9 @@ class NodeRunner {
|
|
|
165
166
|
setImmediate,
|
|
166
167
|
__MODE__: this._options.compilerOptions.mode,
|
|
167
168
|
__SNAPSHOT__: node_path_1.default.join(this._options.source, "__snapshot__"),
|
|
169
|
+
Worker: (0, createFakeWorker_1.default)(this._options.env, {
|
|
170
|
+
outputDirectory: this._options.dist
|
|
171
|
+
}),
|
|
168
172
|
...this._options.env
|
|
169
173
|
};
|
|
170
174
|
return baseModuleScope;
|
package/dist/runner/web/fake.js
CHANGED
|
@@ -102,9 +102,6 @@ class FakeDocumentWebRunner extends node_1.NodeRunner {
|
|
|
102
102
|
this.requirers.get("entry")(this._options.dist, (0, urlToRelativePath_1.default)(url));
|
|
103
103
|
};
|
|
104
104
|
globalContext.document = this.document;
|
|
105
|
-
globalContext.Worker = (0, createFakeWorker_1.default)(this._options.env, {
|
|
106
|
-
outputDirectory: this._options.dist
|
|
107
|
-
});
|
|
108
105
|
globalContext.EventSource = EventSourceForNode_1.default;
|
|
109
106
|
globalContext.location = {
|
|
110
107
|
href: "https://test.cases/path/index.html",
|
|
@@ -169,6 +166,12 @@ class FakeDocumentWebRunner extends node_1.NodeRunner {
|
|
|
169
166
|
if (!file) {
|
|
170
167
|
return this.requirers.get("miss")(currentDirectory, modulePath);
|
|
171
168
|
}
|
|
169
|
+
if (file.content.includes("__STATS_I__")) {
|
|
170
|
+
const statsIndex = this._options.stats?.()?.__index__;
|
|
171
|
+
if (typeof statsIndex === "number") {
|
|
172
|
+
esmContext.__STATS_I__ = statsIndex;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
172
175
|
let esm = esmCache.get(file.path);
|
|
173
176
|
if (!esm) {
|
|
174
177
|
esm = new node_vm_1.SourceTextModule(file.content, {
|
package/dist/runner/web/jsdom.js
CHANGED
|
@@ -8,7 +8,6 @@ const node_fs_1 = __importDefault(require("node:fs"));
|
|
|
8
8
|
const node_path_1 = __importDefault(require("node:path"));
|
|
9
9
|
const jsdom_1 = require("jsdom");
|
|
10
10
|
const helper_1 = require("../../helper");
|
|
11
|
-
const createFakeWorker_1 = __importDefault(require("../../helper/legacy/createFakeWorker"));
|
|
12
11
|
const EventSourceForNode_1 = __importDefault(require("../../helper/legacy/EventSourceForNode"));
|
|
13
12
|
const urlToRelativePath_1 = __importDefault(require("../../helper/legacy/urlToRelativePath"));
|
|
14
13
|
const node_1 = require("../node");
|
|
@@ -110,9 +109,6 @@ class JSDOMWebRunner extends node_1.NodeRunner {
|
|
|
110
109
|
createBaseModuleScope() {
|
|
111
110
|
const moduleScope = super.createBaseModuleScope();
|
|
112
111
|
moduleScope.EventSource = EventSourceForNode_1.default;
|
|
113
|
-
moduleScope.Worker = (0, createFakeWorker_1.default)(this._options.env, {
|
|
114
|
-
outputDirectory: this._options.dist
|
|
115
|
-
});
|
|
116
112
|
const urlToPath = (url) => {
|
|
117
113
|
return node_path_1.default.resolve(this._webOptions.dist, `./${url.startsWith("https://test.cases/path/") ? url.slice(24) : url}`);
|
|
118
114
|
};
|
package/dist/type.d.ts
CHANGED
|
@@ -201,3 +201,11 @@ export type TTestRunnerCreator = {
|
|
|
201
201
|
key: (context: ITestContext, name: string, file: string) => string;
|
|
202
202
|
runner: (context: ITestContext, name: string, file: string, env: ITestEnv) => ITestRunner;
|
|
203
203
|
};
|
|
204
|
+
declare global {
|
|
205
|
+
var __TEST_PATH__: string;
|
|
206
|
+
var __TEST_FIXTURES_PATH__: string;
|
|
207
|
+
var __TEST_DIST_PATH__: string;
|
|
208
|
+
var __ROOT_PATH__: string;
|
|
209
|
+
var __RSPACK_PATH__: string;
|
|
210
|
+
var __RSPACK_TEST_TOOLS_PATH__: string;
|
|
211
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rspack-canary/test-tools",
|
|
3
|
-
"version": "1.5.9-canary-
|
|
3
|
+
"version": "1.5.9-canary-a915dabc-20251013174148",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Test tools for rspack",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -100,10 +100,10 @@
|
|
|
100
100
|
"wast-loader": "^1.14.1",
|
|
101
101
|
"worker-rspack-loader": "^3.1.2",
|
|
102
102
|
"exports-loader": "^5.0.0",
|
|
103
|
-
"@rspack/cli": "npm:@rspack-canary/cli@1.5.9-canary-
|
|
104
|
-
"@rspack/
|
|
105
|
-
"@rspack/
|
|
106
|
-
"@rspack/
|
|
103
|
+
"@rspack/cli": "npm:@rspack-canary/cli@1.5.9-canary-a915dabc-20251013174148",
|
|
104
|
+
"@rspack/core": "npm:@rspack-canary/core@1.5.9-canary-a915dabc-20251013174148",
|
|
105
|
+
"@rspack/test-tools": "npm:@rspack-canary/test-tools@1.5.9-canary-a915dabc-20251013174148",
|
|
106
|
+
"@rspack/binding-testing": "1.4.1"
|
|
107
107
|
},
|
|
108
108
|
"peerDependencies": {
|
|
109
109
|
"@rspack/core": ">=1.0.0"
|