@rspack-canary/test-tools 1.5.7-canary-a3406c0a-20250922173625 → 1.5.8-canary-6c1a40e3-20250925175235
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.d.ts +2 -2
- package/dist/case/builtin.js +37 -28
- package/dist/case/cache.d.ts +1 -1
- package/dist/case/cache.js +135 -42
- package/dist/case/common.d.ts +10 -0
- package/dist/case/common.js +237 -0
- package/dist/case/compiler.d.ts +7 -4
- package/dist/case/compiler.js +144 -109
- package/dist/case/config.d.ts +3 -2
- package/dist/case/config.js +47 -39
- package/dist/case/defaults.d.ts +2 -2
- package/dist/case/defaults.js +28 -18
- package/dist/case/diagnostic.d.ts +1 -1
- package/dist/case/diagnostic.js +52 -43
- package/dist/case/diff.d.ts +17 -1
- package/dist/case/diff.js +170 -22
- package/dist/case/error.d.ts +14 -4
- package/dist/case/error.js +51 -21
- package/dist/case/hash.d.ts +1 -1
- package/dist/case/hash.js +41 -34
- package/dist/case/hook.d.ts +4 -5
- package/dist/case/hook.js +78 -70
- package/dist/case/hot-step.d.ts +1 -1
- package/dist/case/hot-step.js +9 -5
- package/dist/case/hot.d.ts +5 -5
- package/dist/case/hot.js +142 -55
- package/dist/case/incremental.d.ts +1 -1
- package/dist/case/incremental.js +19 -34
- package/dist/case/native-watcher.js +10 -23
- package/dist/case/normal.js +46 -31
- package/dist/case/runner.d.ts +18 -0
- package/dist/case/runner.js +108 -0
- package/dist/case/serial.d.ts +1 -1
- package/dist/case/serial.js +7 -15
- package/dist/case/stats-api.js +52 -22
- package/dist/case/stats-output.js +133 -137
- package/dist/case/treeshaking.js +33 -22
- package/dist/case/watch.d.ts +27 -0
- package/dist/case/watch.js +321 -21
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -2
- package/dist/runner/index.d.ts +2 -7
- package/dist/runner/index.js +2 -7
- package/dist/runner/{runner/node → node}/index.d.ts +1 -2
- package/dist/runner/{runner/node → node}/index.js +2 -2
- package/dist/runner/{runner/web → web}/fake.d.ts +1 -2
- package/dist/runner/{runner/web → web}/fake.js +7 -7
- package/dist/runner/{runner/web → web}/index.d.ts +2 -2
- package/dist/runner/{runner/web → web}/index.js +1 -1
- package/dist/runner/{runner/web → web}/jsdom.d.ts +1 -2
- package/dist/runner/{runner/web → web}/jsdom.js +4 -4
- package/dist/test/context.d.ts +3 -5
- package/dist/test/context.js +22 -12
- package/dist/test/creator.d.ts +13 -12
- package/dist/test/creator.js +52 -43
- package/dist/test/tester.js +4 -1
- package/dist/type.d.ts +41 -10
- package/dist/type.js +7 -1
- package/package.json +6 -6
- package/dist/processor/basic.d.ts +0 -27
- package/dist/processor/basic.js +0 -157
- package/dist/processor/diff.d.ts +0 -30
- package/dist/processor/diff.js +0 -140
- package/dist/processor/index.d.ts +0 -6
- package/dist/processor/index.js +0 -22
- package/dist/processor/multi.d.ts +0 -19
- package/dist/processor/multi.js +0 -75
- package/dist/processor/simple.d.ts +0 -24
- package/dist/processor/simple.js +0 -51
- package/dist/processor/snapshot.d.ts +0 -12
- package/dist/processor/snapshot.js +0 -67
- package/dist/processor/watch.d.ts +0 -30
- package/dist/processor/watch.js +0 -252
- package/dist/runner/basic.d.ts +0 -10
- package/dist/runner/basic.js +0 -64
- package/dist/runner/cache.d.ts +0 -5
- package/dist/runner/cache.js +0 -92
- package/dist/runner/hot.d.ts +0 -5
- package/dist/runner/hot.js +0 -91
- package/dist/runner/multiple.d.ts +0 -11
- package/dist/runner/multiple.js +0 -52
- package/dist/runner/runner/index.d.ts +0 -2
- package/dist/runner/runner/index.js +0 -18
- package/dist/runner/type.d.ts +0 -42
- package/dist/runner/type.js +0 -9
- package/dist/runner/watch.d.ts +0 -7
- package/dist/runner/watch.js +0 -71
- package/dist/test/simple.d.ts +0 -5
- package/dist/test/simple.js +0 -43
package/dist/processor/diff.js
DELETED
|
@@ -1,140 +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.DiffProcessor = void 0;
|
|
7
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
-
const compare_1 = require("../compare");
|
|
9
|
-
const plugin_1 = require("../plugin");
|
|
10
|
-
const type_1 = require("../type");
|
|
11
|
-
const basic_1 = require("./basic");
|
|
12
|
-
class DiffProcessor {
|
|
13
|
-
constructor(options) {
|
|
14
|
-
this.options = options;
|
|
15
|
-
this.hashes = [];
|
|
16
|
-
this.webpack = null;
|
|
17
|
-
if (global.updateSnapshot) {
|
|
18
|
-
this.webpack = new basic_1.BasicProcessor({
|
|
19
|
-
defaultOptions: context => this.getDefaultOptions(type_1.ECompilerType.Webpack, context.getSource(), node_path_1.default.join(context.getDist(), type_1.ECompilerType.Webpack)),
|
|
20
|
-
compilerType: type_1.ECompilerType.Webpack,
|
|
21
|
-
name: type_1.ECompilerType.Webpack,
|
|
22
|
-
configFiles: ["webpack.config.js", "rspack.config.js"],
|
|
23
|
-
runable: false
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
this.rspack = new basic_1.BasicProcessor({
|
|
27
|
-
defaultOptions: context => this.getDefaultOptions(type_1.ECompilerType.Rspack, context.getSource(), node_path_1.default.join(context.getDist(), type_1.ECompilerType.Rspack)),
|
|
28
|
-
compilerType: type_1.ECompilerType.Rspack,
|
|
29
|
-
name: type_1.ECompilerType.Rspack,
|
|
30
|
-
configFiles: ["rspack.config.js", "webpack.config.js"],
|
|
31
|
-
runable: false
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
async config(context) {
|
|
35
|
-
if (this.webpack) {
|
|
36
|
-
await this.webpack.config(context);
|
|
37
|
-
}
|
|
38
|
-
await this.rspack.config(context);
|
|
39
|
-
}
|
|
40
|
-
async compiler(context) {
|
|
41
|
-
if (this.webpack) {
|
|
42
|
-
await this.webpack.compiler(context);
|
|
43
|
-
}
|
|
44
|
-
await this.rspack.compiler(context);
|
|
45
|
-
}
|
|
46
|
-
async build(context) {
|
|
47
|
-
if (this.webpack) {
|
|
48
|
-
await this.webpack.build(context);
|
|
49
|
-
}
|
|
50
|
-
await this.rspack.build(context);
|
|
51
|
-
}
|
|
52
|
-
async check(env, context) {
|
|
53
|
-
if (this.webpack) {
|
|
54
|
-
const webpackCompiler = context.getCompiler(type_1.ECompilerType.Webpack);
|
|
55
|
-
const webpackStats = webpackCompiler.getStats();
|
|
56
|
-
//TODO: handle chunk hash and content hash
|
|
57
|
-
webpackStats?.hash && this.hashes.push(webpackStats?.hash);
|
|
58
|
-
if (!this.options.errors) {
|
|
59
|
-
env.expect(webpackStats?.hasErrors()).toBe(false);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
const rspackCompiler = context.getCompiler(type_1.ECompilerType.Rspack);
|
|
63
|
-
const rspackStats = rspackCompiler.getStats();
|
|
64
|
-
//TODO: handle chunk hash and content hash
|
|
65
|
-
rspackStats?.hash && this.hashes.push(rspackStats?.hash);
|
|
66
|
-
if (!this.options.errors) {
|
|
67
|
-
env.expect(rspackStats?.hasErrors()).toBe(false);
|
|
68
|
-
}
|
|
69
|
-
const dist = context.getDist();
|
|
70
|
-
const snapshot = context.getSource("__snapshot__");
|
|
71
|
-
for (const file of this.options.files) {
|
|
72
|
-
const rspackDist = node_path_1.default.join(dist, type_1.ECompilerType.Rspack, file);
|
|
73
|
-
const webpackDist = node_path_1.default.join(dist, type_1.ECompilerType.Webpack, file);
|
|
74
|
-
const snapshotDist = node_path_1.default.join(snapshot, file.replace(/\.js$/, ".json"));
|
|
75
|
-
const result = (0, compare_1.compareFile)(rspackDist, webpackDist, {
|
|
76
|
-
modules: this.options.modules,
|
|
77
|
-
runtimeModules: this.options.runtimeModules,
|
|
78
|
-
format: this.createFormatOptions(),
|
|
79
|
-
renameModule: this.options.renameModule,
|
|
80
|
-
bootstrap: this.options.bootstrap,
|
|
81
|
-
detail: this.options.detail,
|
|
82
|
-
snapshot: snapshotDist
|
|
83
|
-
});
|
|
84
|
-
if (typeof this.options.onCompareFile === "function") {
|
|
85
|
-
this.options.onCompareFile(file, result);
|
|
86
|
-
}
|
|
87
|
-
if (typeof this.options.onCompareModules === "function" &&
|
|
88
|
-
result.modules.modules) {
|
|
89
|
-
this.options.onCompareModules(file, result.modules.modules);
|
|
90
|
-
}
|
|
91
|
-
if (typeof this.options.onCompareRuntimeModules === "function" &&
|
|
92
|
-
result.modules.runtimeModules) {
|
|
93
|
-
this.options.onCompareRuntimeModules(file, result.modules.runtimeModules);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
getDefaultOptions(type, src, dist) {
|
|
98
|
-
return {
|
|
99
|
-
entry: node_path_1.default.join(src, "./src/index.js"),
|
|
100
|
-
context: src,
|
|
101
|
-
output: {
|
|
102
|
-
path: dist,
|
|
103
|
-
filename: "bundle.js",
|
|
104
|
-
chunkFilename: "[name].chunk.js"
|
|
105
|
-
},
|
|
106
|
-
plugins: [
|
|
107
|
-
type === type_1.ECompilerType.Webpack && new plugin_1.WebpackDiffConfigPlugin(),
|
|
108
|
-
type === type_1.ECompilerType.Rspack && new plugin_1.RspackDiffConfigPlugin()
|
|
109
|
-
].filter(Boolean),
|
|
110
|
-
experiments: type === type_1.ECompilerType.Rspack
|
|
111
|
-
? {
|
|
112
|
-
css: true,
|
|
113
|
-
rspackFuture: {
|
|
114
|
-
bundlerInfo: {
|
|
115
|
-
force: false
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
: {}
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
createFormatOptions() {
|
|
123
|
-
const formatOptions = {
|
|
124
|
-
ignoreModuleArguments: this.options.ignoreModuleArguments,
|
|
125
|
-
ignoreModuleId: this.options.ignoreModuleId,
|
|
126
|
-
ignorePropertyQuotationMark: this.options.ignorePropertyQuotationMark,
|
|
127
|
-
ignoreBlockOnlyStatement: this.options.ignoreBlockOnlyStatement,
|
|
128
|
-
ignoreIfCertainCondition: this.options.ignoreIfCertainCondition,
|
|
129
|
-
ignoreSwcHelpersPath: this.options.ignoreSwcHelpersPath,
|
|
130
|
-
ignoreObjectPropertySequence: this.options.ignoreObjectPropertySequence,
|
|
131
|
-
ignoreCssFilePath: this.options.ignoreCssFilePath,
|
|
132
|
-
replacements: this.options.replacements || []
|
|
133
|
-
};
|
|
134
|
-
for (const hash of this.hashes) {
|
|
135
|
-
formatOptions.replacements.push({ from: hash, to: "fullhash" });
|
|
136
|
-
}
|
|
137
|
-
return formatOptions;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
exports.DiffProcessor = DiffProcessor;
|
package/dist/processor/index.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./basic"), exports);
|
|
18
|
-
__exportStar(require("./diff"), exports);
|
|
19
|
-
__exportStar(require("./multi"), exports);
|
|
20
|
-
__exportStar(require("./simple"), exports);
|
|
21
|
-
__exportStar(require("./snapshot"), exports);
|
|
22
|
-
__exportStar(require("./watch"), exports);
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { ECompilerType, ITestContext, ITestEnv, ITestProcessor, TCompiler, TCompilerMultiStats, TCompilerOptions, TCompilerStats } from "../type";
|
|
2
|
-
import { BasicProcessor } from "./basic";
|
|
3
|
-
export interface IMultiTaskProcessorOptions<T extends ECompilerType> {
|
|
4
|
-
defaultOptions?: (index: number, context: ITestContext) => TCompilerOptions<T>;
|
|
5
|
-
overrideOptions?: (index: number, context: ITestContext, options: TCompilerOptions<T>) => void;
|
|
6
|
-
findBundle?: (index: number, context: ITestContext, options: TCompilerOptions<T>) => string[] | string | void;
|
|
7
|
-
compilerType: T;
|
|
8
|
-
name: string;
|
|
9
|
-
configFiles?: string[];
|
|
10
|
-
runable: boolean;
|
|
11
|
-
compiler?: (context: ITestContext, compiler: TCompiler<T>) => Promise<void>;
|
|
12
|
-
check?: (env: ITestEnv, context: ITestContext, compiler: TCompiler<T>, stats: TCompilerStats<T> | TCompilerMultiStats<T> | null) => Promise<void>;
|
|
13
|
-
}
|
|
14
|
-
export declare class MultiTaskProcessor<T extends ECompilerType> extends BasicProcessor<T> implements ITestProcessor {
|
|
15
|
-
protected _multiOptions: IMultiTaskProcessorOptions<T>;
|
|
16
|
-
protected multiCompilerOptions: TCompilerOptions<T>[];
|
|
17
|
-
constructor(_multiOptions: IMultiTaskProcessorOptions<T>);
|
|
18
|
-
config(context: ITestContext): Promise<void>;
|
|
19
|
-
}
|
package/dist/processor/multi.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MultiTaskProcessor = void 0;
|
|
4
|
-
const webpack_merge_1 = require("webpack-merge");
|
|
5
|
-
const helper_1 = require("../helper");
|
|
6
|
-
const basic_1 = require("./basic");
|
|
7
|
-
class MultiTaskProcessor extends basic_1.BasicProcessor {
|
|
8
|
-
constructor(_multiOptions) {
|
|
9
|
-
super({
|
|
10
|
-
runable: _multiOptions.runable,
|
|
11
|
-
compilerType: _multiOptions.compilerType,
|
|
12
|
-
findBundle: (context, _) => {
|
|
13
|
-
if (typeof _multiOptions.findBundle !== "function") {
|
|
14
|
-
return [];
|
|
15
|
-
}
|
|
16
|
-
const result = [];
|
|
17
|
-
const multiFileIndexMap = context.getValue(_multiOptions.name, "multiFileIndexMap") || {};
|
|
18
|
-
for (const [index, compilerOptions] of this.multiCompilerOptions.entries()) {
|
|
19
|
-
const curBundles = _multiOptions.findBundle(index, context, compilerOptions);
|
|
20
|
-
const bundles = Array.isArray(curBundles)
|
|
21
|
-
? curBundles
|
|
22
|
-
: curBundles
|
|
23
|
-
? [curBundles]
|
|
24
|
-
: [];
|
|
25
|
-
for (const bundle of bundles) {
|
|
26
|
-
if (multiFileIndexMap[bundle]) {
|
|
27
|
-
multiFileIndexMap[bundle].push(index);
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
multiFileIndexMap[bundle] = [index];
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
result.push(...bundles);
|
|
34
|
-
}
|
|
35
|
-
context.setValue(_multiOptions.name, "multiFileIndexMap", multiFileIndexMap);
|
|
36
|
-
return result;
|
|
37
|
-
},
|
|
38
|
-
check: _multiOptions.check,
|
|
39
|
-
compiler: _multiOptions.compiler,
|
|
40
|
-
name: _multiOptions.name
|
|
41
|
-
});
|
|
42
|
-
this._multiOptions = _multiOptions;
|
|
43
|
-
this.multiCompilerOptions = [];
|
|
44
|
-
}
|
|
45
|
-
async config(context) {
|
|
46
|
-
this.multiCompilerOptions = [];
|
|
47
|
-
const caseOptions = Array.isArray(this._multiOptions.configFiles)
|
|
48
|
-
? (0, helper_1.readConfigFile)(this._multiOptions.configFiles.map(i => context.getSource(i)), configs => {
|
|
49
|
-
return configs.flatMap(c => {
|
|
50
|
-
if (typeof c === "function") {
|
|
51
|
-
const options = {
|
|
52
|
-
testPath: context.getDist(),
|
|
53
|
-
env: undefined
|
|
54
|
-
};
|
|
55
|
-
return c(options.env, options);
|
|
56
|
-
}
|
|
57
|
-
return c;
|
|
58
|
-
});
|
|
59
|
-
})
|
|
60
|
-
: [{}];
|
|
61
|
-
for (const [index, options] of caseOptions.entries()) {
|
|
62
|
-
const compilerOptions = (0, webpack_merge_1.merge)(typeof this._multiOptions.defaultOptions === "function"
|
|
63
|
-
? this._multiOptions.defaultOptions(index, context)
|
|
64
|
-
: {}, options);
|
|
65
|
-
if (typeof this._multiOptions.overrideOptions === "function") {
|
|
66
|
-
this._multiOptions.overrideOptions(index, context, compilerOptions);
|
|
67
|
-
}
|
|
68
|
-
this.multiCompilerOptions.push(compilerOptions);
|
|
69
|
-
}
|
|
70
|
-
const compiler = this.getCompiler(context);
|
|
71
|
-
compiler.setOptions(this.multiCompilerOptions);
|
|
72
|
-
context.setValue(this._options.name, "multiCompilerOptions", this.multiCompilerOptions);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
exports.MultiTaskProcessor = MultiTaskProcessor;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { ECompilerType, ITestContext, ITestEnv, ITestProcessor, TCompiler, TCompilerOptions, TCompilerStats } from "../type";
|
|
2
|
-
export interface ISimpleProcessorOptions<T extends ECompilerType> {
|
|
3
|
-
options?: (context: ITestContext) => TCompilerOptions<T>;
|
|
4
|
-
compilerCallback?: (error: Error | null, stats: TCompilerStats<T> | null) => void;
|
|
5
|
-
compilerType: T;
|
|
6
|
-
name: string;
|
|
7
|
-
build?: (context: ITestContext, compiler: TCompiler<T>) => Promise<void>;
|
|
8
|
-
compiler?: (context: ITestContext, compiler: TCompiler<T>) => Promise<void>;
|
|
9
|
-
check?: (env: ITestEnv, context: ITestContext, compiler: TCompiler<T>, stats: TCompilerStats<T>) => Promise<void>;
|
|
10
|
-
}
|
|
11
|
-
export declare class SimpleTaskProcessor<T extends ECompilerType> implements ITestProcessor {
|
|
12
|
-
protected _options: ISimpleProcessorOptions<T>;
|
|
13
|
-
constructor(_options: ISimpleProcessorOptions<T>);
|
|
14
|
-
config(context: ITestContext): Promise<void>;
|
|
15
|
-
compiler(context: ITestContext): Promise<void>;
|
|
16
|
-
build(context: ITestContext): Promise<void>;
|
|
17
|
-
run(env: ITestEnv, context: ITestContext): Promise<void>;
|
|
18
|
-
check(env: ITestEnv, context: ITestContext): Promise<void>;
|
|
19
|
-
before(context: ITestContext): Promise<void>;
|
|
20
|
-
after(context: ITestContext): Promise<void>;
|
|
21
|
-
beforeAll(context: ITestContext): Promise<void>;
|
|
22
|
-
afterAll(context: ITestContext): Promise<void>;
|
|
23
|
-
protected getCompiler(context: ITestContext): import("../type").ITestCompilerManager<T>;
|
|
24
|
-
}
|
package/dist/processor/simple.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SimpleTaskProcessor = void 0;
|
|
4
|
-
class SimpleTaskProcessor {
|
|
5
|
-
constructor(_options) {
|
|
6
|
-
this._options = _options;
|
|
7
|
-
}
|
|
8
|
-
async config(context) {
|
|
9
|
-
const compiler = this.getCompiler(context);
|
|
10
|
-
if (typeof this._options.options === "function") {
|
|
11
|
-
compiler.setOptions(this._options.options.call(this, context));
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
async compiler(context) {
|
|
15
|
-
const compiler = this.getCompiler(context);
|
|
16
|
-
const instance = this._options.compilerCallback
|
|
17
|
-
? compiler.createCompilerWithCallback(this._options.compilerCallback)
|
|
18
|
-
: compiler.createCompiler();
|
|
19
|
-
if (typeof this._options.compiler === "function") {
|
|
20
|
-
await this._options.compiler.call(this, context, instance);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
async build(context) {
|
|
24
|
-
const compiler = this.getCompiler(context);
|
|
25
|
-
if (typeof this._options.build === "function") {
|
|
26
|
-
await this._options.build.call(this, context, compiler.getCompiler());
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
await compiler.build();
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
async run(env, context) { }
|
|
33
|
-
async check(env, context) {
|
|
34
|
-
const compiler = this.getCompiler(context);
|
|
35
|
-
const stats = compiler.getStats();
|
|
36
|
-
if (typeof this._options.check === "function") {
|
|
37
|
-
await this._options.check.call(this, env, context, compiler.getCompiler(), stats);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
async before(context) { }
|
|
41
|
-
async after(context) {
|
|
42
|
-
const compiler = this.getCompiler(context);
|
|
43
|
-
await compiler.close();
|
|
44
|
-
}
|
|
45
|
-
async beforeAll(context) { }
|
|
46
|
-
async afterAll(context) { }
|
|
47
|
-
getCompiler(context) {
|
|
48
|
-
return context.getCompiler(this._options.name, this._options.compilerType);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
exports.SimpleTaskProcessor = SimpleTaskProcessor;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { ECompilerType, ITestContext, ITestEnv } from "../type";
|
|
2
|
-
import { BasicProcessor, type IBasicProcessorOptions } from "./basic";
|
|
3
|
-
export interface ISnapshotProcessorOptions<T extends ECompilerType> extends IBasicProcessorOptions<T> {
|
|
4
|
-
snapshot: string;
|
|
5
|
-
snapshotFileFilter?: (file: string) => boolean;
|
|
6
|
-
}
|
|
7
|
-
export declare class SnapshotProcessor<T extends ECompilerType> extends BasicProcessor<T> {
|
|
8
|
-
protected _snapshotOptions: ISnapshotProcessorOptions<T>;
|
|
9
|
-
constructor(_snapshotOptions: ISnapshotProcessorOptions<T>);
|
|
10
|
-
check(env: ITestEnv, context: ITestContext): Promise<void>;
|
|
11
|
-
serializeEachFile(content: string): string;
|
|
12
|
-
}
|
|
@@ -1,67 +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.SnapshotProcessor = void 0;
|
|
7
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
-
const placeholder_1 = require("../helper/expect/placeholder");
|
|
9
|
-
const basic_1 = require("./basic");
|
|
10
|
-
class SnapshotProcessor extends basic_1.BasicProcessor {
|
|
11
|
-
constructor(_snapshotOptions) {
|
|
12
|
-
super(_snapshotOptions);
|
|
13
|
-
this._snapshotOptions = _snapshotOptions;
|
|
14
|
-
if (node_path_1.default.extname(_snapshotOptions.snapshot) === ".snap") {
|
|
15
|
-
throw new Error("Snapshot with `.snap` will be managed by jest, please use `.snap.txt` instead in SnapshotProcessor");
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
async check(env, context) {
|
|
19
|
-
const compiler = this.getCompiler(context);
|
|
20
|
-
const stats = compiler.getStats();
|
|
21
|
-
const c = compiler.getCompiler();
|
|
22
|
-
if (!stats || !c)
|
|
23
|
-
return;
|
|
24
|
-
if (stats.hasErrors()) {
|
|
25
|
-
const errors = [];
|
|
26
|
-
if (stats.stats) {
|
|
27
|
-
for (const s of stats.stats) {
|
|
28
|
-
if (s.hasErrors()) {
|
|
29
|
-
errors.push(...s.compilation.errors);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
const s = stats;
|
|
35
|
-
errors.push(...s.compilation.errors);
|
|
36
|
-
}
|
|
37
|
-
throw new Error(`Failed to compile in fixture ${this._options.name}, Errors: ${errors
|
|
38
|
-
?.map(i => `${i.message}\n${i.stack}`)
|
|
39
|
-
.join("\n\n")}`);
|
|
40
|
-
}
|
|
41
|
-
const compilation = c._lastCompilation ||
|
|
42
|
-
c._lastCompilation;
|
|
43
|
-
const snapshotFileFilter = this._snapshotOptions.snapshotFileFilter ||
|
|
44
|
-
((file) => file.endsWith(".js") && !file.includes("runtime.js"));
|
|
45
|
-
const fileContents = Object.entries(compilation.assets)
|
|
46
|
-
.filter(([file]) => snapshotFileFilter.call(this, file))
|
|
47
|
-
.map(([file, source]) => {
|
|
48
|
-
const tag = node_path_1.default.extname(file).slice(1) || "txt";
|
|
49
|
-
let content = (0, placeholder_1.normalizePlaceholder)(source.source().toString());
|
|
50
|
-
const testConfig = context.getTestConfig();
|
|
51
|
-
if (testConfig.snapshotContent) {
|
|
52
|
-
content = testConfig.snapshotContent(content);
|
|
53
|
-
}
|
|
54
|
-
return `\`\`\`${tag} title=${file}\n${content}\n\`\`\``;
|
|
55
|
-
});
|
|
56
|
-
fileContents.sort();
|
|
57
|
-
const content = fileContents.join("\n\n");
|
|
58
|
-
const snapshotPath = node_path_1.default.isAbsolute(this._snapshotOptions.snapshot)
|
|
59
|
-
? this._snapshotOptions.snapshot
|
|
60
|
-
: node_path_1.default.resolve(context.getSource(), `./__snapshots__/${this._snapshotOptions.snapshot}`);
|
|
61
|
-
env.expect(content).toMatchFileSnapshot(snapshotPath);
|
|
62
|
-
}
|
|
63
|
-
serializeEachFile(content) {
|
|
64
|
-
return (0, placeholder_1.normalizePlaceholder)(content);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
exports.SnapshotProcessor = SnapshotProcessor;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { ECompilerType, ITestContext, ITestEnv, TCompilerOptions } from "../type";
|
|
2
|
-
import { type IMultiTaskProcessorOptions, MultiTaskProcessor } from "./multi";
|
|
3
|
-
export interface IWatchProcessorOptions<T extends ECompilerType> extends IMultiTaskProcessorOptions<T> {
|
|
4
|
-
stepName: string;
|
|
5
|
-
tempDir: string;
|
|
6
|
-
nativeWatcher?: boolean;
|
|
7
|
-
}
|
|
8
|
-
export declare class WatchProcessor<T extends ECompilerType> extends MultiTaskProcessor<T> {
|
|
9
|
-
protected _watchOptions: IWatchProcessorOptions<T>;
|
|
10
|
-
protected _watchState: Record<string, any>;
|
|
11
|
-
protected currentTriggerFilename: string | null;
|
|
12
|
-
protected lastHash: string | null;
|
|
13
|
-
constructor(_watchOptions: IWatchProcessorOptions<T>, _watchState: Record<string, any>);
|
|
14
|
-
compiler(context: ITestContext): Promise<void>;
|
|
15
|
-
build(context: ITestContext): Promise<void>;
|
|
16
|
-
run(env: ITestEnv, context: ITestContext): Promise<void>;
|
|
17
|
-
check(env: ITestEnv, context: ITestContext): Promise<void>;
|
|
18
|
-
config(context: ITestContext): Promise<void>;
|
|
19
|
-
static overrideOptions<T extends ECompilerType>({ tempDir, nativeWatcher }: IWatchProcessorOptions<T>): (index: number, context: ITestContext, options: TCompilerOptions<ECompilerType>) => void;
|
|
20
|
-
static findBundle<T extends ECompilerType>(this: IWatchProcessorOptions<T>, index: number, context: ITestContext, options: TCompilerOptions<T>): string | string[];
|
|
21
|
-
}
|
|
22
|
-
export interface IWatchStepProcessorOptions<T extends ECompilerType> extends Omit<IWatchProcessorOptions<T>, "experiments" | "optimization"> {
|
|
23
|
-
}
|
|
24
|
-
export declare class WatchStepProcessor<T extends ECompilerType> extends WatchProcessor<T> {
|
|
25
|
-
protected _watchOptions: IWatchStepProcessorOptions<T>;
|
|
26
|
-
protected _watchState: Record<string, any>;
|
|
27
|
-
constructor(_watchOptions: IWatchStepProcessorOptions<T>, _watchState: Record<string, any>);
|
|
28
|
-
compiler(context: ITestContext): Promise<void>;
|
|
29
|
-
build(context: ITestContext): Promise<void>;
|
|
30
|
-
}
|