@rspack/test-tools 0.6.5 → 0.7.0-beta.0

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 (84) hide show
  1. package/dist/case/builtin.js +1 -1
  2. package/dist/case/compiler.js +1 -1
  3. package/dist/case/config.d.ts +2 -0
  4. package/dist/case/defaults.d.ts +5 -1
  5. package/dist/case/defaults.js +6 -3
  6. package/dist/case/diff.d.ts +2 -0
  7. package/dist/case/diff.js +2 -2
  8. package/dist/case/error.d.ts +1 -1
  9. package/dist/case/error.js +2 -2
  10. package/dist/case/hash.d.ts +2 -0
  11. package/dist/case/hook.d.ts +5 -0
  12. package/dist/case/hook.js +4 -3
  13. package/dist/case/hot-step.js +1 -1
  14. package/dist/case/hot.js +1 -1
  15. package/dist/case/index.d.ts +8 -8
  16. package/dist/case/index.js +8 -8
  17. package/dist/case/normal.js +1 -1
  18. package/dist/case/stats-api.d.ts +1 -1
  19. package/dist/case/stats-api.js +2 -2
  20. package/dist/case/treeshaking.js +2 -13
  21. package/dist/case/watch.js +1 -1
  22. package/dist/compare/comparator.js +2 -2
  23. package/dist/compare/compare.d.ts +1 -1
  24. package/dist/compare/compare.js +3 -3
  25. package/dist/compare/format-code.js +1 -1
  26. package/dist/compare/index.d.ts +3 -3
  27. package/dist/compare/index.js +3 -3
  28. package/dist/compiler.js +1 -1
  29. package/dist/helper/index.d.ts +2 -2
  30. package/dist/helper/index.js +2 -2
  31. package/dist/helper/legacy/createFakeWorker.js +0 -1
  32. package/dist/index.d.ts +8 -8
  33. package/dist/index.js +8 -8
  34. package/dist/processor/basic.js +2 -2
  35. package/dist/processor/builtin.js +4 -3
  36. package/dist/processor/config.js +3 -3
  37. package/dist/processor/defaults.d.ts +8 -2
  38. package/dist/processor/defaults.js +2 -2
  39. package/dist/processor/diagnostic.js +3 -3
  40. package/dist/processor/diff.d.ts +1 -1
  41. package/dist/processor/diff.js +1 -1
  42. package/dist/processor/error.d.ts +2 -2
  43. package/dist/processor/error.js +1 -1
  44. package/dist/processor/hook.d.ts +8 -6
  45. package/dist/processor/hook.js +18 -9
  46. package/dist/processor/hot-step.d.ts +2 -2
  47. package/dist/processor/hot-step.js +2 -2
  48. package/dist/processor/hot.js +2 -2
  49. package/dist/processor/index.d.ts +11 -11
  50. package/dist/processor/index.js +11 -11
  51. package/dist/processor/multi.js +1 -1
  52. package/dist/processor/normal.js +2 -2
  53. package/dist/processor/snapshot.d.ts +1 -1
  54. package/dist/processor/snapshot.js +3 -3
  55. package/dist/processor/stats-api.d.ts +2 -1
  56. package/dist/processor/stats-api.js +3 -2
  57. package/dist/processor/stats.js +4 -4
  58. package/dist/processor/treeshaking.d.ts +1 -2
  59. package/dist/processor/treeshaking.js +9 -21
  60. package/dist/processor/watch.js +5 -5
  61. package/dist/reporter/diff-stats.js +2 -2
  62. package/dist/reporter/index.d.ts +1 -1
  63. package/dist/reporter/index.js +1 -1
  64. package/dist/runner/basic.js +1 -1
  65. package/dist/runner/index.d.ts +2 -2
  66. package/dist/runner/index.js +2 -2
  67. package/dist/runner/runner/basic.js +1 -1
  68. package/dist/runner/runner/cjs.js +1 -1
  69. package/dist/runner/runner/esm.js +1 -1
  70. package/dist/runner/runner/normal.d.ts +1 -1
  71. package/dist/runner/runner/normal.js +1 -1
  72. package/dist/runner/runner/watch.d.ts +1 -1
  73. package/dist/runner/runner/web/fake.d.ts +1 -1
  74. package/dist/runner/runner/web/fake.js +5 -5
  75. package/dist/runner/runner/web/jsdom.d.ts +1 -1
  76. package/dist/runner/runner/web/jsdom.js +3 -3
  77. package/dist/runner/watch.js +1 -1
  78. package/dist/test/context.d.ts +1 -1
  79. package/dist/test/context.js +1 -1
  80. package/dist/test/creator.d.ts +1 -1
  81. package/dist/test/creator.js +1 -1
  82. package/dist/test/tester.d.ts +1 -1
  83. package/dist/type.d.ts +3 -3
  84. package/package.json +5 -5
@@ -4,9 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.createBuiltinCase = void 0;
7
+ const path_1 = __importDefault(require("path"));
7
8
  const processor_1 = require("../processor");
8
9
  const creator_1 = require("../test/creator");
9
- const path_1 = __importDefault(require("path"));
10
10
  const FILTERS = {
11
11
  "plugin-css": (file) => file.endsWith(".css"),
12
12
  "plugin-css-modules": (file) => file.endsWith(".css") ||
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createCompilerCase = void 0;
4
- const type_1 = require("../type");
5
4
  const processor_1 = require("../processor");
6
5
  const simple_1 = require("../test/simple");
6
+ const type_1 = require("../type");
7
7
  function createCompilerCase(name, src, dist, testConfig) {
8
8
  const caseConfig = require(testConfig);
9
9
  const runner = (0, simple_1.getSimpleProcessorRunner)(src, dist);
@@ -1 +1,3 @@
1
+ import { ECompilerType, TTestConfig } from "..";
2
+ export type TConfigCaseConfig = Omit<TTestConfig<ECompilerType.Rspack>, "validate">;
1
3
  export declare function createConfigCase(name: string, src: string, dist: string): void;
@@ -1 +1,5 @@
1
- export declare function createDefaultsCase(src: string): void;
1
+ import { IDefaultsConfigProcessorOptions } from "../processor";
2
+ export type TDefaultsCaseConfig = Omit<IDefaultsConfigProcessorOptions, "name"> & {
3
+ description: string;
4
+ };
5
+ export declare function createDefaultsCase(name: string, src: string): void;
@@ -4,9 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.createDefaultsCase = void 0;
7
- const context_1 = require("../test/context");
8
7
  const path_1 = __importDefault(require("path"));
9
8
  const processor_1 = require("../processor");
9
+ const context_1 = require("../test/context");
10
10
  const srcDir = path_1.default.resolve(__dirname, "../../tests/fixtures");
11
11
  const distDir = path_1.default.resolve(__dirname, "../../tests/js/defaults");
12
12
  const context = new context_1.TestContext({
@@ -27,10 +27,13 @@ async function run(name, processor) {
27
27
  await ((_d = processor.after) === null || _d === void 0 ? void 0 : _d.call(processor, context));
28
28
  }
29
29
  }
30
- function createDefaultsCase(src) {
30
+ function createDefaultsCase(name, src) {
31
31
  const caseConfig = require(src);
32
32
  it(`should generate the correct defaults from ${caseConfig.description}`, async () => {
33
- await run(caseConfig.name, new processor_1.DefaultsConfigTaskProcessor(caseConfig));
33
+ await run(name, new processor_1.DefaultsConfigTaskProcessor({
34
+ name,
35
+ ...caseConfig
36
+ }));
34
37
  });
35
38
  }
36
39
  exports.createDefaultsCase = createDefaultsCase;
@@ -1 +1,3 @@
1
+ import { IDiffProcessorOptions } from "../processor";
2
+ export type TDiffCaseConfig = IDiffProcessorOptions;
1
3
  export declare function createDiffCase(name: string, src: string, dist: string): void;
package/dist/case/diff.js CHANGED
@@ -4,13 +4,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.createDiffCase = void 0;
7
- const path_1 = __importDefault(require("path"));
8
7
  const fs_extra_1 = __importDefault(require("fs-extra"));
8
+ const path_1 = __importDefault(require("path"));
9
9
  const rimraf_1 = __importDefault(require("rimraf"));
10
10
  const createLazyTestEnv_1 = __importDefault(require("../helper/legacy/createLazyTestEnv"));
11
11
  const processor_1 = require("../processor");
12
- const type_1 = require("../type");
13
12
  const tester_1 = require("../test/tester");
13
+ const type_1 = require("../type");
14
14
  const DEFAULT_CASE_CONFIG = {
15
15
  webpackPath: require.resolve("webpack"),
16
16
  rspackPath: require.resolve("@rspack/core"),
@@ -1,5 +1,5 @@
1
- import { ECompilerType } from "../type";
2
1
  import { IErrorTaskProcessorOptions } from "../processor";
2
+ import { ECompilerType } from "../type";
3
3
  export type TErrorCaseConfig = Omit<IErrorTaskProcessorOptions<ECompilerType.Rspack>, "name" | "compilerType"> & {
4
4
  description: string;
5
5
  };
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createErrorCase = void 0;
4
- const type_1 = require("../type");
5
- const simple_1 = require("../test/simple");
6
4
  const processor_1 = require("../processor");
5
+ const simple_1 = require("../test/simple");
6
+ const type_1 = require("../type");
7
7
  let addedSerializer = false;
8
8
  function createErrorCase(name, src, dist, testConfig) {
9
9
  if (!addedSerializer) {
@@ -1 +1,3 @@
1
+ import { ECompilerType, TTestConfig } from "../type";
2
+ export type THashCaseConfig = Pick<TTestConfig<ECompilerType.Rspack>, "validate">;
1
3
  export declare function createHashCase(name: string, src: string, dist: string): void;
@@ -1 +1,6 @@
1
+ import { IHookProcessorOptions } from "../processor";
2
+ import { ECompilerType } from "../type";
3
+ export type THookCaseConfig = Omit<IHookProcessorOptions<ECompilerType.Rspack>, "name" | "compilerType" | "runable"> & {
4
+ description: string;
5
+ };
1
6
  export declare function createHookCase(name: string, src: string, dist: string, source: string): void;
package/dist/case/hook.js CHANGED
@@ -5,11 +5,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.createHookCase = void 0;
7
7
  const path_1 = __importDefault(require("path"));
8
- const simple_1 = require("../test/simple");
8
+ const createLazyTestEnv_1 = __importDefault(require("../helper/legacy/createLazyTestEnv"));
9
9
  const processor_1 = require("../processor");
10
10
  const runner_1 = require("../runner");
11
+ const simple_1 = require("../test/simple");
11
12
  const type_1 = require("../type");
12
- const createLazyTestEnv_1 = __importDefault(require("../helper/legacy/createLazyTestEnv"));
13
13
  function createHookCase(name, src, dist, source) {
14
14
  const caseConfig = require(path_1.default.join(src, "test.js"));
15
15
  const testName = path_1.default.basename(name.slice(0, name.indexOf(path_1.default.extname(name))));
@@ -25,10 +25,11 @@ function createHookCase(name, src, dist, source) {
25
25
  await runner(name, new processor_1.HookTaskProcessor({
26
26
  name,
27
27
  compilerType: type_1.ECompilerType.Rspack,
28
- findBundle: function (i, options) {
28
+ findBundle: function () {
29
29
  return ["main.js"];
30
30
  },
31
31
  snapshot: path_1.default.join(src, "output.snap.txt"),
32
+ runable: true,
32
33
  ...caseConfig
33
34
  }));
34
35
  });
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createHotStepCase = void 0;
4
4
  const hot_step_1 = require("../processor/hot-step");
5
- const creator_1 = require("../test/creator");
6
5
  const runner_1 = require("../runner");
6
+ const creator_1 = require("../test/creator");
7
7
  const creators = new Map();
8
8
  function getCreator(target) {
9
9
  if (!creators.has(target)) {
package/dist/case/hot.js CHANGED
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createHotCase = void 0;
4
4
  const hot_1 = require("../processor/hot");
5
- const creator_1 = require("../test/creator");
6
5
  const runner_1 = require("../runner");
6
+ const creator_1 = require("../test/creator");
7
7
  const creators = new Map();
8
8
  function getCreator(target) {
9
9
  if (!creators.has(target)) {
@@ -1,16 +1,16 @@
1
+ export * from "./builtin";
2
+ export * from "./compiler";
1
3
  export * from "./config";
4
+ export * from "./defaults";
2
5
  export * from "./diagnostic";
3
6
  export * from "./diff";
7
+ export * from "./error";
4
8
  export * from "./hash";
9
+ export * from "./hook";
5
10
  export * from "./hot";
11
+ export * from "./hot-step";
6
12
  export * from "./normal";
13
+ export * from "./stats-api";
7
14
  export * from "./stats-output";
8
- export * from "./watch";
9
15
  export * from "./treeshaking";
10
- export * from "./defaults";
11
- export * from "./builtin";
12
- export * from "./hot-step";
13
- export * from "./compiler";
14
- export * from "./stats-api";
15
- export * from "./error";
16
- export * from "./hook";
16
+ export * from "./watch";
@@ -14,19 +14,19 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./builtin"), exports);
18
+ __exportStar(require("./compiler"), exports);
17
19
  __exportStar(require("./config"), exports);
20
+ __exportStar(require("./defaults"), exports);
18
21
  __exportStar(require("./diagnostic"), exports);
19
22
  __exportStar(require("./diff"), exports);
23
+ __exportStar(require("./error"), exports);
20
24
  __exportStar(require("./hash"), exports);
25
+ __exportStar(require("./hook"), exports);
21
26
  __exportStar(require("./hot"), exports);
27
+ __exportStar(require("./hot-step"), exports);
22
28
  __exportStar(require("./normal"), exports);
29
+ __exportStar(require("./stats-api"), exports);
23
30
  __exportStar(require("./stats-output"), exports);
24
- __exportStar(require("./watch"), exports);
25
31
  __exportStar(require("./treeshaking"), exports);
26
- __exportStar(require("./defaults"), exports);
27
- __exportStar(require("./builtin"), exports);
28
- __exportStar(require("./hot-step"), exports);
29
- __exportStar(require("./compiler"), exports);
30
- __exportStar(require("./stats-api"), exports);
31
- __exportStar(require("./error"), exports);
32
- __exportStar(require("./hook"), exports);
32
+ __exportStar(require("./watch"), exports);
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.createNormalCase = void 0;
7
7
  const path_1 = __importDefault(require("path"));
8
8
  const normal_1 = require("../processor/normal");
9
- const creator_1 = require("../test/creator");
10
9
  const runner_1 = require("../runner");
10
+ const creator_1 = require("../test/creator");
11
11
  const creator = new creator_1.BasicCaseCreator({
12
12
  clean: true,
13
13
  describe: false,
@@ -1,5 +1,5 @@
1
- import { ECompilerType } from "../type";
2
1
  import { IStatsAPITaskProcessorOptions } from "../processor";
2
+ import { ECompilerType } from "../type";
3
3
  export type TStatsAPICaseConfig = Omit<IStatsAPITaskProcessorOptions<ECompilerType.Rspack>, "name" | "compilerType"> & {
4
4
  description: string;
5
5
  };
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createStatsAPICase = void 0;
4
- const type_1 = require("../type");
5
- const simple_1 = require("../test/simple");
6
4
  const processor_1 = require("../processor");
5
+ const simple_1 = require("../test/simple");
6
+ const type_1 = require("../type");
7
7
  let addedSerializer = false;
8
8
  function createStatsAPICase(name, src, dist, testConfig) {
9
9
  if (!addedSerializer) {
@@ -7,23 +7,12 @@ const creator = new creator_1.BasicCaseCreator({
7
7
  clean: true,
8
8
  describe: false,
9
9
  description(name, step) {
10
- if (step === 0) {
11
- return `${name} with builtin.treeShaking should match snapshot`;
12
- }
13
- else {
14
- return `${name} with newTreeshaking should match snapshot`;
15
- }
10
+ return `${name} with newTreeshaking should match snapshot`;
16
11
  },
17
12
  steps: ({ name }) => [
18
13
  new treeshaking_1.RspackTreeShakingProcessor({
19
14
  name,
20
- snapshot: "output.snap.txt",
21
- type: "builtin"
22
- }),
23
- new treeshaking_1.RspackTreeShakingProcessor({
24
- name,
25
- snapshot: "new_treeshaking.snap.txt",
26
- type: "new"
15
+ snapshot: "treeshaking.snap.txt"
27
16
  })
28
17
  ]
29
18
  });
@@ -7,8 +7,8 @@ exports.createWatchCase = void 0;
7
7
  const fs_1 = __importDefault(require("fs"));
8
8
  const path_1 = __importDefault(require("path"));
9
9
  const watch_1 = require("../processor/watch");
10
- const creator_1 = require("../test/creator");
11
10
  const runner_1 = require("../runner");
11
+ const creator_1 = require("../test/creator");
12
12
  const creator = new creator_1.BasicCaseCreator({
13
13
  clean: true,
14
14
  runner: runner_1.WatchRunnerFactory,
@@ -4,10 +4,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.DiffComparator = void 0;
7
+ const deepmerge_1 = __importDefault(require("deepmerge"));
8
+ const path_1 = __importDefault(require("path"));
7
9
  const compare_1 = require("./compare");
8
10
  const replace_runtime_module_name_1 = require("./replace-runtime-module-name");
9
- const path_1 = __importDefault(require("path"));
10
- const deepmerge_1 = __importDefault(require("deepmerge"));
11
11
  class DiffComparator {
12
12
  constructor(options) {
13
13
  this.options = options;
@@ -1,5 +1,5 @@
1
- import { IFormatCodeOptions } from "./format-code";
2
1
  import { TCompareModules, TCompareResult, TFileCompareResult, TModuleCompareResult } from "../type";
2
+ import { IFormatCodeOptions } from "./format-code";
3
3
  export interface ICompareOptions {
4
4
  modules?: TCompareModules;
5
5
  runtimeModules?: TCompareModules;
@@ -4,12 +4,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.compareContent = exports.compareModules = exports.compareFile = void 0;
7
+ const fs_extra_1 = __importDefault(require("fs-extra"));
7
8
  const jest_diff_1 = require("jest-diff");
8
- const format_code_1 = require("./format-code");
9
- const replace_runtime_module_name_1 = require("./replace-runtime-module-name");
10
9
  const helper_1 = require("../helper");
11
- const fs_extra_1 = __importDefault(require("fs-extra"));
12
10
  const type_1 = require("../type");
11
+ const format_code_1 = require("./format-code");
12
+ const replace_runtime_module_name_1 = require("./replace-runtime-module-name");
13
13
  function compareFile(sourceFile, distFile, compareOptions) {
14
14
  const result = {
15
15
  type: type_1.ECompareResultType.Same,
@@ -27,8 +27,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.formatCode = void 0;
30
- const parser_1 = require("@babel/parser");
31
30
  const generator_1 = __importDefault(require("@babel/generator"));
31
+ const parser_1 = require("@babel/parser");
32
32
  const traverse_1 = __importDefault(require("@babel/traverse"));
33
33
  const T = __importStar(require("@babel/types"));
34
34
  const replace_module_argument_1 = require("./replace-module-argument");
@@ -1,5 +1,5 @@
1
+ export * from "./comparator";
2
+ export * from "./compare";
3
+ export * from "./format-code";
1
4
  export * from "./replace-module-argument";
2
5
  export * from "./replace-runtime-module-name";
3
- export * from "./format-code";
4
- export * from "./compare";
5
- export * from "./comparator";
@@ -14,8 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./comparator"), exports);
18
+ __exportStar(require("./compare"), exports);
19
+ __exportStar(require("./format-code"), exports);
17
20
  __exportStar(require("./replace-module-argument"), exports);
18
21
  __exportStar(require("./replace-runtime-module-name"), exports);
19
- __exportStar(require("./format-code"), exports);
20
- __exportStar(require("./compare"), exports);
21
- __exportStar(require("./comparator"), exports);
package/dist/compiler.js CHANGED
@@ -5,8 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.TestCompilerManager = exports.COMPILER_FACTORIES = exports.ECompilerEvent = void 0;
7
7
  const events_1 = __importDefault(require("events"));
8
- const type_1 = require("./type");
9
8
  const webpack_merge_1 = __importDefault(require("webpack-merge"));
9
+ const type_1 = require("./type");
10
10
  var ECompilerEvent;
11
11
  (function (ECompilerEvent) {
12
12
  ECompilerEvent["Build"] = "build";
@@ -1,4 +1,4 @@
1
- export * from "./read-config-file";
2
- export * from "./parse-modules";
3
1
  export * from "./directory";
2
+ export * from "./parse-modules";
3
+ export * from "./read-config-file";
4
4
  export * from "./win";
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./read-config-file"), exports);
18
- __exportStar(require("./parse-modules"), exports);
19
17
  __exportStar(require("./directory"), exports);
18
+ __exportStar(require("./parse-modules"), exports);
19
+ __exportStar(require("./read-config-file"), exports);
20
20
  __exportStar(require("./win"), exports);
@@ -57,7 +57,6 @@ self.postMessage = data => {
57
57
  };
58
58
  require(${JSON.stringify(path.resolve(outputDirectory, file))});
59
59
  `;
60
- // eslint-disable-next-line n/no-unsupported-features/node-builtins
61
60
  this.worker = new (require("worker_threads").Worker)(workerBootstrap, {
62
61
  eval: true
63
62
  });
package/dist/index.d.ts CHANGED
@@ -1,11 +1,11 @@
1
- export * from "./type";
2
- export * from "./test/tester";
3
- export * from "./test/context";
4
- export * from "./test/simple";
5
- export * from "./processor";
6
- export * from "./reporter";
1
+ export * from "./case";
7
2
  export * from "./compare";
8
- export * from "./plugin";
9
3
  export * from "./helper";
4
+ export * from "./plugin";
5
+ export * from "./processor";
6
+ export * from "./reporter";
10
7
  export * from "./runner";
11
- export * from "./case";
8
+ export * from "./test/context";
9
+ export * from "./test/simple";
10
+ export * from "./test/tester";
11
+ export * from "./type";
package/dist/index.js CHANGED
@@ -14,14 +14,14 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./type"), exports);
18
- __exportStar(require("./test/tester"), exports);
19
- __exportStar(require("./test/context"), exports);
20
- __exportStar(require("./test/simple"), exports);
21
- __exportStar(require("./processor"), exports);
22
- __exportStar(require("./reporter"), exports);
17
+ __exportStar(require("./case"), exports);
23
18
  __exportStar(require("./compare"), exports);
24
- __exportStar(require("./plugin"), exports);
25
19
  __exportStar(require("./helper"), exports);
20
+ __exportStar(require("./plugin"), exports);
21
+ __exportStar(require("./processor"), exports);
22
+ __exportStar(require("./reporter"), exports);
26
23
  __exportStar(require("./runner"), exports);
27
- __exportStar(require("./case"), exports);
24
+ __exportStar(require("./test/context"), exports);
25
+ __exportStar(require("./test/simple"), exports);
26
+ __exportStar(require("./test/tester"), exports);
27
+ __exportStar(require("./type"), exports);
@@ -4,10 +4,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.BasicTaskProcessor = void 0;
7
- const helper_1 = require("../helper");
8
- const checkArrayExpectation_1 = __importDefault(require("../helper/legacy/checkArrayExpectation"));
9
7
  const fs_1 = __importDefault(require("fs"));
10
8
  const path_1 = __importDefault(require("path"));
9
+ const helper_1 = require("../helper");
10
+ const checkArrayExpectation_1 = __importDefault(require("../helper/legacy/checkArrayExpectation"));
11
11
  class BasicTaskProcessor {
12
12
  constructor(_options) {
13
13
  this._options = _options;
@@ -4,14 +4,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.RspackBuiltinProcessor = void 0;
7
- const type_1 = require("../type");
7
+ const core_1 = require("@rspack/core");
8
8
  const fs_extra_1 = __importDefault(require("fs-extra"));
9
9
  const webpack_merge_1 = require("webpack-merge");
10
- const core_1 = require("@rspack/core");
10
+ const type_1 = require("../type");
11
11
  const snapshot_1 = require("./snapshot");
12
12
  class RspackBuiltinProcessor extends snapshot_1.SnapshotProcessor {
13
13
  constructor(_builtinOptions) {
14
14
  super({
15
+ configFiles: ["rspack.config.js", "webpack.config.js"],
15
16
  snapshotFileFilter: _builtinOptions.snapshotFileFilter,
16
17
  snapshot: _builtinOptions.snapshot,
17
18
  compilerType: type_1.ECompilerType.Rspack,
@@ -128,7 +129,7 @@ class RspackBuiltinProcessor extends snapshot_1.SnapshotProcessor {
128
129
  treeShaking: false
129
130
  }
130
131
  };
131
- const testConfigFile = context.getSource("test.config.js");
132
+ const testConfigFile = context.getSource("rspack.config.js");
132
133
  if (fs_extra_1.default.existsSync(testConfigFile)) {
133
134
  let caseOptions = require(testConfigFile);
134
135
  if (caseOptions.entry) {
@@ -4,11 +4,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.RspackConfigProcessor = void 0;
7
- const type_1 = require("../type");
8
- const multi_1 = require("./multi");
9
- const path_1 = __importDefault(require("path"));
10
7
  const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
11
9
  const parseResource_1 = require("../helper/legacy/parseResource");
10
+ const type_1 = require("../type");
11
+ const multi_1 = require("./multi");
12
12
  class RspackConfigProcessor extends multi_1.MultiTaskProcessor {
13
13
  constructor(options) {
14
14
  super({
@@ -1,10 +1,15 @@
1
- import { SimpleTaskProcessor } from "./simple";
1
+ /// <reference types="jest" />
2
2
  import { ECompilerType, ITestContext, ITestEnv, TCompilerOptions } from "../type";
3
+ import { SimpleTaskProcessor } from "./simple";
4
+ declare class Diff {
5
+ value: string;
6
+ constructor(value: string);
7
+ }
3
8
  export interface IDefaultsConfigProcessorOptions {
4
9
  options?: (context: ITestContext) => TCompilerOptions<ECompilerType.Rspack>;
5
10
  cwd?: string;
6
11
  name: string;
7
- diff: (diff: any, defaults: any) => Promise<void>;
12
+ diff: (diff: jest.JestMatchers<Diff>, defaults: jest.JestMatchers<TCompilerOptions<ECompilerType.Rspack>>) => Promise<void>;
8
13
  }
9
14
  export declare class DefaultsConfigTaskProcessor extends SimpleTaskProcessor<ECompilerType.Rspack> {
10
15
  protected _defaultsConfigOptions: IDefaultsConfigProcessorOptions;
@@ -22,3 +27,4 @@ export declare class DefaultsConfigTaskProcessor extends SimpleTaskProcessor<ECo
22
27
  static getDefaultConfig(cwd: string, config: TCompilerOptions<ECompilerType.Rspack>): TCompilerOptions<ECompilerType.Rspack>;
23
28
  static addSnapshotSerializer(): void;
24
29
  }
30
+ export {};
@@ -4,10 +4,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.DefaultsConfigTaskProcessor = void 0;
7
- const simple_1 = require("./simple");
8
- const type_1 = require("../type");
9
7
  const jest_diff_1 = require("jest-diff");
10
8
  const strip_ansi_1 = __importDefault(require("strip-ansi"));
9
+ const type_1 = require("../type");
10
+ const simple_1 = require("./simple");
11
11
  const CURRENT_CWD = process.cwd();
12
12
  const quoteMeta = (str) => str.replace(/[-[\]\\/{}()*+?.^$|]/g, "\\$&");
13
13
  const cwdRegExp = new RegExp(`${quoteMeta(CURRENT_CWD)}((?:\\\\)?(?:[a-zA-Z.\\-_]+\\\\)*)`, "g");
@@ -4,12 +4,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.RspackDiagnosticProcessor = void 0;
7
- const type_1 = require("../type");
8
- const basic_1 = require("./basic");
9
7
  const assert_1 = __importDefault(require("assert"));
10
- const path_1 = __importDefault(require("path"));
11
8
  const fs_1 = __importDefault(require("fs"));
9
+ const path_1 = __importDefault(require("path"));
12
10
  const helper_1 = require("../helper");
11
+ const type_1 = require("../type");
12
+ const basic_1 = require("./basic");
13
13
  const serializer = require("jest-serializer-path");
14
14
  const normalizePaths = serializer.normalizePaths;
15
15
  const rspackPath = path_1.default.resolve(__dirname, "../../../rspack");
@@ -1,5 +1,5 @@
1
- import { ITestContext, ITestEnv, ITestProcessor, TCompareModules, TFileCompareResult, TModuleCompareResult } from "../type";
2
1
  import { IFormatCodeOptions } from "../compare";
2
+ import { ITestContext, ITestEnv, ITestProcessor, TCompareModules, TFileCompareResult, TModuleCompareResult } from "../type";
3
3
  export interface IDiffProcessorOptions extends IFormatCodeOptions {
4
4
  webpackPath: string;
5
5
  rspackPath: string;
@@ -4,10 +4,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.DiffProcessor = void 0;
7
- const type_1 = require("../type");
8
7
  const path_1 = __importDefault(require("path"));
9
8
  const compare_1 = require("../compare");
10
9
  const plugin_1 = require("../plugin");
10
+ const type_1 = require("../type");
11
11
  const basic_1 = require("./basic");
12
12
  class DiffProcessor {
13
13
  constructor(options) {
@@ -1,6 +1,6 @@
1
- import { SimpleTaskProcessor } from "./simple";
2
- import { ECompilerType, ITestContext, ITestEnv, TCompiler, TCompilerOptions } from "../type";
3
1
  import { StatsError, StatsWarnings } from "@rspack/core";
2
+ import { ECompilerType, ITestContext, ITestEnv, TCompiler, TCompilerOptions } from "../type";
3
+ import { SimpleTaskProcessor } from "./simple";
4
4
  type TStatsDiagnostics = {
5
5
  errors: StatsError[];
6
6
  warnings: StatsWarnings[];
@@ -4,10 +4,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.ErrorTaskProcessor = void 0;
7
- const simple_1 = require("./simple");
8
7
  const path_1 = __importDefault(require("path"));
9
8
  const pretty_format_1 = __importDefault(require("pretty-format"));
10
9
  const webpack_merge_1 = __importDefault(require("webpack-merge"));
10
+ const simple_1 = require("./simple");
11
11
  const CWD_PATTERN = new RegExp(path_1.default.join(process.cwd(), "../../").replace(/\\/g, "/"), "gm");
12
12
  const ERROR_STACK_PATTERN = /(?:\n\s+at\s.*)+/gm;
13
13
  function cleanError(err) {