@rspack/test-tools 1.5.5 → 1.5.7

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 (142) hide show
  1. package/dist/case/builtin.d.ts +2 -0
  2. package/dist/case/builtin.js +173 -13
  3. package/dist/case/cache.d.ts +1 -1
  4. package/dist/case/cache.js +210 -11
  5. package/dist/case/common.d.ts +10 -0
  6. package/dist/case/common.js +237 -0
  7. package/dist/case/compiler.d.ts +7 -4
  8. package/dist/case/compiler.js +35 -18
  9. package/dist/case/config.d.ts +5 -1
  10. package/dist/case/config.js +102 -16
  11. package/dist/case/defaults.d.ts +12 -4
  12. package/dist/case/defaults.js +67 -12
  13. package/dist/case/diagnostic.d.ts +6 -0
  14. package/dist/case/diagnostic.js +123 -14
  15. package/dist/case/diff.d.ts +17 -1
  16. package/dist/case/diff.js +170 -22
  17. package/dist/case/error.d.ts +14 -4
  18. package/dist/case/error.js +103 -7
  19. package/dist/case/hash.d.ts +1 -1
  20. package/dist/case/hash.js +68 -7
  21. package/dist/case/hook.d.ts +35 -4
  22. package/dist/case/hook.js +196 -14
  23. package/dist/case/hot-step.js +307 -9
  24. package/dist/case/hot.d.ts +8 -1
  25. package/dist/case/hot.js +235 -8
  26. package/dist/case/incremental.d.ts +1 -1
  27. package/dist/case/incremental.js +39 -41
  28. package/dist/case/index.d.ts +20 -20
  29. package/dist/case/index.js +44 -34
  30. package/dist/case/native-watcher.js +10 -23
  31. package/dist/case/normal.js +174 -12
  32. package/dist/case/runner.d.ts +18 -0
  33. package/dist/case/runner.js +108 -0
  34. package/dist/case/serial.d.ts +1 -1
  35. package/dist/case/serial.js +8 -12
  36. package/dist/case/stats-api.d.ts +0 -5
  37. package/dist/case/stats-api.js +57 -7
  38. package/dist/case/stats-output.js +197 -10
  39. package/dist/case/treeshaking.js +34 -7
  40. package/dist/case/watch.d.ts +27 -0
  41. package/dist/case/watch.js +321 -21
  42. package/dist/compare/format-code.d.ts +1 -1
  43. package/dist/compare/format-code.js +6 -1
  44. package/dist/helper/directory.js +1 -1
  45. package/dist/helper/legacy/checkArrayExpectation.d.ts +1 -1
  46. package/dist/helper/legacy/checkArrayExpectation.js +7 -7
  47. package/dist/helper/plugins/hot-update.d.ts +2 -2
  48. package/dist/index.d.ts +0 -1
  49. package/dist/index.js +0 -1
  50. package/dist/runner/index.d.ts +2 -9
  51. package/dist/runner/index.js +2 -9
  52. package/dist/runner/node/index.d.ts +37 -0
  53. package/dist/runner/node/index.js +396 -0
  54. package/dist/runner/web/fake.d.ts +15 -0
  55. package/dist/runner/{runner/web → web}/fake.js +10 -28
  56. package/dist/runner/{runner/web.d.ts → web/index.d.ts} +4 -5
  57. package/dist/runner/{runner/web.js → web/index.js} +2 -2
  58. package/dist/runner/web/jsdom.d.ts +24 -0
  59. package/dist/runner/{runner/web → web}/jsdom.js +18 -8
  60. package/dist/test/context.d.ts +3 -5
  61. package/dist/test/context.js +22 -12
  62. package/dist/test/creator.d.ts +3 -3
  63. package/dist/test/creator.js +3 -2
  64. package/dist/test/simple.js +1 -0
  65. package/dist/test/tester.js +10 -0
  66. package/dist/type.d.ts +42 -12
  67. package/dist/type.js +7 -1
  68. package/package.json +6 -6
  69. package/dist/processor/basic.d.ts +0 -24
  70. package/dist/processor/basic.js +0 -146
  71. package/dist/processor/builtin.d.ts +0 -9
  72. package/dist/processor/builtin.js +0 -171
  73. package/dist/processor/cache.d.ts +0 -20
  74. package/dist/processor/cache.js +0 -129
  75. package/dist/processor/config.d.ts +0 -11
  76. package/dist/processor/config.js +0 -86
  77. package/dist/processor/defaults.d.ts +0 -30
  78. package/dist/processor/defaults.js +0 -72
  79. package/dist/processor/diagnostic.d.ts +0 -15
  80. package/dist/processor/diagnostic.js +0 -102
  81. package/dist/processor/diff.d.ts +0 -30
  82. package/dist/processor/diff.js +0 -140
  83. package/dist/processor/error.d.ts +0 -23
  84. package/dist/processor/error.js +0 -95
  85. package/dist/processor/hash.d.ts +0 -10
  86. package/dist/processor/hash.js +0 -63
  87. package/dist/processor/hook.d.ts +0 -44
  88. package/dist/processor/hook.js +0 -204
  89. package/dist/processor/hot-incremental.d.ts +0 -14
  90. package/dist/processor/hot-incremental.js +0 -43
  91. package/dist/processor/hot-step.d.ts +0 -18
  92. package/dist/processor/hot-step.js +0 -307
  93. package/dist/processor/hot.d.ts +0 -17
  94. package/dist/processor/hot.js +0 -145
  95. package/dist/processor/index.d.ts +0 -20
  96. package/dist/processor/index.js +0 -36
  97. package/dist/processor/multi.d.ts +0 -17
  98. package/dist/processor/multi.js +0 -73
  99. package/dist/processor/normal.d.ts +0 -12
  100. package/dist/processor/normal.js +0 -168
  101. package/dist/processor/simple.d.ts +0 -24
  102. package/dist/processor/simple.js +0 -51
  103. package/dist/processor/snapshot.d.ts +0 -12
  104. package/dist/processor/snapshot.js +0 -66
  105. package/dist/processor/stats-api.d.ts +0 -18
  106. package/dist/processor/stats-api.js +0 -48
  107. package/dist/processor/stats.d.ts +0 -18
  108. package/dist/processor/stats.js +0 -206
  109. package/dist/processor/treeshaking.d.ts +0 -10
  110. package/dist/processor/treeshaking.js +0 -33
  111. package/dist/processor/watch.d.ts +0 -30
  112. package/dist/processor/watch.js +0 -251
  113. package/dist/runner/basic.d.ts +0 -10
  114. package/dist/runner/basic.js +0 -63
  115. package/dist/runner/cache.d.ts +0 -5
  116. package/dist/runner/cache.js +0 -90
  117. package/dist/runner/hot-step.d.ts +0 -5
  118. package/dist/runner/hot-step.js +0 -87
  119. package/dist/runner/hot.d.ts +0 -5
  120. package/dist/runner/hot.js +0 -83
  121. package/dist/runner/multiple.d.ts +0 -11
  122. package/dist/runner/multiple.js +0 -52
  123. package/dist/runner/normal.d.ts +0 -5
  124. package/dist/runner/normal.js +0 -20
  125. package/dist/runner/runner/basic.d.ts +0 -30
  126. package/dist/runner/runner/basic.js +0 -119
  127. package/dist/runner/runner/cjs.d.ts +0 -16
  128. package/dist/runner/runner/cjs.js +0 -180
  129. package/dist/runner/runner/esm.d.ts +0 -7
  130. package/dist/runner/runner/esm.js +0 -128
  131. package/dist/runner/runner/index.d.ts +0 -8
  132. package/dist/runner/runner/index.js +0 -24
  133. package/dist/runner/runner/normal.d.ts +0 -9
  134. package/dist/runner/runner/normal.js +0 -26
  135. package/dist/runner/runner/watch.d.ts +0 -16
  136. package/dist/runner/runner/watch.js +0 -27
  137. package/dist/runner/runner/web/fake.d.ts +0 -18
  138. package/dist/runner/runner/web/jsdom.d.ts +0 -25
  139. package/dist/runner/type.d.ts +0 -42
  140. package/dist/runner/type.js +0 -9
  141. package/dist/runner/watch.d.ts +0 -7
  142. package/dist/runner/watch.js +0 -60
@@ -1,95 +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.ErrorProcessor = void 0;
7
- const node_path_1 = __importDefault(require("node:path"));
8
- const webpack_merge_1 = __importDefault(require("webpack-merge"));
9
- const simple_1 = require("./simple");
10
- class RspackStatsDiagnostics {
11
- constructor(errors, warnings) {
12
- this.errors = errors;
13
- this.warnings = warnings;
14
- }
15
- }
16
- class ErrorProcessor extends simple_1.SimpleTaskProcessor {
17
- constructor(_errorOptions) {
18
- super({
19
- options: (context) => {
20
- let options = {
21
- context: node_path_1.default.resolve(__dirname, "../../../../tests/rspack-test/fixtures/errors"),
22
- mode: "none",
23
- devtool: false,
24
- optimization: {
25
- minimize: false,
26
- moduleIds: "named",
27
- chunkIds: "named"
28
- },
29
- experiments: {
30
- css: true,
31
- rspackFuture: {
32
- bundlerInfo: {
33
- force: false
34
- }
35
- }
36
- }
37
- };
38
- if (typeof _errorOptions.options === "function") {
39
- options = (0, webpack_merge_1.default)(options, _errorOptions.options(options, context));
40
- }
41
- if (options.mode === "production") {
42
- if (options.optimization)
43
- options.optimization.minimize = true;
44
- else
45
- options.optimization = { minimize: true };
46
- }
47
- return options;
48
- },
49
- build: _errorOptions.build,
50
- compilerType: _errorOptions.compilerType,
51
- name: _errorOptions.name
52
- });
53
- this._errorOptions = _errorOptions;
54
- }
55
- async compiler(context) {
56
- await super.compiler(context);
57
- const compiler = this.getCompiler(context).getCompiler();
58
- if (compiler) {
59
- compiler.outputFileSystem = {
60
- // CHANGE: rspack outputFileSystem `mkdirp` uses option `{ recursive: true }`, webpack's second parameter is alway a callback
61
- mkdir(dir, maybeOptionOrCallback, maybeCallback) {
62
- if (typeof maybeOptionOrCallback === "function") {
63
- maybeOptionOrCallback();
64
- }
65
- else if (typeof maybeCallback === "function") {
66
- maybeCallback();
67
- }
68
- },
69
- writeFile(file, content, callback) {
70
- callback();
71
- },
72
- stat(file, callback) {
73
- callback(new Error("ENOENT"));
74
- },
75
- mkdirSync() { },
76
- writeFileSync() { }
77
- };
78
- }
79
- }
80
- async run(env, context) {
81
- // do nothing
82
- }
83
- async check(env, context) {
84
- const compiler = this.getCompiler(context);
85
- const stats = compiler.getStats();
86
- env.expect(typeof stats).toBe("object");
87
- const statsResult = stats.toJson({ errorDetails: false });
88
- env.expect(typeof statsResult).toBe("object");
89
- const { errors, warnings } = statsResult;
90
- env.expect(Array.isArray(errors)).toBe(true);
91
- env.expect(Array.isArray(warnings)).toBe(true);
92
- await this._errorOptions.check?.(new RspackStatsDiagnostics(errors, warnings));
93
- }
94
- }
95
- exports.ErrorProcessor = ErrorProcessor;
@@ -1,10 +0,0 @@
1
- import type { ECompilerType, ITestContext, ITestEnv, TCompilerOptions } from "../type";
2
- import { type IMultiTaskProcessorOptions, MultiTaskProcessor } from "./multi";
3
- export interface IHashProcessorOptions<T extends ECompilerType> extends Omit<IMultiTaskProcessorOptions<T>, "runable"> {
4
- }
5
- export declare class HashProcessor<T extends ECompilerType> extends MultiTaskProcessor<T> {
6
- constructor(_hashOptions: IHashProcessorOptions<T>);
7
- check(env: ITestEnv, context: ITestContext): Promise<void>;
8
- static defaultOptions<T extends ECompilerType>(index: number, context: ITestContext): TCompilerOptions<T>;
9
- static overrideOptions<T extends ECompilerType>(index: number, context: ITestContext, options: TCompilerOptions<T>): void;
10
- }
@@ -1,63 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.HashProcessor = void 0;
4
- const multi_1 = require("./multi");
5
- const REG_ERROR_CASE = /error$/;
6
- class HashProcessor extends multi_1.MultiTaskProcessor {
7
- constructor(_hashOptions) {
8
- super({
9
- defaultOptions: (HashProcessor.defaultOptions),
10
- overrideOptions: (HashProcessor.overrideOptions),
11
- runable: false,
12
- ..._hashOptions
13
- });
14
- }
15
- async check(env, context) {
16
- const compiler = this.getCompiler(context);
17
- const testConfig = context.getTestConfig();
18
- const stats = compiler.getStats();
19
- if (!stats) {
20
- env.expect(false);
21
- return;
22
- }
23
- if (REG_ERROR_CASE.test(this._options.name)) {
24
- env.expect(stats.hasErrors());
25
- }
26
- else {
27
- env.expect(!stats.hasErrors());
28
- }
29
- if (typeof testConfig.validate === "function") {
30
- testConfig.validate(stats);
31
- }
32
- else {
33
- throw new Error("HashTestCases should have test.config.js and a validate method");
34
- }
35
- }
36
- static defaultOptions(index, context) {
37
- return {
38
- context: context.getSource(),
39
- output: {
40
- path: context.getDist()
41
- },
42
- experiments: {
43
- css: true,
44
- rspackFuture: {
45
- bundlerInfo: {
46
- force: false
47
- }
48
- }
49
- }
50
- };
51
- }
52
- static overrideOptions(index, context, options) {
53
- if (!options.entry) {
54
- options.entry = "./index.js";
55
- }
56
- if (!global.printLogger) {
57
- options.infrastructureLogging = {
58
- level: "error"
59
- };
60
- }
61
- }
62
- }
63
- exports.HashProcessor = HashProcessor;
@@ -1,44 +0,0 @@
1
- import { TestContext, type TTestContextOptions } from "../test/context";
2
- import type { ECompilerType, ITestContext, ITestEnv, TCompiler, TCompilerOptions } from "../type";
3
- import { type ISnapshotProcessorOptions, SnapshotProcessor } from "./snapshot";
4
- export declare class HookCasesContext extends TestContext {
5
- protected src: string;
6
- protected testName: string;
7
- protected options: TTestContextOptions;
8
- protected promises: Promise<void>[];
9
- protected count: number;
10
- protected snapshots: Record<string | number, Array<[string | Buffer, string]>>;
11
- protected snapshotsList: Array<string | number>;
12
- constructor(src: string, testName: string, options: TTestContextOptions);
13
- /**
14
- * Snapshot function arguments and return value.
15
- * Generated snapshot is located in the same directory with the test source.
16
- * @example
17
- * compiler.hooks.compilation("name", context.snapped((...args) => { ... }))
18
- */
19
- snapped(cb: (...args: unknown[]) => Promise<unknown>, prefix?: string): (this: any, ...args: unknown[]) => Promise<unknown>;
20
- /**
21
- * @internal
22
- */
23
- _addSnapshot(content: unknown, name: string, group: string | number): void;
24
- /**
25
- * @internal
26
- */
27
- collectSnapshots(env: ITestEnv, options?: {
28
- diff: {};
29
- }): Promise<void>;
30
- }
31
- export interface IHookProcessorOptions<T extends ECompilerType> extends ISnapshotProcessorOptions<T> {
32
- options?: (context: ITestContext) => TCompilerOptions<T>;
33
- compiler?: (context: ITestContext, compiler: TCompiler<T>) => Promise<void>;
34
- check?: (context: ITestContext) => Promise<void>;
35
- }
36
- export declare class HookTaskProcessor<T extends ECompilerType> extends SnapshotProcessor<T> {
37
- protected _hookOptions: IHookProcessorOptions<T>;
38
- constructor(_hookOptions: IHookProcessorOptions<T>);
39
- config(context: ITestContext): Promise<void>;
40
- compiler(context: ITestContext): Promise<void>;
41
- check(env: ITestEnv, context: HookCasesContext): Promise<void>;
42
- static defaultOptions<T extends ECompilerType>(context: ITestContext): TCompilerOptions<T>;
43
- static overrideOptions<T extends ECompilerType>(options: TCompilerOptions<T>): void;
44
- }
@@ -1,204 +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
- }
194
- };
195
- }
196
- static overrideOptions(options) {
197
- if (!global.printLogger) {
198
- options.infrastructureLogging = {
199
- level: "error"
200
- };
201
- }
202
- }
203
- }
204
- 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 {};