@rspack-canary/test-tools 1.5.6-canary-e598f284-20250921173624 → 1.5.7-canary-a3406c0a-20250922173625

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.
Files changed (70) hide show
  1. package/dist/case/builtin.d.ts +2 -0
  2. package/dist/case/builtin.js +153 -2
  3. package/dist/case/cache.js +115 -9
  4. package/dist/case/compiler.js +1 -1
  5. package/dist/case/config.d.ts +4 -1
  6. package/dist/case/config.js +80 -2
  7. package/dist/case/defaults.d.ts +11 -3
  8. package/dist/case/defaults.js +47 -2
  9. package/dist/case/diagnostic.d.ts +6 -0
  10. package/dist/case/diagnostic.js +109 -9
  11. package/dist/case/error.d.ts +2 -2
  12. package/dist/case/error.js +79 -2
  13. package/dist/case/hash.js +61 -7
  14. package/dist/case/hook.d.ts +35 -3
  15. package/dist/case/hook.js +185 -4
  16. package/dist/case/hot-step.d.ts +1 -1
  17. package/dist/case/hot-step.js +302 -8
  18. package/dist/case/hot.d.ts +8 -1
  19. package/dist/case/hot.js +147 -7
  20. package/dist/case/incremental.js +21 -8
  21. package/dist/case/index.d.ts +20 -20
  22. package/dist/case/index.js +44 -34
  23. package/dist/case/normal.js +152 -5
  24. package/dist/case/serial.js +7 -3
  25. package/dist/case/stats-api.d.ts +0 -5
  26. package/dist/case/stats-api.js +33 -2
  27. package/dist/case/stats-output.js +200 -10
  28. package/dist/case/treeshaking.js +19 -3
  29. package/dist/helper/plugins/hot-update.d.ts +2 -2
  30. package/dist/processor/basic.d.ts +4 -1
  31. package/dist/processor/basic.js +20 -10
  32. package/dist/processor/index.d.ts +0 -14
  33. package/dist/processor/index.js +0 -14
  34. package/dist/processor/multi.d.ts +3 -1
  35. package/dist/processor/multi.js +2 -0
  36. package/dist/processor/simple.d.ts +1 -1
  37. package/dist/processor/simple.js +4 -4
  38. package/dist/processor/snapshot.js +4 -3
  39. package/dist/type.d.ts +1 -1
  40. package/package.json +4 -4
  41. package/dist/processor/builtin.d.ts +0 -9
  42. package/dist/processor/builtin.js +0 -171
  43. package/dist/processor/cache.d.ts +0 -20
  44. package/dist/processor/cache.js +0 -131
  45. package/dist/processor/config.d.ts +0 -11
  46. package/dist/processor/config.js +0 -88
  47. package/dist/processor/defaults.d.ts +0 -30
  48. package/dist/processor/defaults.js +0 -72
  49. package/dist/processor/diagnostic.d.ts +0 -15
  50. package/dist/processor/diagnostic.js +0 -104
  51. package/dist/processor/error.d.ts +0 -23
  52. package/dist/processor/error.js +0 -95
  53. package/dist/processor/hash.d.ts +0 -10
  54. package/dist/processor/hash.js +0 -65
  55. package/dist/processor/hook.d.ts +0 -44
  56. package/dist/processor/hook.js +0 -206
  57. package/dist/processor/hot-incremental.d.ts +0 -14
  58. package/dist/processor/hot-incremental.js +0 -43
  59. package/dist/processor/hot-step.d.ts +0 -18
  60. package/dist/processor/hot-step.js +0 -307
  61. package/dist/processor/hot.d.ts +0 -17
  62. package/dist/processor/hot.js +0 -147
  63. package/dist/processor/normal.d.ts +0 -12
  64. package/dist/processor/normal.js +0 -170
  65. package/dist/processor/stats-api.d.ts +0 -18
  66. package/dist/processor/stats-api.js +0 -48
  67. package/dist/processor/stats.d.ts +0 -18
  68. package/dist/processor/stats.js +0 -206
  69. package/dist/processor/treeshaking.d.ts +0 -10
  70. package/dist/processor/treeshaking.js +0 -33
@@ -1,206 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.HookTaskProcessor = exports.HookCasesContext = void 0;
7
- const node_path_1 = __importDefault(require("node:path"));
8
- const core_1 = require("@rspack/core");
9
- const jest_snapshot_1 = require("jest-snapshot");
10
- const path_serializer_1 = require("path-serializer");
11
- const pretty_format_1 = require("pretty-format");
12
- const context_1 = require("../test/context");
13
- const snapshot_1 = require("./snapshot");
14
- const srcDir = node_path_1.default.resolve(__dirname, "../../../../tests/rspack-test/fixtures");
15
- const distDir = node_path_1.default.resolve(__dirname, "../../../../tests/rspack-test/js/hook");
16
- const sourceSerializer = {
17
- test(val) {
18
- return val instanceof core_1.sources.Source;
19
- },
20
- print(val) {
21
- return val.source();
22
- }
23
- };
24
- const internalSerializer = {
25
- test(val) {
26
- return val instanceof core_1.Compiler || val instanceof core_1.Compilation;
27
- },
28
- print(val) {
29
- return JSON.stringify(`${val.constructor.name}(internal ignored)`);
30
- }
31
- };
32
- const testPathSerializer = (0, path_serializer_1.createSnapshotSerializer)({
33
- replace: [
34
- {
35
- match: srcDir,
36
- mark: "<HOOK_SRC_DIR>"
37
- },
38
- {
39
- match: distDir,
40
- mark: "<HOOK_DIST_DIR>"
41
- }
42
- ]
43
- });
44
- const escapeRegex = true;
45
- const printFunctionName = false;
46
- const normalizeNewlines = (str) => str.replace(/\r\n|\r/g, "\n");
47
- const serialize = (val, indent = 2, formatOverrides = {}) => normalizeNewlines((0, pretty_format_1.format)(val, {
48
- escapeRegex,
49
- indent,
50
- plugins: [
51
- ...(0, jest_snapshot_1.getSerializers)(),
52
- sourceSerializer,
53
- internalSerializer,
54
- testPathSerializer
55
- ],
56
- printFunctionName,
57
- ...formatOverrides
58
- }));
59
- class HookCasesContext extends context_1.TestContext {
60
- constructor(src, testName, options) {
61
- super(options);
62
- this.src = src;
63
- this.testName = testName;
64
- this.options = options;
65
- this.promises = [];
66
- this.count = 0;
67
- this.snapshots = {};
68
- this.snapshotsList = [];
69
- this.snapped = this.snapped.bind(this);
70
- }
71
- /**
72
- * Snapshot function arguments and return value.
73
- * Generated snapshot is located in the same directory with the test source.
74
- * @example
75
- * compiler.hooks.compilation("name", context.snapped((...args) => { ... }))
76
- */
77
- snapped(cb, prefix = "") {
78
- // eslint-disable-next-line
79
- const context = this;
80
- return function SNAPPED_HOOK(...args) {
81
- const group = prefix ? prefix : context.count++;
82
- context._addSnapshot(args, "input", group);
83
- const output = cb.apply(this, args);
84
- if (output && typeof output.then === "function") {
85
- let resolve;
86
- context.promises.push(new Promise(r => (resolve = r)));
87
- return output
88
- .then((o) => {
89
- context._addSnapshot(o, "output (Promise resolved)", group);
90
- return o;
91
- })
92
- .catch((o) => {
93
- context._addSnapshot(o, "output (Promise rejected)", group);
94
- return o;
95
- })
96
- .finally(resolve);
97
- }
98
- context._addSnapshot(output, "output", group);
99
- return output;
100
- };
101
- }
102
- /**
103
- * @internal
104
- */
105
- _addSnapshot(content, name, group) {
106
- const normalizedContent = Buffer.isBuffer(content)
107
- ? content
108
- : serialize(content, undefined, {
109
- escapeString: true,
110
- printBasicPrototype: true
111
- }).replace(/\r\n/g, "\n");
112
- (this.snapshots[group] = this.snapshots[group] || []).push([
113
- normalizedContent,
114
- name
115
- ]);
116
- if (!this.snapshotsList.includes(group)) {
117
- this.snapshotsList.push(group);
118
- }
119
- }
120
- /**
121
- * @internal
122
- */
123
- async collectSnapshots(env, options = {
124
- diff: {}
125
- }) {
126
- await Promise.allSettled(this.promises);
127
- if (!this.snapshotsList.length)
128
- return;
129
- const snapshots = this.snapshotsList.reduce((acc, group, index) => {
130
- const block = this.snapshots[group || index].reduce((acc, [content, name]) => {
131
- name = `## ${name || `test: ${index}`}\n\n`;
132
- const block = `\`\`\`javascript\n${content}\n\`\`\`\n`;
133
- return `${acc}${name + block}\n`;
134
- }, "");
135
- return `${acc}# ${Number.isInteger(group) ? `Group: ${index}` : group}\n\n${block}`;
136
- }, "");
137
- env
138
- .expect(snapshots)
139
- .toMatchFileSnapshot(node_path_1.default.join(this.src, "hooks.snap.txt"), options);
140
- }
141
- }
142
- exports.HookCasesContext = HookCasesContext;
143
- class HookTaskProcessor extends snapshot_1.SnapshotProcessor {
144
- constructor(_hookOptions) {
145
- super({
146
- defaultOptions: (HookTaskProcessor.defaultOptions),
147
- ..._hookOptions
148
- });
149
- this._hookOptions = _hookOptions;
150
- }
151
- async config(context) {
152
- await super.config(context);
153
- const compiler = this.getCompiler(context);
154
- if (typeof this._hookOptions.options === "function") {
155
- compiler.mergeOptions(this._hookOptions.options(context));
156
- }
157
- }
158
- async compiler(context) {
159
- await super.compiler(context);
160
- if (typeof this._hookOptions.compiler === "function") {
161
- const compiler = this.getCompiler(context);
162
- await this._hookOptions.compiler(context, compiler.getCompiler());
163
- }
164
- }
165
- async check(env, context) {
166
- await context.collectSnapshots(env);
167
- await super.check(env, context);
168
- if (typeof this._hookOptions.check === "function") {
169
- await this._hookOptions.check(context);
170
- }
171
- }
172
- static defaultOptions(context) {
173
- return {
174
- context: context.getSource(),
175
- mode: "production",
176
- target: "async-node",
177
- devtool: false,
178
- cache: false,
179
- entry: "./hook",
180
- output: {
181
- path: context.getDist()
182
- },
183
- optimization: {
184
- minimize: false
185
- },
186
- experiments: {
187
- css: true,
188
- rspackFuture: {
189
- bundlerInfo: {
190
- force: false
191
- }
192
- },
193
- inlineConst: true,
194
- lazyBarrel: true
195
- }
196
- };
197
- }
198
- static overrideOptions(options) {
199
- if (!global.printLogger) {
200
- options.infrastructureLogging = {
201
- level: "error"
202
- };
203
- }
204
- }
205
- }
206
- exports.HookTaskProcessor = HookTaskProcessor;
@@ -1,14 +0,0 @@
1
- import { ECompilerType, type ITestContext, type ITestEnv, type TCompilerOptions } from "../type";
2
- import type { IBasicProcessorOptions } from "./basic";
3
- import { HotProcessor } from "./hot";
4
- export interface IHotIncrementalProcessorOptions<T extends ECompilerType> extends Omit<IBasicProcessorOptions<T>, "runable"> {
5
- target: TCompilerOptions<T>["target"];
6
- webpackCases: boolean;
7
- }
8
- export declare class HotIncrementalProcessor<T extends ECompilerType> extends HotProcessor<T> {
9
- protected _hotOptions: IHotIncrementalProcessorOptions<T>;
10
- constructor(_hotOptions: IHotIncrementalProcessorOptions<T>);
11
- run(env: ITestEnv, context: ITestContext): Promise<void>;
12
- afterAll(context: ITestContext): Promise<void>;
13
- static defaultOptions<T extends ECompilerType>(this: HotIncrementalProcessor<T>, context: ITestContext): TCompilerOptions<T>;
14
- }
@@ -1,43 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.HotIncrementalProcessor = void 0;
4
- const type_1 = require("../type");
5
- const hot_1 = require("./hot");
6
- class HotIncrementalProcessor extends hot_1.HotProcessor {
7
- constructor(_hotOptions) {
8
- super({
9
- defaultOptions: HotIncrementalProcessor.defaultOptions,
10
- ..._hotOptions
11
- });
12
- this._hotOptions = _hotOptions;
13
- }
14
- async run(env, context) {
15
- context.setValue(this._options.name, "documentType", this._hotOptions.webpackCases ? type_1.EDocumentType.Fake : type_1.EDocumentType.JSDOM);
16
- await super.run(env, context);
17
- }
18
- async afterAll(context) {
19
- try {
20
- await super.afterAll(context);
21
- }
22
- catch (e) {
23
- const isFake = context.getValue(this._options.name, "documentType") ===
24
- type_1.EDocumentType.Fake;
25
- if (isFake && /Should run all hot steps/.test(e.message))
26
- return;
27
- throw e;
28
- }
29
- }
30
- static defaultOptions(context) {
31
- const options = super.defaultOptions(context);
32
- if (this._hotOptions.compilerType === type_1.ECompilerType.Rspack) {
33
- const rspackOptions = options;
34
- rspackOptions.experiments ??= {};
35
- rspackOptions.experiments.incremental ??= "advance-silent";
36
- }
37
- else {
38
- throw new Error("HotIncrementalProcessor should only used for Rspack.");
39
- }
40
- return options;
41
- }
42
- }
43
- exports.HotIncrementalProcessor = HotIncrementalProcessor;
@@ -1,18 +0,0 @@
1
- import type { THotStepRuntimeData } from "../runner";
2
- import type { ECompilerType, ITestContext, ITestEnv, TCompilerOptions, TCompilerStatsCompilation } from "../type";
3
- import { HotProcessor, type IHotProcessorOptions } from "./hot";
4
- type TModuleGetHandler = (file: string, options: TCompilerOptions<ECompilerType>) => string[];
5
- export interface IHotSnapshotProcessorOptions<T extends ECompilerType> extends IHotProcessorOptions<T> {
6
- getModuleHandler?: TModuleGetHandler;
7
- snapshot?: string;
8
- }
9
- export declare class HotSnapshotProcessor<T extends ECompilerType> extends HotProcessor<T> {
10
- protected _hotOptions: IHotSnapshotProcessorOptions<T>;
11
- private hashes;
12
- private entries;
13
- constructor(_hotOptions: IHotSnapshotProcessorOptions<T>);
14
- run(env: ITestEnv, context: ITestContext): Promise<void>;
15
- check(env: ITestEnv, context: ITestContext): Promise<void>;
16
- protected matchStepSnapshot(env: ITestEnv, context: ITestContext, step: number, stats: TCompilerStatsCompilation<T>, runtime?: THotStepRuntimeData): void;
17
- }
18
- export {};
@@ -1,307 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.HotSnapshotProcessor = void 0;
7
- const node_path_1 = __importDefault(require("node:path"));
8
- const fs_extra_1 = __importDefault(require("fs-extra"));
9
- const placeholder_1 = require("../helper/expect/placeholder");
10
- const win_1 = require("../helper/win");
11
- const hot_1 = require("./hot");
12
- const NOOP_SET = new Set();
13
- const escapeLocalName = (str) => str.split(/[-<>:"/|?*.]/).join("_");
14
- const SELF_HANDLER = (file, options) => {
15
- let res = [];
16
- const hotUpdateGlobal = (_, modules) => {
17
- res = Object.keys(modules);
18
- };
19
- const hotUpdateGlobalKey = escapeLocalName(`${options.output?.hotUpdateGlobal || "webpackHotUpdate"}${options.output?.uniqueName || ""}`);
20
- global.self ??= {};
21
- global.self[hotUpdateGlobalKey] = hotUpdateGlobal;
22
- require(file);
23
- delete global.self[hotUpdateGlobalKey];
24
- if (!Object.keys(global.self).length) {
25
- delete global.self;
26
- }
27
- return res;
28
- };
29
- const NODE_HANDLER = (file) => {
30
- return Object.keys(require(file).modules) || [];
31
- };
32
- const GET_MODULE_HANDLER = {
33
- web: SELF_HANDLER,
34
- webworker: SELF_HANDLER,
35
- "async-node": NODE_HANDLER,
36
- node: NODE_HANDLER
37
- };
38
- class HotSnapshotProcessor extends hot_1.HotProcessor {
39
- constructor(_hotOptions) {
40
- super(_hotOptions);
41
- this._hotOptions = _hotOptions;
42
- this.hashes = [];
43
- this.entries = {};
44
- }
45
- async run(env, context) {
46
- context.setValue(this._options.name, "hotUpdateStepChecker", (hotUpdateContext, stats, runtime) => {
47
- const statsJson = stats.toJson({
48
- assets: true,
49
- chunks: true
50
- });
51
- const chunks = Array.from(
52
- // Some chunk fields are missing from rspack
53
- stats?.compilation.chunks || NOOP_SET);
54
- for (const entry of chunks.filter(i => i.hasRuntime())) {
55
- if (!this.entries[entry.id] && entry.runtime) {
56
- this.entries[entry.id] =
57
- // Webpack uses `string | SortableSet<string>` for `entry.runtime`
58
- typeof entry.runtime === "string"
59
- ? [entry.runtime]
60
- : Array.from(entry.runtime);
61
- }
62
- }
63
- this.matchStepSnapshot(env, context, hotUpdateContext.updateIndex, statsJson, runtime);
64
- this.hashes.push(stats.hash);
65
- });
66
- context.setValue(this._options.name, "hotUpdateStepErrorChecker", (_, stats, runtime) => {
67
- this.hashes.push(stats.hash);
68
- });
69
- await super.run(env, context);
70
- }
71
- async check(env, context) {
72
- const compiler = this.getCompiler(context);
73
- const stats = compiler.getStats();
74
- if (!stats || !stats.hash) {
75
- env.expect(false);
76
- return;
77
- }
78
- const statsJson = stats.toJson({ assets: true, chunks: true });
79
- const chunks = Array.from(
80
- // Some chunk fields are missing from rspack
81
- stats?.compilation.chunks || NOOP_SET);
82
- for (const entry of chunks.filter(i => i.hasRuntime())) {
83
- if (entry.runtime) {
84
- this.entries[entry.id] =
85
- // Webpack uses `string | SortableSet<string>` for `entry.runtime`
86
- typeof entry.runtime === "string"
87
- ? [entry.runtime]
88
- : Array.from(entry.runtime);
89
- }
90
- }
91
- let matchFailed = null;
92
- try {
93
- this.matchStepSnapshot(env, context, 0, statsJson);
94
- }
95
- catch (e) {
96
- matchFailed = e;
97
- }
98
- this.hashes.push(stats.hash);
99
- if (matchFailed) {
100
- throw matchFailed;
101
- }
102
- }
103
- matchStepSnapshot(env, context, step, stats, runtime) {
104
- const compiler = this.getCompiler(context);
105
- const compilerOptions = compiler.getOptions();
106
- const getModuleHandler = this._hotOptions.getModuleHandler ||
107
- GET_MODULE_HANDLER[compilerOptions.target];
108
- env.expect(typeof getModuleHandler).toBe("function");
109
- const lastHash = this.hashes[this.hashes.length - 1];
110
- const snapshotPath = context.getSource(`${this._hotOptions.snapshot || `__snapshots__/${compilerOptions.target}`}/${step}.snap.txt`);
111
- const title = `Case ${node_path_1.default.basename(this._options.name)}: Step ${step}`;
112
- const hotUpdateFile = [];
113
- const hotUpdateManifest = [];
114
- const changedFiles = this.updateOptions.updateIndex === 0
115
- ? []
116
- : this.updateOptions.changedFiles.map((i) => (0, win_1.escapeSep)(node_path_1.default.relative(context.getSource(), i)));
117
- changedFiles.sort();
118
- const hashes = {
119
- [lastHash || "LAST_HASH"]: "LAST_HASH",
120
- [stats.hash]: "CURRENT_HASH"
121
- };
122
- // TODO: find a better way
123
- // replace [runtime] to [runtime of id] to prevent worker hash
124
- const runtimes = {};
125
- for (const [id, runtime] of Object.entries(this.entries)) {
126
- if (typeof runtime === "string") {
127
- if (runtime !== id) {
128
- runtimes[runtime] = `[runtime of ${id}]`;
129
- }
130
- }
131
- else if (Array.isArray(runtime)) {
132
- for (const r of runtime) {
133
- if (r !== id) {
134
- runtimes[r] = `[runtime of ${id}]`;
135
- }
136
- }
137
- }
138
- }
139
- const replaceContent = (rawStr) => {
140
- let str = rawStr;
141
- const replaceContentConfig = context.getTestConfig().snapshotContent;
142
- if (replaceContentConfig) {
143
- str = replaceContentConfig(str);
144
- }
145
- return (0, placeholder_1.normalizePlaceholder)(Object.entries(hashes)
146
- .reduce((str, [raw, replacement]) => {
147
- return str.split(raw).join(replacement);
148
- }, str)
149
- .replace(/\/\/ (\d+)\s+(?=var cssReload)/, "")
150
- .replaceAll(/var data = "(?:.*)"/g, match => {
151
- return decodeURIComponent(match).replaceAll(/\\/g, "/");
152
- }));
153
- };
154
- const replaceFileName = (str) => {
155
- return Object.entries({
156
- ...hashes,
157
- ...runtimes
158
- }).reduce((str, [raw, replacement]) => {
159
- return str.split(raw).join(replacement);
160
- }, str);
161
- };
162
- const fileList = stats
163
- .assets.map(i => {
164
- const fileName = i.name;
165
- const renderName = replaceFileName(fileName);
166
- const content = replaceContent(fs_extra_1.default.readFileSync(context.getDist(fileName), "utf-8"));
167
- if (fileName.endsWith("hot-update.js")) {
168
- const modules = getModuleHandler(context.getDist(fileName), compilerOptions);
169
- const runtime = [];
170
- for (const i of content.matchAll(/\/\/ (webpack\/runtime\/[\w_-]+)\s*\n/g)) {
171
- runtime.push(i[1]);
172
- }
173
- modules.sort();
174
- runtime.sort();
175
- hotUpdateFile.push({
176
- name: renderName,
177
- content,
178
- modules,
179
- runtime
180
- });
181
- return `- Update: ${renderName}, size: ${content.length}`;
182
- }
183
- if (fileName.endsWith("hot-update.json")) {
184
- const manifest = JSON.parse(content);
185
- manifest.c?.sort();
186
- manifest.r?.sort();
187
- manifest.m?.sort();
188
- hotUpdateManifest.push({
189
- name: renderName,
190
- content: JSON.stringify(manifest)
191
- });
192
- return `- Manifest: ${renderName}, size: ${i.size}`;
193
- }
194
- if (fileName.endsWith(".js")) {
195
- return `- Bundle: ${renderName}`;
196
- }
197
- })
198
- .filter(Boolean);
199
- fileList.sort();
200
- hotUpdateManifest.sort((a, b) => (a.name > b.name ? 1 : -1));
201
- hotUpdateFile.sort((a, b) => (a.name > b.name ? 1 : -1));
202
- if (runtime?.javascript) {
203
- runtime.javascript.outdatedModules.sort();
204
- runtime.javascript.updatedModules.sort();
205
- runtime.javascript.updatedRuntime.sort();
206
- runtime.javascript.acceptedModules.sort();
207
- runtime.javascript.disposedModules.sort();
208
- for (const value of Object.values(runtime.javascript.outdatedDependencies)) {
209
- value.sort();
210
- }
211
- }
212
- const content = `
213
- # ${title}
214
-
215
- ## Changed Files
216
- ${changedFiles.map(i => `- ${i}`).join("\n")}
217
-
218
- ## Asset Files
219
- ${fileList.join("\n")}
220
-
221
- ## Manifest
222
- ${hotUpdateManifest
223
- .map(i => `
224
- ### ${i.name}
225
-
226
- \`\`\`json
227
- ${i.content}
228
- \`\`\`
229
- `)
230
- .join("\n\n")}
231
-
232
- ## Update
233
-
234
- ${hotUpdateFile
235
- .map(i => `
236
- ### ${i.name}
237
-
238
- #### Changed Modules
239
- ${i.modules.map(i => `- ${i}`).join("\n")}
240
-
241
- #### Changed Runtime Modules
242
- ${i.runtime.map(i => `- ${i}`).join("\n")}
243
-
244
- #### Changed Content
245
- \`\`\`js
246
- ${i.content}
247
- \`\`\`
248
- `)
249
- .join("\n\n")}
250
-
251
-
252
- ${runtime
253
- ? `
254
- ## Runtime
255
- ### Status
256
-
257
- \`\`\`txt
258
- ${runtime.statusPath.join(" => ")}
259
- \`\`\`
260
-
261
- ${runtime.javascript
262
- ? `
263
-
264
- ### JavaScript
265
-
266
- #### Outdated
267
-
268
- Outdated Modules:
269
- ${runtime.javascript.outdatedModules.map(i => `- ${i}`).join("\n")}
270
-
271
-
272
- Outdated Dependencies:
273
- \`\`\`json
274
- ${JSON.stringify(runtime.javascript.outdatedDependencies || {}, null, 2)}
275
- \`\`\`
276
-
277
- #### Updated
278
-
279
- Updated Modules:
280
- ${runtime.javascript.updatedModules.map(i => `- ${i}`).join("\n")}
281
-
282
- Updated Runtime:
283
- ${runtime.javascript.updatedRuntime.map(i => `- \`${i}\``).join("\n")}
284
-
285
-
286
- #### Callback
287
-
288
- Accepted Callback:
289
- ${runtime.javascript.acceptedModules.map(i => `- ${i}`).join("\n")}
290
-
291
- Disposed Callback:
292
- ${runtime.javascript.disposedModules.map(i => `- ${i}`).join("\n")}
293
- `
294
- : ""}
295
-
296
- `
297
- : ""}
298
-
299
- `
300
- .replaceAll(/%3A(\d+)%2F/g, (match, capture) => {
301
- return match.replace(capture, "PORT");
302
- })
303
- .trim();
304
- env.expect(content).toMatchFileSnapshot(snapshotPath);
305
- }
306
- }
307
- exports.HotSnapshotProcessor = HotSnapshotProcessor;
@@ -1,17 +0,0 @@
1
- import { ECompilerType, type ITestContext, type ITestEnv, type ITestRunner, type TCompilerOptions, type TUpdateOptions } from "../type";
2
- import { BasicProcessor, type IBasicProcessorOptions } from "./basic";
3
- export interface IHotProcessorOptions<T extends ECompilerType> extends Omit<IBasicProcessorOptions<T>, "runable"> {
4
- target: TCompilerOptions<T>["target"];
5
- checkSteps?: boolean;
6
- }
7
- export declare class HotProcessor<T extends ECompilerType> extends BasicProcessor<T> {
8
- protected _hotOptions: IHotProcessorOptions<T>;
9
- protected updateOptions: TUpdateOptions;
10
- protected runner: ITestRunner | null;
11
- constructor(_hotOptions: IHotProcessorOptions<T>);
12
- run(env: ITestEnv, context: ITestContext): Promise<void>;
13
- static findBundle<T extends ECompilerType>(this: HotProcessor<T>, context: ITestContext): string | string[];
14
- afterAll(context: ITestContext): Promise<void>;
15
- static defaultOptions<T extends ECompilerType>(this: HotProcessor<T>, context: ITestContext): TCompilerOptions<T>;
16
- static overrideOptions<T extends ECompilerType>(this: HotProcessor<T>, context: ITestContext, options: TCompilerOptions<T>): void;
17
- }