@rspack-debug/test-tools 1.3.14
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/LICENSE +22 -0
- package/README.md +17 -0
- package/dist/case/builtin.d.ts +1 -0
- package/dist/case/builtin.js +39 -0
- package/dist/case/cache.d.ts +2 -0
- package/dist/case/cache.js +34 -0
- package/dist/case/compiler.d.ts +6 -0
- package/dist/case/compiler.js +17 -0
- package/dist/case/config.d.ts +3 -0
- package/dist/case/config.js +39 -0
- package/dist/case/defaults.d.ts +6 -0
- package/dist/case/defaults.js +39 -0
- package/dist/case/diagnostic.d.ts +1 -0
- package/dist/case/diagnostic.js +29 -0
- package/dist/case/diff.d.ts +3 -0
- package/dist/case/diff.js +126 -0
- package/dist/case/error.d.ts +6 -0
- package/dist/case/error.js +21 -0
- package/dist/case/hash.d.ts +3 -0
- package/dist/case/hash.js +30 -0
- package/dist/case/hook.d.ts +6 -0
- package/dist/case/hook.js +35 -0
- package/dist/case/hot-step.d.ts +2 -0
- package/dist/case/hot-step.js +32 -0
- package/dist/case/hot.d.ts +2 -0
- package/dist/case/hot.js +32 -0
- package/dist/case/index.d.ts +19 -0
- package/dist/case/index.js +35 -0
- package/dist/case/new-incremental.d.ts +6 -0
- package/dist/case/new-incremental.js +100 -0
- package/dist/case/normal.d.ts +1 -0
- package/dist/case/normal.js +29 -0
- package/dist/case/serial.d.ts +3 -0
- package/dist/case/serial.js +34 -0
- package/dist/case/stats-api.d.ts +6 -0
- package/dist/case/stats-api.js +21 -0
- package/dist/case/stats-output.d.ts +1 -0
- package/dist/case/stats-output.js +22 -0
- package/dist/case/treeshaking.d.ts +1 -0
- package/dist/case/treeshaking.js +23 -0
- package/dist/case/watch.d.ts +1 -0
- package/dist/case/watch.js +53 -0
- package/dist/compare/comparator.d.ts +17 -0
- package/dist/compare/comparator.js +52 -0
- package/dist/compare/compare.d.ts +17 -0
- package/dist/compare/compare.js +175 -0
- package/dist/compare/format-code.d.ts +16 -0
- package/dist/compare/format-code.js +239 -0
- package/dist/compare/index.d.ts +5 -0
- package/dist/compare/index.js +21 -0
- package/dist/compare/replace-module-argument.d.ts +1 -0
- package/dist/compare/replace-module-argument.js +8 -0
- package/dist/compare/replace-runtime-module-name.d.ts +1 -0
- package/dist/compare/replace-runtime-module-name.js +71 -0
- package/dist/compiler.d.ts +28 -0
- package/dist/compiler.js +111 -0
- package/dist/helper/directory.d.ts +12 -0
- package/dist/helper/directory.js +81 -0
- package/dist/helper/expect/diff.d.ts +3 -0
- package/dist/helper/expect/diff.js +21 -0
- package/dist/helper/expect/error.d.ts +5 -0
- package/dist/helper/expect/error.js +51 -0
- package/dist/helper/expect/placeholder.d.ts +1 -0
- package/dist/helper/expect/placeholder.js +41 -0
- package/dist/helper/expect/rspack.d.ts +3 -0
- package/dist/helper/expect/rspack.js +14 -0
- package/dist/helper/expect/to-be-typeof.d.ts +4 -0
- package/dist/helper/expect/to-be-typeof.js +12 -0
- package/dist/helper/expect/to-end-with.d.ts +4 -0
- package/dist/helper/expect/to-end-with.js +11 -0
- package/dist/helper/expect/to-match-file-snapshot.d.ts +23 -0
- package/dist/helper/expect/to-match-file-snapshot.js +108 -0
- package/dist/helper/hot-update/index.d.ts +1 -0
- package/dist/helper/hot-update/index.js +5 -0
- package/dist/helper/hot-update/loader.d.ts +1 -0
- package/dist/helper/hot-update/loader.js +32 -0
- package/dist/helper/hot-update/plugin.d.ts +17 -0
- package/dist/helper/hot-update/plugin.js +133 -0
- package/dist/helper/index.d.ts +7 -0
- package/dist/helper/index.js +23 -0
- package/dist/helper/legacy/EventSourceForNode.d.ts +8 -0
- package/dist/helper/legacy/EventSourceForNode.js +40 -0
- package/dist/helper/legacy/FakeDocument.d.ts +54 -0
- package/dist/helper/legacy/FakeDocument.js +278 -0
- package/dist/helper/legacy/asModule.d.ts +3 -0
- package/dist/helper/legacy/asModule.js +25 -0
- package/dist/helper/legacy/captureStdio.d.ts +8 -0
- package/dist/helper/legacy/captureStdio.js +32 -0
- package/dist/helper/legacy/checkArrayExpectation.d.ts +2 -0
- package/dist/helper/legacy/checkArrayExpectation.js +111 -0
- package/dist/helper/legacy/copyDiff.d.ts +2 -0
- package/dist/helper/legacy/copyDiff.js +33 -0
- package/dist/helper/legacy/createFakeWorker.d.ts +13 -0
- package/dist/helper/legacy/createFakeWorker.js +80 -0
- package/dist/helper/legacy/createLazyTestEnv.d.ts +10 -0
- package/dist/helper/legacy/createLazyTestEnv.js +116 -0
- package/dist/helper/legacy/createLogger.d.ts +23 -0
- package/dist/helper/legacy/createLogger.js +20 -0
- package/dist/helper/legacy/currentScript.d.ts +6 -0
- package/dist/helper/legacy/currentScript.js +8 -0
- package/dist/helper/legacy/fakeSystem.d.ts +9 -0
- package/dist/helper/legacy/fakeSystem.js +124 -0
- package/dist/helper/legacy/parseResource.d.ts +6 -0
- package/dist/helper/legacy/parseResource.js +15 -0
- package/dist/helper/legacy/supportsImportFn.d.ts +1 -0
- package/dist/helper/legacy/supportsImportFn.js +15 -0
- package/dist/helper/legacy/supportsWorker.d.ts +2 -0
- package/dist/helper/legacy/supportsWorker.js +17 -0
- package/dist/helper/legacy/urlToRelativePath.d.ts +2 -0
- package/dist/helper/legacy/urlToRelativePath.js +7 -0
- package/dist/helper/legacy/walkCssTokens.d.ts +40 -0
- package/dist/helper/legacy/walkCssTokens.js +761 -0
- package/dist/helper/legacy/warmup-webpack.d.ts +1 -0
- package/dist/helper/legacy/warmup-webpack.js +26 -0
- package/dist/helper/loaders/hot-update.d.ts +1 -0
- package/dist/helper/loaders/hot-update.js +40 -0
- package/dist/helper/parse-modules.d.ts +7 -0
- package/dist/helper/parse-modules.js +73 -0
- package/dist/helper/plugins/hot-update.d.ts +7 -0
- package/dist/helper/plugins/hot-update.js +40 -0
- package/dist/helper/plugins/index.d.ts +1 -0
- package/dist/helper/plugins/index.js +17 -0
- package/dist/helper/read-config-file.d.ts +2 -0
- package/dist/helper/read-config-file.js +13 -0
- package/dist/helper/serializers.d.ts +2 -0
- package/dist/helper/serializers.js +52 -0
- package/dist/helper/setup-env.d.ts +1 -0
- package/dist/helper/setup-env.js +80 -0
- package/dist/helper/setup-expect.d.ts +1 -0
- package/dist/helper/setup-expect.js +16 -0
- package/dist/helper/update-snapshot.d.ts +1 -0
- package/dist/helper/update-snapshot.js +6 -0
- package/dist/helper/util/checkSourceMap.d.ts +1 -0
- package/dist/helper/util/checkSourceMap.js +96 -0
- package/dist/helper/util/checkStats.d.ts +2 -0
- package/dist/helper/util/checkStats.js +43 -0
- package/dist/helper/util/currentWatchStep.d.ts +1 -0
- package/dist/helper/util/currentWatchStep.js +2 -0
- package/dist/helper/util/expectWarningFactory.d.ts +2 -0
- package/dist/helper/util/expectWarningFactory.js +21 -0
- package/dist/helper/util/filterUtil.d.ts +8 -0
- package/dist/helper/util/filterUtil.js +50 -0
- package/dist/helper/util/identifier.d.ts +76 -0
- package/dist/helper/util/identifier.js +339 -0
- package/dist/helper/util/replaceMitteDiagnostic.d.ts +2 -0
- package/dist/helper/util/replaceMitteDiagnostic.js +17 -0
- package/dist/helper/win.d.ts +1 -0
- package/dist/helper/win.js +10 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +28 -0
- package/dist/plugin/index.d.ts +4 -0
- package/dist/plugin/index.js +20 -0
- package/dist/plugin/lazy-compilation-test-plugin.d.ts +4 -0
- package/dist/plugin/lazy-compilation-test-plugin.js +67 -0
- package/dist/plugin/rspack-diff-config-plugin.d.ts +7 -0
- package/dist/plugin/rspack-diff-config-plugin.js +42 -0
- package/dist/plugin/webpack-diff-config-plugin.d.ts +7 -0
- package/dist/plugin/webpack-diff-config-plugin.js +41 -0
- package/dist/plugin/webpack-module-placeholder-plugin.d.ts +3 -0
- package/dist/plugin/webpack-module-placeholder-plugin.js +107 -0
- package/dist/processor/basic.d.ts +24 -0
- package/dist/processor/basic.js +146 -0
- package/dist/processor/builtin.d.ts +9 -0
- package/dist/processor/builtin.js +171 -0
- package/dist/processor/cache.d.ts +20 -0
- package/dist/processor/cache.js +127 -0
- package/dist/processor/config.d.ts +11 -0
- package/dist/processor/config.js +81 -0
- package/dist/processor/defaults.d.ts +30 -0
- package/dist/processor/defaults.js +72 -0
- package/dist/processor/diagnostic.d.ts +15 -0
- package/dist/processor/diagnostic.js +102 -0
- package/dist/processor/diff.d.ts +30 -0
- package/dist/processor/diff.js +140 -0
- package/dist/processor/error.d.ts +23 -0
- package/dist/processor/error.js +95 -0
- package/dist/processor/hash.d.ts +10 -0
- package/dist/processor/hash.js +63 -0
- package/dist/processor/hook.d.ts +44 -0
- package/dist/processor/hook.js +204 -0
- package/dist/processor/hot-new-incremental.d.ts +14 -0
- package/dist/processor/hot-new-incremental.js +43 -0
- package/dist/processor/hot-step.d.ts +18 -0
- package/dist/processor/hot-step.js +299 -0
- package/dist/processor/hot.d.ts +17 -0
- package/dist/processor/hot.js +138 -0
- package/dist/processor/index.d.ts +20 -0
- package/dist/processor/index.js +36 -0
- package/dist/processor/multi.d.ts +17 -0
- package/dist/processor/multi.js +73 -0
- package/dist/processor/normal.d.ts +12 -0
- package/dist/processor/normal.js +150 -0
- package/dist/processor/simple.d.ts +23 -0
- package/dist/processor/simple.js +49 -0
- package/dist/processor/snapshot.d.ts +12 -0
- package/dist/processor/snapshot.js +62 -0
- package/dist/processor/stats-api.d.ts +18 -0
- package/dist/processor/stats-api.js +48 -0
- package/dist/processor/stats.d.ts +18 -0
- package/dist/processor/stats.js +206 -0
- package/dist/processor/treeshaking.d.ts +10 -0
- package/dist/processor/treeshaking.js +33 -0
- package/dist/processor/watch.d.ts +29 -0
- package/dist/processor/watch.js +234 -0
- package/dist/reporter/diff-html.d.ts +15 -0
- package/dist/reporter/diff-html.js +69 -0
- package/dist/reporter/diff-stats.d.ts +24 -0
- package/dist/reporter/diff-stats.js +131 -0
- package/dist/reporter/index.d.ts +2 -0
- package/dist/reporter/index.js +18 -0
- package/dist/runner/basic.d.ts +10 -0
- package/dist/runner/basic.js +63 -0
- package/dist/runner/cache.d.ts +5 -0
- package/dist/runner/cache.js +90 -0
- package/dist/runner/hot-step.d.ts +5 -0
- package/dist/runner/hot-step.js +87 -0
- package/dist/runner/hot.d.ts +5 -0
- package/dist/runner/hot.js +83 -0
- package/dist/runner/index.d.ts +9 -0
- package/dist/runner/index.js +25 -0
- package/dist/runner/multiple.d.ts +11 -0
- package/dist/runner/multiple.js +38 -0
- package/dist/runner/normal.d.ts +5 -0
- package/dist/runner/normal.js +20 -0
- package/dist/runner/runner/basic.d.ts +30 -0
- package/dist/runner/runner/basic.js +107 -0
- package/dist/runner/runner/cjs.d.ts +14 -0
- package/dist/runner/runner/cjs.js +151 -0
- package/dist/runner/runner/esm.d.ts +7 -0
- package/dist/runner/runner/esm.js +125 -0
- package/dist/runner/runner/index.d.ts +8 -0
- package/dist/runner/runner/index.js +24 -0
- package/dist/runner/runner/normal.d.ts +9 -0
- package/dist/runner/runner/normal.js +23 -0
- package/dist/runner/runner/watch.d.ts +16 -0
- package/dist/runner/runner/watch.js +27 -0
- package/dist/runner/runner/web/fake.d.ts +18 -0
- package/dist/runner/runner/web/fake.js +143 -0
- package/dist/runner/runner/web/jsdom.d.ts +26 -0
- package/dist/runner/runner/web/jsdom.js +219 -0
- package/dist/runner/runner/web.d.ts +15 -0
- package/dist/runner/runner/web.js +32 -0
- package/dist/runner/type.d.ts +42 -0
- package/dist/runner/type.js +9 -0
- package/dist/runner/watch.d.ts +7 -0
- package/dist/runner/watch.js +60 -0
- package/dist/test/context.d.ts +26 -0
- package/dist/test/context.js +108 -0
- package/dist/test/creator.d.ts +46 -0
- package/dist/test/creator.js +310 -0
- package/dist/test/simple.d.ts +5 -0
- package/dist/test/simple.js +43 -0
- package/dist/test/tester.d.ts +17 -0
- package/dist/test/tester.js +88 -0
- package/dist/type.d.ts +168 -0
- package/dist/type.js +22 -0
- package/jest.d.ts +25 -0
- package/package.json +116 -0
- package/template/diff.bundle.css +1 -0
- package/template/diff.bundle.js +144 -0
- package/template/diff.html +14 -0
- package/template/editor.worker.js +1 -0
package/dist/type.d.ts
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import type EventEmitter from "node:events";
|
|
2
|
+
import type { Compiler as RspackCompiler, MultiStats as RspackMultiStats, RspackOptions, Stats as RspackStats, StatsCompilation as RspackStatsCompilation } from "@rspack/core";
|
|
3
|
+
import type { Compiler as WebpackCompiler, MultiStats as WebpackMultiStats, Configuration as WebpackOptions, Stats as WebpackStats, StatsCompilation as WebpackStatsCompilation } from "webpack";
|
|
4
|
+
import type { IBasicModuleScope, TRunnerRequirer } from "./runner/type";
|
|
5
|
+
export interface ITestContext {
|
|
6
|
+
getSource(sub?: string): string;
|
|
7
|
+
getDist(sub?: string): string;
|
|
8
|
+
getTemp(sub?: string): string | null;
|
|
9
|
+
getCompiler<T extends ECompilerType>(name: string, type: T | void): ITestCompilerManager<T>;
|
|
10
|
+
getTestConfig<T extends ECompilerType>(): TTestConfig<T>;
|
|
11
|
+
getRunnerFactory<T extends ECompilerType>(name: string): TRunnerFactory<T> | null;
|
|
12
|
+
getRunner(key: string): ITestRunner | null;
|
|
13
|
+
setRunner(key: string, runner: ITestRunner): void;
|
|
14
|
+
setValue<T>(name: string, key: string, value: T): void;
|
|
15
|
+
getValue<T>(name: string, key: string): T | void;
|
|
16
|
+
getNames(): string[];
|
|
17
|
+
hasError(name?: string): boolean;
|
|
18
|
+
emitError(name: string, err: Error | string): void;
|
|
19
|
+
getError(name?: string): Error[];
|
|
20
|
+
clearError(name?: string): void;
|
|
21
|
+
}
|
|
22
|
+
export declare enum ECompilerType {
|
|
23
|
+
Rspack = "rspack",
|
|
24
|
+
Webpack = "webpack"
|
|
25
|
+
}
|
|
26
|
+
export type TCompilerOptions<T> = T extends ECompilerType.Rspack ? RspackOptions : WebpackOptions;
|
|
27
|
+
export type TCompiler<T> = T extends ECompilerType.Rspack ? RspackCompiler : WebpackCompiler;
|
|
28
|
+
export type TCompilerStats<T> = T extends ECompilerType.Rspack ? RspackStats : WebpackStats;
|
|
29
|
+
export type TCompilerMultiStats<T> = T extends ECompilerType.Rspack ? RspackMultiStats : WebpackMultiStats;
|
|
30
|
+
export type TCompilerStatsCompilation<T> = T extends ECompilerType.Rspack ? RspackStatsCompilation : WebpackStatsCompilation;
|
|
31
|
+
export interface ITestCompilerManager<T extends ECompilerType> {
|
|
32
|
+
getOptions(): TCompilerOptions<T>;
|
|
33
|
+
setOptions(newOptions: TCompilerOptions<T>): TCompilerOptions<T>;
|
|
34
|
+
mergeOptions(newOptions: TCompilerOptions<T>): TCompilerOptions<T>;
|
|
35
|
+
getCompiler(): TCompiler<T> | null;
|
|
36
|
+
createCompiler(): TCompiler<T>;
|
|
37
|
+
build(): Promise<TCompilerStats<T>>;
|
|
38
|
+
watch(timeout?: number): void;
|
|
39
|
+
getStats(): TCompilerStats<T> | TCompilerMultiStats<T> | null;
|
|
40
|
+
getEmitter(): EventEmitter;
|
|
41
|
+
close(): Promise<void>;
|
|
42
|
+
}
|
|
43
|
+
export interface ITestLoader {
|
|
44
|
+
walk(): Promise<void>;
|
|
45
|
+
}
|
|
46
|
+
export type TTestRunResult = Record<string, any>;
|
|
47
|
+
export interface ITesterConfig {
|
|
48
|
+
name: string;
|
|
49
|
+
src: string;
|
|
50
|
+
dist: string;
|
|
51
|
+
temp?: string;
|
|
52
|
+
steps?: ITestProcessor[];
|
|
53
|
+
testConfig?: TTestConfig<ECompilerType>;
|
|
54
|
+
compilerFactories?: TCompilerFactories;
|
|
55
|
+
contextValue?: Record<string, unknown>;
|
|
56
|
+
runnerFactory?: new (name: string, context: ITestContext) => TRunnerFactory<ECompilerType>;
|
|
57
|
+
}
|
|
58
|
+
export interface ITester {
|
|
59
|
+
step: number;
|
|
60
|
+
total: number;
|
|
61
|
+
getContext(): ITestContext;
|
|
62
|
+
prepare(): Promise<void>;
|
|
63
|
+
compile(): Promise<void>;
|
|
64
|
+
check(env: ITestEnv): Promise<void>;
|
|
65
|
+
next(): boolean;
|
|
66
|
+
resume(): Promise<void>;
|
|
67
|
+
}
|
|
68
|
+
export interface ITestProcessor {
|
|
69
|
+
beforeAll?(context: ITestContext): Promise<void>;
|
|
70
|
+
afterAll?(context: ITestContext): Promise<void>;
|
|
71
|
+
before?(context: ITestContext): Promise<void>;
|
|
72
|
+
after?(context: ITestContext): Promise<void>;
|
|
73
|
+
config?(context: ITestContext): Promise<void>;
|
|
74
|
+
compiler?(context: ITestContext): Promise<void>;
|
|
75
|
+
build?(context: ITestContext): Promise<void>;
|
|
76
|
+
run?(env: ITestEnv, context: ITestContext): Promise<void>;
|
|
77
|
+
check?(env: ITestEnv, context: ITestContext): Promise<unknown>;
|
|
78
|
+
}
|
|
79
|
+
export interface ITestReporter<T> {
|
|
80
|
+
init(data?: T): Promise<void>;
|
|
81
|
+
increment(id: string, data: T): Promise<void>;
|
|
82
|
+
failure(id: string): Promise<void>;
|
|
83
|
+
output(): Promise<void>;
|
|
84
|
+
}
|
|
85
|
+
export declare enum ECompareResultType {
|
|
86
|
+
Same = "same",
|
|
87
|
+
Missing = "missing",
|
|
88
|
+
OnlyDist = "only-dist",
|
|
89
|
+
OnlySource = "only-source",
|
|
90
|
+
Different = "different"
|
|
91
|
+
}
|
|
92
|
+
export type TCompareModules = string[] | true;
|
|
93
|
+
export type TCompareResult = {
|
|
94
|
+
type: ECompareResultType;
|
|
95
|
+
detail?: unknown;
|
|
96
|
+
source?: string;
|
|
97
|
+
dist?: string;
|
|
98
|
+
lines?: {
|
|
99
|
+
common: number;
|
|
100
|
+
source: number;
|
|
101
|
+
dist: number;
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
export type TModuleCompareResult = TCompareResult & {
|
|
105
|
+
name: string;
|
|
106
|
+
};
|
|
107
|
+
export type TFileCompareResult = TCompareResult & {
|
|
108
|
+
file: {
|
|
109
|
+
source: string;
|
|
110
|
+
dist: string;
|
|
111
|
+
};
|
|
112
|
+
modules: Partial<Record<"modules" | "runtimeModules", TModuleCompareResult[]>>;
|
|
113
|
+
};
|
|
114
|
+
export type TDiffStatsItem = {
|
|
115
|
+
name: string;
|
|
116
|
+
source: string;
|
|
117
|
+
dist: string;
|
|
118
|
+
type: ECompareResultType;
|
|
119
|
+
};
|
|
120
|
+
export type TDiffStats = {
|
|
121
|
+
root: string;
|
|
122
|
+
data: Array<TDiffStatsItem>;
|
|
123
|
+
};
|
|
124
|
+
export interface ITestEnv {
|
|
125
|
+
expect: jest.Expect;
|
|
126
|
+
it: (...args: any[]) => void;
|
|
127
|
+
beforeEach: (...args: any[]) => void;
|
|
128
|
+
afterEach: (...args: any[]) => void;
|
|
129
|
+
[key: string]: unknown;
|
|
130
|
+
}
|
|
131
|
+
export declare enum EDocumentType {
|
|
132
|
+
Fake = "fake",
|
|
133
|
+
JSDOM = "jsdom"
|
|
134
|
+
}
|
|
135
|
+
export type TTestConfig<T extends ECompilerType> = {
|
|
136
|
+
documentType?: EDocumentType;
|
|
137
|
+
validate?: (stats: TCompilerStats<T> | TCompilerMultiStats<T>, stderr?: string) => void;
|
|
138
|
+
noTest?: boolean;
|
|
139
|
+
writeStatsOuptut?: boolean;
|
|
140
|
+
writeStatsJson?: boolean;
|
|
141
|
+
beforeExecute?: () => void;
|
|
142
|
+
afterExecute?: () => void;
|
|
143
|
+
moduleScope?: (ms: IBasicModuleScope, stats?: TCompilerStatsCompilation<T>) => IBasicModuleScope;
|
|
144
|
+
checkStats?: (stepName: string, jsonStats: TCompilerStatsCompilation<T> | undefined, stringStats: String) => boolean;
|
|
145
|
+
findBundle?: (index: number, options: TCompilerOptions<T>, stepName?: string) => string | string[];
|
|
146
|
+
bundlePath?: string[];
|
|
147
|
+
nonEsmThis?: (p: string | string[]) => Object;
|
|
148
|
+
modules?: Record<string, Object>;
|
|
149
|
+
timeout?: number;
|
|
150
|
+
concurrent?: boolean;
|
|
151
|
+
checkSteps?: boolean;
|
|
152
|
+
};
|
|
153
|
+
export type TTestFilter<T extends ECompilerType> = (creatorConfig: Record<string, unknown>, testConfig: TTestConfig<T>) => boolean | string;
|
|
154
|
+
export interface ITestRunner {
|
|
155
|
+
run(file: string): Promise<unknown>;
|
|
156
|
+
getRequire(): TRunnerRequirer;
|
|
157
|
+
getGlobal(name: string): unknown;
|
|
158
|
+
}
|
|
159
|
+
export type TCompilerFactory<T extends ECompilerType> = (options: TCompilerOptions<T> | TCompilerOptions<T>[]) => TCompiler<T>;
|
|
160
|
+
export interface TRunnerFactory<T extends ECompilerType> {
|
|
161
|
+
create(file: string, compilerOptions: TCompilerOptions<T>, env: ITestEnv): ITestRunner;
|
|
162
|
+
}
|
|
163
|
+
export type TUpdateOptions = {
|
|
164
|
+
updateIndex: number;
|
|
165
|
+
totalUpdates: number;
|
|
166
|
+
changedFiles: string[];
|
|
167
|
+
};
|
|
168
|
+
export type TCompilerFactories = Record<ECompilerType, TCompilerFactory<ECompilerType>>;
|
package/dist/type.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/// <reference types="../jest.d.ts" />
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.EDocumentType = exports.ECompareResultType = exports.ECompilerType = void 0;
|
|
5
|
+
var ECompilerType;
|
|
6
|
+
(function (ECompilerType) {
|
|
7
|
+
ECompilerType["Rspack"] = "rspack";
|
|
8
|
+
ECompilerType["Webpack"] = "webpack";
|
|
9
|
+
})(ECompilerType || (exports.ECompilerType = ECompilerType = {}));
|
|
10
|
+
var ECompareResultType;
|
|
11
|
+
(function (ECompareResultType) {
|
|
12
|
+
ECompareResultType["Same"] = "same";
|
|
13
|
+
ECompareResultType["Missing"] = "missing";
|
|
14
|
+
ECompareResultType["OnlyDist"] = "only-dist";
|
|
15
|
+
ECompareResultType["OnlySource"] = "only-source";
|
|
16
|
+
ECompareResultType["Different"] = "different";
|
|
17
|
+
})(ECompareResultType || (exports.ECompareResultType = ECompareResultType = {}));
|
|
18
|
+
var EDocumentType;
|
|
19
|
+
(function (EDocumentType) {
|
|
20
|
+
EDocumentType["Fake"] = "fake";
|
|
21
|
+
EDocumentType["JSDOM"] = "jsdom";
|
|
22
|
+
})(EDocumentType || (exports.EDocumentType = EDocumentType = {}));
|
package/jest.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/// <reference types="jest" />
|
|
2
|
+
|
|
3
|
+
import type { DiffOptions } from "jest-diff";
|
|
4
|
+
|
|
5
|
+
declare interface FileMatcherOptions {
|
|
6
|
+
diff?: DiffOptions;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
declare global {
|
|
10
|
+
namespace jest {
|
|
11
|
+
interface Matchers<R, T> {
|
|
12
|
+
toMatchFileSnapshot: (
|
|
13
|
+
filename?: string,
|
|
14
|
+
options?: FileMatcherOptions
|
|
15
|
+
) => void;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface Expect {
|
|
19
|
+
toMatchFileSnapshot: (
|
|
20
|
+
filename?: string,
|
|
21
|
+
options?: FileMatcherOptions
|
|
22
|
+
) => void;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rspack-debug/test-tools",
|
|
3
|
+
"version": "1.3.14",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"description": "Test tools for rspack",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"default": "./dist/index.js"
|
|
11
|
+
},
|
|
12
|
+
"./setup-expect": "./dist/helper/setup-expect.js",
|
|
13
|
+
"./setup-env": "./dist/helper/setup-env.js",
|
|
14
|
+
"./package.json": "./package.json"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"client",
|
|
18
|
+
"dist",
|
|
19
|
+
"template",
|
|
20
|
+
"jest.d.ts"
|
|
21
|
+
],
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"access": "public",
|
|
24
|
+
"provenance": true
|
|
25
|
+
},
|
|
26
|
+
"homepage": "https://rspack.rs",
|
|
27
|
+
"bugs": "https://github.com/web-infra-dev/rspack/issues",
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "https://github.com/web-infra-dev/rspack",
|
|
31
|
+
"directory": "packages/rspack-test-tools"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@babel/generator": "7.27.5",
|
|
35
|
+
"@babel/parser": "7.27.5",
|
|
36
|
+
"@babel/traverse": "7.27.4",
|
|
37
|
+
"@babel/types": "7.27.3",
|
|
38
|
+
"cross-env": "^7.0.3",
|
|
39
|
+
"csv-to-markdown-table": "^1.5.0",
|
|
40
|
+
"deepmerge": "^4.3.1",
|
|
41
|
+
"filenamify": "4.3.0",
|
|
42
|
+
"fs-extra": "^11.3.0",
|
|
43
|
+
"glob": "^11.0.2",
|
|
44
|
+
"graceful-fs": "^4.2.11",
|
|
45
|
+
"iconv-lite": "^0.6.3",
|
|
46
|
+
"jest-diff": "^29.7.0",
|
|
47
|
+
"jest-snapshot": "29.7.0",
|
|
48
|
+
"jsdom": "^26.1.0",
|
|
49
|
+
"memfs": "4.17.2",
|
|
50
|
+
"loader-utils": "^2.0.4",
|
|
51
|
+
"path-serializer": "0.4.0",
|
|
52
|
+
"pretty-format": "29.7.0",
|
|
53
|
+
"rimraf": "^5.0.10",
|
|
54
|
+
"source-map": "^0.7.4",
|
|
55
|
+
"terser-webpack-plugin": "^5.3.14",
|
|
56
|
+
"webpack": "5.99.9",
|
|
57
|
+
"webpack-merge": "6.0.1",
|
|
58
|
+
"webpack-sources": "3.3.0"
|
|
59
|
+
},
|
|
60
|
+
"devDependencies": {
|
|
61
|
+
"@rspack/plugin-preact-refresh": "1.1.2",
|
|
62
|
+
"@rspack/plugin-react-refresh": "^1.4.3",
|
|
63
|
+
"@swc/helpers": "0.5.17",
|
|
64
|
+
"@swc/plugin-remove-console": "^7.0.4",
|
|
65
|
+
"@types/babel__generator": "7.27.0",
|
|
66
|
+
"@types/babel__traverse": "7.20.7",
|
|
67
|
+
"@types/fs-extra": "11.0.4",
|
|
68
|
+
"@types/jsdom": "^21.1.7",
|
|
69
|
+
"@types/react": "^19.1.6",
|
|
70
|
+
"@types/react-dom": "^19.1.5",
|
|
71
|
+
"@webdiscus/pug-loader": "^2.11.1",
|
|
72
|
+
"acorn": "^8.14.1",
|
|
73
|
+
"babel-loader": "^10.0.0",
|
|
74
|
+
"babel-plugin-import": "^1.13.8",
|
|
75
|
+
"chalk": "^4.1.2",
|
|
76
|
+
"core-js": "3.42.0",
|
|
77
|
+
"css-loader": "^7.1.2",
|
|
78
|
+
"file-loader": "^6.2.0",
|
|
79
|
+
"graceful-fs": "^4.2.11",
|
|
80
|
+
"html-loader": "^5.1.0",
|
|
81
|
+
"html-webpack-plugin": "^5.6.3",
|
|
82
|
+
"less-loader": "^12.3.0",
|
|
83
|
+
"lodash": "^4.17.21",
|
|
84
|
+
"postcss-loader": "^8.1.1",
|
|
85
|
+
"postcss-pxtorem": "^6.1.0",
|
|
86
|
+
"raw-loader": "^4.0.2",
|
|
87
|
+
"react": "^19.1.0",
|
|
88
|
+
"react-dom": "^19.1.0",
|
|
89
|
+
"react-refresh": "^0.17.0",
|
|
90
|
+
"sass-loader": "^16.0.5",
|
|
91
|
+
"source-map": "^0.7.4",
|
|
92
|
+
"source-map-loader": "^5.0.0",
|
|
93
|
+
"style-loader": "^4.0.0",
|
|
94
|
+
"terser": "5.40.0",
|
|
95
|
+
"typescript": "^5.8.3",
|
|
96
|
+
"wast-loader": "^1.14.1",
|
|
97
|
+
"worker-rspack-loader": "^3.1.2",
|
|
98
|
+
"@rspack/cli": "npm:@rspack-debug/cli@1.3.14",
|
|
99
|
+
"@rspack/core": "npm:@rspack-debug/core@1.3.14",
|
|
100
|
+
"@rspack/test-tools": "npm:@rspack-debug/test-tools@1.3.14"
|
|
101
|
+
},
|
|
102
|
+
"peerDependencies": {
|
|
103
|
+
"@rspack/core": ">=1.0.0"
|
|
104
|
+
},
|
|
105
|
+
"scripts": {
|
|
106
|
+
"build": "tsc -b ./tsconfig.build.json",
|
|
107
|
+
"dev": "tsc -b -w",
|
|
108
|
+
"test": "cross-env RUST_BACKTRACE=full pnpm run --stream /^test:.*/",
|
|
109
|
+
"testu": "pnpm run --stream /^test:.*/ -u",
|
|
110
|
+
"test:base": "cross-env node --no-warnings --expose-gc --max-old-space-size=8192 --experimental-vm-modules ../../node_modules/jest-cli/bin/jest --logHeapUsage --colors --config ./jest.config.js --passWithNoTests",
|
|
111
|
+
"test:hot": "cross-env RSPACK_HOT_TEST=true node --no-warnings --expose-gc --max-old-space-size=8192 --experimental-vm-modules ../../node_modules/jest-cli/bin/jest --logHeapUsage --colors --config ./jest.config.hot.js --passWithNoTests",
|
|
112
|
+
"test:diff": "cross-env RSPACK_DIFF=true node --no-warnings --expose-gc --max-old-space-size=8192 --experimental-vm-modules ../../node_modules/jest-cli/bin/jest --logHeapUsage --colors --config ./jest.config.diff.js --passWithNoTests",
|
|
113
|
+
"api-extractor": "api-extractor run --verbose",
|
|
114
|
+
"api-extractor:ci": "api-extractor run --verbose || diff temp/test-tools.api.md etc/test-tools.api.md"
|
|
115
|
+
}
|
|
116
|
+
}
|