@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,88 +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.ConfigProcessor = void 0;
7
- const node_fs_1 = __importDefault(require("node:fs"));
8
- const node_path_1 = __importDefault(require("node:path"));
9
- const parseResource_1 = require("../helper/legacy/parseResource");
10
- const multi_1 = require("./multi");
11
- class ConfigProcessor extends multi_1.MultiTaskProcessor {
12
- constructor(_configOptions) {
13
- super({
14
- defaultOptions: (ConfigProcessor.defaultOptions),
15
- overrideOptions: (ConfigProcessor.overrideOptions),
16
- findBundle: (ConfigProcessor.findBundle),
17
- ..._configOptions
18
- });
19
- this._configOptions = _configOptions;
20
- }
21
- static findBundle(index, context, options) {
22
- const testConfig = context.getTestConfig();
23
- if (typeof testConfig.findBundle === "function") {
24
- return testConfig.findBundle(index, options);
25
- }
26
- const ext = node_path_1.default.extname((0, parseResource_1.parseResource)(options.output?.filename).path);
27
- const bundlePath = [];
28
- if (options.output?.path &&
29
- node_fs_1.default.existsSync(node_path_1.default.join(options.output.path, `bundle${index}${ext}`))) {
30
- if (options.experiments?.css) {
31
- const cssOutputPath = node_path_1.default.join(options.output.path, (typeof options.output?.cssFilename === "string" &&
32
- options.output?.cssFilename) ||
33
- `bundle${index}.css`);
34
- if (node_fs_1.default.existsSync(cssOutputPath)) {
35
- bundlePath.push(`./bundle${index}.css`);
36
- }
37
- }
38
- bundlePath.push(`./bundle${index}${ext}`);
39
- }
40
- return bundlePath;
41
- }
42
- static defaultOptions(index, context) {
43
- return {
44
- context: context.getSource(),
45
- mode: "production",
46
- target: "async-node",
47
- devtool: false,
48
- cache: false,
49
- output: {
50
- path: context.getDist()
51
- },
52
- optimization: {
53
- minimize: false
54
- },
55
- experiments: {
56
- css: true,
57
- rspackFuture: {
58
- bundlerInfo: {
59
- force: false
60
- }
61
- },
62
- inlineConst: true,
63
- lazyBarrel: true
64
- }
65
- };
66
- }
67
- static overrideOptions(index, context, options) {
68
- if (!options.entry) {
69
- options.entry = "./index.js";
70
- }
71
- if (options.amd === undefined) {
72
- options.amd = {};
73
- }
74
- if (!options.output?.filename) {
75
- const outputModule = options.experiments?.outputModule;
76
- options.output ??= {};
77
- options.output.filename = `bundle${index}${outputModule ? ".mjs" : ".js"}`;
78
- }
79
- if (options.cache === undefined)
80
- options.cache = false;
81
- if (!global.printLogger) {
82
- options.infrastructureLogging = {
83
- level: "error"
84
- };
85
- }
86
- }
87
- }
88
- exports.ConfigProcessor = ConfigProcessor;
@@ -1,30 +0,0 @@
1
- import type { ECompilerType, ITestContext, ITestEnv, TCompilerOptions } from "../type";
2
- import { SimpleTaskProcessor } from "./simple";
3
- declare class RspackTestDiff {
4
- value: string;
5
- constructor(value: string);
6
- }
7
- export interface IDefaultsConfigProcessorOptions<T extends ECompilerType> {
8
- options?: (context: ITestContext) => TCompilerOptions<T>;
9
- cwd?: string;
10
- name: string;
11
- diff: (diff: jest.JestMatchers<RspackTestDiff>, defaults: jest.JestMatchers<TCompilerOptions<T>>) => Promise<void>;
12
- compilerType: T;
13
- }
14
- export declare class DefaultsConfigProcessor<T extends ECompilerType> extends SimpleTaskProcessor<T> {
15
- protected _defaultsConfigOptions: IDefaultsConfigProcessorOptions<T>;
16
- private defaultConfig;
17
- constructor(_defaultsConfigOptions: IDefaultsConfigProcessorOptions<T>);
18
- compiler(context: ITestContext): Promise<void>;
19
- build(context: ITestContext): Promise<void>;
20
- run(env: ITestEnv, context: ITestContext): Promise<void>;
21
- check(env: ITestEnv, context: ITestContext): Promise<void>;
22
- before(context: ITestContext): Promise<void>;
23
- after(context: ITestContext): Promise<void>;
24
- beforeAll(context: ITestContext): Promise<void>;
25
- afterAll(context: ITestContext): Promise<void>;
26
- protected getCompiler(context: ITestContext): import("../type").ITestCompilerManager<T>;
27
- static getDefaultConfig(cwd: string, config: TCompilerOptions<ECompilerType>): TCompilerOptions<ECompilerType>;
28
- static overrideOptions<T extends ECompilerType>(options: TCompilerOptions<T>): void;
29
- }
30
- export {};
@@ -1,72 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DefaultsConfigProcessor = void 0;
4
- const node_util_1 = require("node:util");
5
- const jest_diff_1 = require("jest-diff");
6
- const simple_1 = require("./simple");
7
- const CURRENT_CWD = process.cwd();
8
- class RspackTestDiff {
9
- constructor(value) {
10
- this.value = value;
11
- }
12
- }
13
- class DefaultsConfigProcessor extends simple_1.SimpleTaskProcessor {
14
- constructor(_defaultsConfigOptions) {
15
- super({
16
- options: context => {
17
- let res;
18
- if (typeof _defaultsConfigOptions.options === "function") {
19
- res = _defaultsConfigOptions.options(context);
20
- }
21
- else {
22
- res = {};
23
- }
24
- if (!("mode" in res)) {
25
- res.mode = "none";
26
- }
27
- return res;
28
- },
29
- compilerType: _defaultsConfigOptions.compilerType,
30
- name: _defaultsConfigOptions.name
31
- });
32
- this._defaultsConfigOptions = _defaultsConfigOptions;
33
- this.defaultConfig = DefaultsConfigProcessor.getDefaultConfig(CURRENT_CWD, {
34
- mode: "none"
35
- });
36
- }
37
- async compiler(context) { }
38
- async build(context) { }
39
- async run(env, context) { }
40
- async check(env, context) {
41
- const compiler = this.getCompiler(context);
42
- const config = DefaultsConfigProcessor.getDefaultConfig(this._defaultsConfigOptions.cwd || CURRENT_CWD, compiler.getOptions());
43
- const diff = (0, node_util_1.stripVTControlCharacters)((0, jest_diff_1.diff)(this.defaultConfig, config, { expand: false, contextLines: 0 }));
44
- await this._defaultsConfigOptions.diff(env.expect(new RspackTestDiff(diff)), env.expect(this.defaultConfig));
45
- }
46
- async before(context) { }
47
- async after(context) { }
48
- async beforeAll(context) { }
49
- async afterAll(context) { }
50
- getCompiler(context) {
51
- return context.getCompiler(this._options.name, this._options.compilerType);
52
- }
53
- static getDefaultConfig(cwd, config) {
54
- process.chdir(cwd);
55
- const { applyWebpackOptionsDefaults, getNormalizedWebpackOptions } = require("@rspack/core").config;
56
- const normalizedConfig = getNormalizedWebpackOptions(config);
57
- applyWebpackOptionsDefaults(normalizedConfig);
58
- // make snapshot stable
59
- normalizedConfig.experiments.rspackFuture.bundlerInfo.version =
60
- "$version$";
61
- process.chdir(CURRENT_CWD);
62
- return normalizedConfig;
63
- }
64
- static overrideOptions(options) {
65
- if (!global.printLogger) {
66
- options.infrastructureLogging = {
67
- level: "error"
68
- };
69
- }
70
- }
71
- }
72
- exports.DefaultsConfigProcessor = DefaultsConfigProcessor;
@@ -1,15 +0,0 @@
1
- import type { ECompilerType, ITestContext, ITestEnv, TCompilerOptions } from "../type";
2
- import { BasicProcessor, type IBasicProcessorOptions } from "./basic";
3
- export interface IDiagnosticProcessorOptions<T extends ECompilerType> extends Omit<IBasicProcessorOptions<T>, "runable"> {
4
- snapshot: string;
5
- snapshotErrors: string;
6
- snapshotWarning: string;
7
- format?: (output: string) => string;
8
- }
9
- export declare class DiagnosticProcessor<T extends ECompilerType> extends BasicProcessor<T> {
10
- protected _diagnosticOptions: IDiagnosticProcessorOptions<T>;
11
- constructor(_diagnosticOptions: IDiagnosticProcessorOptions<T>);
12
- check(env: ITestEnv, context: ITestContext): Promise<void>;
13
- static defaultOptions<T extends ECompilerType>(context: ITestContext): TCompilerOptions<T>;
14
- static overrideOptions<T extends ECompilerType>(options: TCompilerOptions<T>): void;
15
- }
@@ -1,104 +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.DiagnosticProcessor = void 0;
7
- const node_assert_1 = __importDefault(require("node:assert"));
8
- const node_path_1 = __importDefault(require("node:path"));
9
- const placeholder_1 = require("../helper/expect/placeholder");
10
- const basic_1 = require("./basic");
11
- class DiagnosticProcessor extends basic_1.BasicProcessor {
12
- constructor(_diagnosticOptions) {
13
- super({
14
- defaultOptions: (DiagnosticProcessor.defaultOptions),
15
- runable: false,
16
- ..._diagnosticOptions
17
- });
18
- this._diagnosticOptions = _diagnosticOptions;
19
- }
20
- async check(env, context) {
21
- const compiler = this.getCompiler(context);
22
- const stats = compiler.getStats();
23
- if (!stats) {
24
- throw new Error("Stats should exists");
25
- }
26
- (0, node_assert_1.default)(stats.hasErrors() || stats.hasWarnings());
27
- let output = (0, placeholder_1.normalizePlaceholder)(stats.toString({
28
- all: false,
29
- errors: true,
30
- warnings: true
31
- })).replaceAll("\\", "/"); // stats has some win32 paths that path-serializer can not handle
32
- const statsJson = stats.toJson({
33
- all: false,
34
- errors: true,
35
- warnings: true
36
- });
37
- const errors = (statsJson.errors || []).map(e => {
38
- // @ts-expect-error error message is already serialized in `stats.err`
39
- delete e.message;
40
- delete e.stack;
41
- return e;
42
- });
43
- const warnings = (statsJson.warnings || []).map(e => {
44
- // @ts-expect-error error message is already serialized in `stats.err`
45
- delete e.message;
46
- delete e.stack;
47
- return e;
48
- });
49
- if (typeof this._diagnosticOptions.format === "function") {
50
- output = this._diagnosticOptions.format(output);
51
- }
52
- env.expect.addSnapshotSerializer({
53
- test(received) {
54
- return typeof received === "string";
55
- },
56
- serialize(received) {
57
- return (0, placeholder_1.normalizePlaceholder)(received.trim());
58
- }
59
- });
60
- const errorOutputPath = node_path_1.default.resolve(context.getSource(this._diagnosticOptions.snapshot));
61
- const errorStatsOutputPath = node_path_1.default.resolve(context.getSource(this._diagnosticOptions.snapshotErrors));
62
- const warningStatsOutputPath = node_path_1.default.resolve(context.getSource(this._diagnosticOptions.snapshotWarning));
63
- env.expect(output).toMatchFileSnapshot(errorOutputPath);
64
- env.expect(errors).toMatchFileSnapshot(errorStatsOutputPath);
65
- env.expect(warnings).toMatchFileSnapshot(warningStatsOutputPath);
66
- }
67
- static defaultOptions(context) {
68
- return {
69
- target: "node",
70
- context: context.getSource(),
71
- entry: {
72
- main: "./"
73
- },
74
- mode: "development",
75
- devServer: {
76
- hot: false
77
- },
78
- infrastructureLogging: {
79
- debug: false
80
- },
81
- output: {
82
- path: context.getDist()
83
- },
84
- experiments: {
85
- css: true,
86
- rspackFuture: {
87
- bundlerInfo: {
88
- force: false
89
- }
90
- },
91
- inlineConst: true,
92
- lazyBarrel: true
93
- }
94
- };
95
- }
96
- static overrideOptions(options) {
97
- if (!global.printLogger) {
98
- options.infrastructureLogging = {
99
- level: "error"
100
- };
101
- }
102
- }
103
- }
104
- exports.DiagnosticProcessor = DiagnosticProcessor;
@@ -1,23 +0,0 @@
1
- import type { StatsError } from "@rspack/core";
2
- import type { ECompilerType, ITestContext, ITestEnv, TCompiler, TCompilerOptions } from "../type";
3
- import { SimpleTaskProcessor } from "./simple";
4
- declare class RspackStatsDiagnostics {
5
- errors: StatsError[];
6
- warnings: StatsError[];
7
- constructor(errors: StatsError[], warnings: StatsError[]);
8
- }
9
- export interface IErrorProcessorOptions<T extends ECompilerType> {
10
- name: string;
11
- compilerType: T;
12
- options?: (options: TCompilerOptions<T>, context: ITestContext) => TCompilerOptions<T>;
13
- build?: (context: ITestContext, compiler: TCompiler<T>) => Promise<void>;
14
- check?: (stats: RspackStatsDiagnostics) => Promise<void>;
15
- }
16
- export declare class ErrorProcessor<T extends ECompilerType> extends SimpleTaskProcessor<T> {
17
- protected _errorOptions: IErrorProcessorOptions<T>;
18
- constructor(_errorOptions: IErrorProcessorOptions<T>);
19
- compiler(context: ITestContext): Promise<void>;
20
- run(env: ITestEnv, context: ITestContext): Promise<void>;
21
- check(env: ITestEnv, context: ITestContext): Promise<void>;
22
- }
23
- export {};
@@ -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,65 +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
- inlineConst: true,
50
- lazyBarrel: true
51
- }
52
- };
53
- }
54
- static overrideOptions(index, context, options) {
55
- if (!options.entry) {
56
- options.entry = "./index.js";
57
- }
58
- if (!global.printLogger) {
59
- options.infrastructureLogging = {
60
- level: "error"
61
- };
62
- }
63
- }
64
- }
65
- 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
- }