@rspack-canary/test-tools 1.5.9-canary-ec64d52e-20251008173631 → 1.5.9-canary-39ce7fc0-20251009174151

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.
@@ -0,0 +1 @@
1
+ export declare function createExampleCase(name: string, src: string): void;
@@ -0,0 +1,57 @@
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.createExampleCase = createExampleCase;
7
+ const node_path_1 = __importDefault(require("node:path"));
8
+ const creator_1 = require("../test/creator");
9
+ const common_1 = require("./common");
10
+ function overrideOptions(index, context, options) {
11
+ options.context = context.getSource();
12
+ options.output = options.output || {};
13
+ options.output.pathinfo = true;
14
+ options.output.path = context.getDist();
15
+ options.output.publicPath = "dist/";
16
+ if (!options.entry)
17
+ options.entry = "./example.js";
18
+ if (!options.plugins)
19
+ options.plugins = [];
20
+ }
21
+ function createExampleProcessor(name) {
22
+ return {
23
+ config: async (context) => {
24
+ (0, common_1.configMultiCompiler)(context, name, ["rspack.config.js", "webpack.config.js"], () => ({}), overrideOptions);
25
+ },
26
+ compiler: async (context) => {
27
+ await (0, common_1.compiler)(context, name);
28
+ },
29
+ build: async (context) => {
30
+ await (0, common_1.build)(context, name);
31
+ },
32
+ run: async (env, context) => {
33
+ // no need to run, just check the building
34
+ },
35
+ check: async (env, context) => {
36
+ const compiler = (0, common_1.getCompiler)(context, name);
37
+ const stats = compiler.getStats();
38
+ if (stats?.hasErrors()) {
39
+ console.log(stats.toString({
40
+ all: false,
41
+ errors: true,
42
+ errorDetails: true,
43
+ errorStacks: true
44
+ }));
45
+ }
46
+ expect(stats?.hasErrors()).toBe(false);
47
+ }
48
+ };
49
+ }
50
+ const creator = new creator_1.BasicCaseCreator({
51
+ clean: true,
52
+ steps: ({ name }) => [createExampleProcessor(name)],
53
+ concurrent: true
54
+ });
55
+ function createExampleCase(name, src) {
56
+ creator.create(name, src, node_path_1.default.join(src, "dist"));
57
+ }
@@ -79,12 +79,10 @@ function getWatchCreator(options) {
79
79
  .map(name => ({ name }));
80
80
  return runs.map((run, index) => index === 0
81
81
  ? (0, watch_1.createWatchInitialProcessor)(name, temp, run.name, watchState, {
82
- incremental: true,
83
- ignoreNotFriendlyForIncrementalWarnings: options.ignoreNotFriendlyForIncrementalWarnings
82
+ incremental: true
84
83
  })
85
84
  : (0, watch_1.createWatchStepProcessor)(name, temp, run.name, watchState, {
86
- incremental: true,
87
- ignoreNotFriendlyForIncrementalWarnings: options.ignoreNotFriendlyForIncrementalWarnings
85
+ incremental: true
88
86
  }));
89
87
  },
90
88
  concurrent: true
@@ -7,6 +7,7 @@ export { createDiagnosticCase } from "./diagnostic";
7
7
  export { createDiffCase } from "./diff";
8
8
  export { createErrorCase } from "./error";
9
9
  export { createEsmOutputCase } from "./esm-output";
10
+ export { createExampleCase } from "./example";
10
11
  export { createHashCase } from "./hash";
11
12
  export { createHookCase } from "./hook";
12
13
  export { createHotCase } from "./hot";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createWatchCase = exports.createTreeShakingCase = exports.createStatsOutputCase = exports.createStatsAPICase = exports.createSerialCase = exports.createNormalCase = exports.createHotNormalCase = exports.createNativeWatcher = exports.createMultiCompilerCase = exports.createWatchIncrementalCase = exports.createHotIncrementalCase = exports.createHotStepCase = exports.createHotCase = exports.createHookCase = exports.createHashCase = exports.createEsmOutputCase = exports.createErrorCase = exports.createDiffCase = exports.createDiagnosticCase = exports.getRspackDefaultConfig = exports.createDefaultsCase = exports.createConfigCase = exports.createCompilerCase = exports.createCacheCase = exports.createBuiltinCase = void 0;
3
+ exports.createWatchCase = exports.createTreeShakingCase = exports.createStatsOutputCase = exports.createStatsAPICase = exports.createSerialCase = exports.createNormalCase = exports.createHotNormalCase = exports.createNativeWatcher = exports.createMultiCompilerCase = exports.createWatchIncrementalCase = exports.createHotIncrementalCase = exports.createHotStepCase = exports.createHotCase = exports.createHookCase = exports.createHashCase = exports.createExampleCase = exports.createEsmOutputCase = exports.createErrorCase = exports.createDiffCase = exports.createDiagnosticCase = exports.getRspackDefaultConfig = exports.createDefaultsCase = exports.createConfigCase = exports.createCompilerCase = exports.createCacheCase = exports.createBuiltinCase = void 0;
4
4
  var builtin_1 = require("./builtin");
5
5
  Object.defineProperty(exports, "createBuiltinCase", { enumerable: true, get: function () { return builtin_1.createBuiltinCase; } });
6
6
  var cache_1 = require("./cache");
@@ -20,6 +20,8 @@ var error_1 = require("./error");
20
20
  Object.defineProperty(exports, "createErrorCase", { enumerable: true, get: function () { return error_1.createErrorCase; } });
21
21
  var esm_output_1 = require("./esm-output");
22
22
  Object.defineProperty(exports, "createEsmOutputCase", { enumerable: true, get: function () { return esm_output_1.createEsmOutputCase; } });
23
+ var example_1 = require("./example");
24
+ Object.defineProperty(exports, "createExampleCase", { enumerable: true, get: function () { return example_1.createExampleCase; } });
23
25
  var hash_1 = require("./hash");
24
26
  Object.defineProperty(exports, "createHashCase", { enumerable: true, get: function () { return hash_1.createHashCase; } });
25
27
  var hook_1 = require("./hook");
@@ -1,8 +1,7 @@
1
1
  import { type ECompilerType, type ITestContext, type ITestEnv, type ITestRunner } from "../type";
2
- export declare function createWatchInitialProcessor(name: string, tempDir: string, step: string, watchState: Record<string, any>, { incremental, nativeWatcher, ignoreNotFriendlyForIncrementalWarnings }?: {
2
+ export declare function createWatchInitialProcessor(name: string, tempDir: string, step: string, watchState: Record<string, any>, { incremental, nativeWatcher }?: {
3
3
  incremental?: boolean | undefined;
4
4
  nativeWatcher?: boolean | undefined;
5
- ignoreNotFriendlyForIncrementalWarnings?: boolean | undefined;
6
5
  }): {
7
6
  before: (context: ITestContext) => Promise<void>;
8
7
  config: <T extends ECompilerType.Rspack>(context: ITestContext) => Promise<void>;
@@ -11,10 +10,9 @@ export declare function createWatchInitialProcessor(name: string, tempDir: strin
11
10
  run: (env: ITestEnv, context: ITestContext) => Promise<void>;
12
11
  check: <T extends ECompilerType.Rspack>(env: ITestEnv, context: ITestContext) => Promise<void>;
13
12
  };
14
- export declare function createWatchStepProcessor(name: string, tempDir: string, step: string, watchState: Record<string, any>, { incremental, nativeWatcher, ignoreNotFriendlyForIncrementalWarnings }?: {
13
+ export declare function createWatchStepProcessor(name: string, tempDir: string, step: string, watchState: Record<string, any>, { incremental, nativeWatcher }?: {
15
14
  incremental?: boolean | undefined;
16
15
  nativeWatcher?: boolean | undefined;
17
- ignoreNotFriendlyForIncrementalWarnings?: boolean | undefined;
18
16
  }): {
19
17
  before: (context: ITestContext) => Promise<void>;
20
18
  config: <T extends ECompilerType.Rspack>(context: ITestContext) => Promise<void>;
@@ -21,7 +21,7 @@ const type_1 = require("../type");
21
21
  const common_1 = require("./common");
22
22
  // This file is used to port step number to rspack.config.js/webpack.config.js
23
23
  const currentWatchStepModulePath = node_path_1.default.resolve(__dirname, "../helper/util/currentWatchStep");
24
- function createWatchInitialProcessor(name, tempDir, step, watchState, { incremental = false, nativeWatcher = false, ignoreNotFriendlyForIncrementalWarnings = false } = {}) {
24
+ function createWatchInitialProcessor(name, tempDir, step, watchState, { incremental = false, nativeWatcher = false } = {}) {
25
25
  const watchContext = {
26
26
  currentTriggerFilename: null,
27
27
  lastHash: null,
@@ -35,12 +35,13 @@ function createWatchInitialProcessor(name, tempDir, step, watchState, { incremen
35
35
  context.setValue(name, "watchContext", watchContext);
36
36
  },
37
37
  config: async (context) => {
38
+ const testConfig = context.getTestConfig();
38
39
  const multiCompilerOptions = [];
39
40
  const caseOptions = (0, helper_1.readConfigFile)(["rspack.config.js", "webpack.config.js"].map(i => context.getSource(i)));
40
41
  for (const [index, options] of caseOptions.entries()) {
41
42
  const compilerOptions = (0, webpack_merge_1.default)(defaultOptions({
42
43
  incremental,
43
- ignoreNotFriendlyForIncrementalWarnings
44
+ ignoreNotFriendlyForIncrementalWarnings: testConfig.ignoreNotFriendlyForIncrementalWarnings
44
45
  }), options);
45
46
  overrideOptions(index, context, compilerOptions, tempDir, nativeWatcher);
46
47
  multiCompilerOptions.push(compilerOptions);
@@ -164,8 +165,8 @@ function createWatchInitialProcessor(name, tempDir, step, watchState, { incremen
164
165
  }
165
166
  };
166
167
  }
167
- function createWatchStepProcessor(name, tempDir, step, watchState, { incremental = false, nativeWatcher = false, ignoreNotFriendlyForIncrementalWarnings = false } = {}) {
168
- const processor = createWatchInitialProcessor(name, tempDir, step, watchState, { incremental, ignoreNotFriendlyForIncrementalWarnings });
168
+ function createWatchStepProcessor(name, tempDir, step, watchState, { incremental = false, nativeWatcher = false } = {}) {
169
+ const processor = createWatchInitialProcessor(name, tempDir, step, watchState, { incremental });
169
170
  processor.compiler = async (context) => {
170
171
  // do nothing
171
172
  };
@@ -101,7 +101,7 @@ class BasicCaseCreator {
101
101
  stepSignal.then((e) => {
102
102
  cb(e);
103
103
  });
104
- }, options.timeout || 180000);
104
+ }, options.timeout || 300000);
105
105
  chain = chain.then(async () => {
106
106
  try {
107
107
  env.clear();
@@ -170,7 +170,7 @@ class BasicCaseCreator {
170
170
  .join("\n\n");
171
171
  throw new Error(`Case "${name}" failed at step ${tester.step + 1}:\n${errors}`);
172
172
  }
173
- }, options.timeout || 30000);
173
+ }, options.timeout || 60000);
174
174
  const env = this.createEnv(testConfig, options);
175
175
  }
176
176
  afterAll(async () => {
@@ -98,7 +98,8 @@ class Tester {
98
98
  }
99
99
  }
100
100
  catch (e) {
101
- console.error(e);
101
+ const errors = this.context.getError(this.config.name);
102
+ console.error(new Error([...errors, e].map(e => e.message).join("\n")));
102
103
  throw e;
103
104
  }
104
105
  }
package/dist/type.d.ts CHANGED
@@ -151,6 +151,7 @@ export type TTestConfig<T extends ECompilerType> = {
151
151
  concurrent?: boolean;
152
152
  snapshotContent?(content: string): string;
153
153
  checkSteps?: boolean;
154
+ ignoreNotFriendlyForIncrementalWarnings?: boolean;
154
155
  };
155
156
  export type TTestFilter<T extends ECompilerType> = (creatorConfig: Record<string, unknown>, testConfig: TTestConfig<T>) => boolean | string;
156
157
  export interface ITestRunner {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspack-canary/test-tools",
3
- "version": "1.5.9-canary-ec64d52e-20251008173631",
3
+ "version": "1.5.9-canary-39ce7fc0-20251009174151",
4
4
  "license": "MIT",
5
5
  "description": "Test tools for rspack",
6
6
  "main": "dist/index.js",
@@ -100,10 +100,10 @@
100
100
  "wast-loader": "^1.14.1",
101
101
  "worker-rspack-loader": "^3.1.2",
102
102
  "exports-loader": "^5.0.0",
103
- "@rspack/cli": "npm:@rspack-canary/cli@1.5.9-canary-ec64d52e-20251008173631",
104
- "@rspack/core": "npm:@rspack-canary/core@1.5.9-canary-ec64d52e-20251008173631",
105
- "@rspack/test-tools": "npm:@rspack-canary/test-tools@1.5.9-canary-ec64d52e-20251008173631",
106
- "@rspack/binding-testing": "1.4.1"
103
+ "@rspack/cli": "npm:@rspack-canary/cli@1.5.9-canary-39ce7fc0-20251009174151",
104
+ "@rspack/core": "npm:@rspack-canary/core@1.5.9-canary-39ce7fc0-20251009174151",
105
+ "@rspack/binding-testing": "1.4.1",
106
+ "@rspack/test-tools": "npm:@rspack-canary/test-tools@1.5.9-canary-39ce7fc0-20251009174151"
107
107
  },
108
108
  "peerDependencies": {
109
109
  "@rspack/core": ">=1.0.0"