@rspack/test-tools 1.0.13 → 1.0.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.
Files changed (72) hide show
  1. package/dist/case/builtin.js +1 -2
  2. package/dist/case/compiler.js +1 -2
  3. package/dist/case/config.js +1 -2
  4. package/dist/case/defaults.js +1 -2
  5. package/dist/case/diagnostic.js +1 -2
  6. package/dist/case/diff.js +1 -2
  7. package/dist/case/error.js +1 -3
  8. package/dist/case/hash.js +1 -2
  9. package/dist/case/hook.js +1 -2
  10. package/dist/case/hot-step.js +1 -2
  11. package/dist/case/hot.js +1 -2
  12. package/dist/case/new-incremental.js +3 -12
  13. package/dist/case/normal.js +2 -3
  14. package/dist/case/stats-api.js +1 -3
  15. package/dist/case/stats-output.js +1 -2
  16. package/dist/case/treeshaking.js +1 -2
  17. package/dist/case/watch.js +1 -2
  18. package/dist/compare/compare.js +3 -4
  19. package/dist/compare/format-code.js +1 -2
  20. package/dist/compare/replace-module-argument.js +1 -2
  21. package/dist/compare/replace-runtime-module-name.js +2 -3
  22. package/dist/compiler.d.ts +0 -1
  23. package/dist/compiler.js +1 -1
  24. package/dist/helper/directory.d.ts +0 -1
  25. package/dist/helper/directory.js +2 -2
  26. package/dist/helper/expect/char.d.ts +4 -0
  27. package/dist/helper/expect/char.js +25 -0
  28. package/dist/helper/expect/diff.d.ts +3 -0
  29. package/dist/helper/expect/diff.js +21 -0
  30. package/dist/helper/expect/error.d.ts +5 -0
  31. package/dist/helper/expect/error.js +51 -0
  32. package/dist/helper/expect/placeholder.d.ts +1 -0
  33. package/dist/helper/expect/placeholder.js +34 -0
  34. package/dist/helper/expect/rspack.d.ts +3 -0
  35. package/dist/helper/expect/rspack.js +14 -0
  36. package/dist/helper/expect/to-be-typeof.js +1 -2
  37. package/dist/helper/expect/to-end-with.js +1 -2
  38. package/dist/helper/expect/to-match-file-snapshot.d.ts +0 -1
  39. package/dist/helper/expect/to-match-file-snapshot.js +1 -2
  40. package/dist/helper/legacy/EventSourceForNode.d.ts +2 -3
  41. package/dist/helper/legacy/FakeDocument.d.ts +2 -2
  42. package/dist/helper/legacy/asModule.d.ts +0 -1
  43. package/dist/helper/legacy/createFakeWorker.d.ts +0 -1
  44. package/dist/helper/legacy/fakeSystem.d.ts +3 -3
  45. package/dist/helper/legacy/walkCssTokens.d.ts +5 -3
  46. package/dist/helper/parse-modules.js +1 -2
  47. package/dist/helper/read-config-file.js +1 -2
  48. package/dist/helper/replace-paths.js +1 -2
  49. package/dist/helper/setup-env.d.ts +1 -0
  50. package/dist/helper/setup-env.js +1 -0
  51. package/dist/helper/setup-expect.js +58 -1
  52. package/dist/helper/update-snapshot.js +1 -2
  53. package/dist/helper/util/checkSourceMap.js +1 -1
  54. package/dist/helper/util/filterUtil.d.ts +4 -4
  55. package/dist/helper/util/identifier.d.ts +9 -9
  56. package/dist/helper/win.js +2 -3
  57. package/dist/processor/defaults.d.ts +2 -5
  58. package/dist/processor/defaults.js +2 -36
  59. package/dist/processor/error.d.ts +4 -6
  60. package/dist/processor/error.js +5 -66
  61. package/dist/processor/hook.d.ts +0 -1
  62. package/dist/processor/hot-new-incremental.js +1 -9
  63. package/dist/processor/stats-api.d.ts +0 -3
  64. package/dist/processor/stats-api.js +0 -4
  65. package/dist/processor/stats.js +7 -28
  66. package/dist/processor/watch.js +39 -1
  67. package/dist/runner/type.d.ts +0 -2
  68. package/dist/runner/type.js +1 -1
  69. package/dist/test/simple.js +1 -2
  70. package/dist/type.d.ts +0 -3
  71. package/dist/type.js +3 -3
  72. package/package.json +5 -4
@@ -9,6 +9,7 @@ const node_path_1 = __importDefault(require("node:path"));
9
9
  const webpack_merge_1 = require("webpack-merge");
10
10
  const compiler_1 = require("../compiler");
11
11
  const helper_1 = require("../helper");
12
+ const checkArrayExpectation_1 = __importDefault(require("../helper/legacy/checkArrayExpectation"));
12
13
  const copyDiff_1 = __importDefault(require("../helper/legacy/copyDiff"));
13
14
  const multi_1 = require("./multi");
14
15
  // This file is used to port step number to rspack.config.js/webpack.config.js
@@ -52,7 +53,44 @@ class WatchProcessor extends multi_1.MultiTaskProcessor {
52
53
  await super.run(env, context);
53
54
  }
54
55
  async check(env, context) {
55
- await super.check(env, context);
56
+ const testConfig = context.getTestConfig();
57
+ if (testConfig.noTest)
58
+ return;
59
+ const errors = (context.getError(this._options.name) || []).map(e => ({
60
+ message: e.message,
61
+ stack: e.stack
62
+ }));
63
+ const warnings = [];
64
+ const compiler = this.getCompiler(context);
65
+ const stats = compiler.getStats();
66
+ if (stats) {
67
+ node_fs_1.default.writeFileSync(node_path_1.default.join(context.getDist(), "stats.txt"), stats.toString({
68
+ preset: "verbose",
69
+ colors: false
70
+ }), "utf-8");
71
+ const jsonStats = stats.toJson({
72
+ errorDetails: true
73
+ });
74
+ node_fs_1.default.writeFileSync(node_path_1.default.join(context.getDist(), "stats.json"), JSON.stringify(jsonStats, null, 2), "utf-8");
75
+ if (jsonStats.errors) {
76
+ errors.push(...jsonStats.errors);
77
+ }
78
+ if (jsonStats.warnings) {
79
+ warnings.push(...jsonStats.warnings);
80
+ }
81
+ }
82
+ await new Promise((resolve, reject) => {
83
+ (0, checkArrayExpectation_1.default)(node_path_1.default.join(context.getSource(), this._watchOptions.stepName), { errors }, "error", "Error", reject);
84
+ resolve();
85
+ });
86
+ await new Promise((resolve, reject) => {
87
+ (0, checkArrayExpectation_1.default)(node_path_1.default.join(context.getSource(), this._watchOptions.stepName), { warnings }, "warning", "Warning", reject);
88
+ resolve();
89
+ });
90
+ // clear error if checked
91
+ if (node_fs_1.default.existsSync(context.getSource("errors.js"))) {
92
+ context.clearError(this._options.name);
93
+ }
56
94
  // check hash
57
95
  node_fs_1.default.renameSync(node_path_1.default.join(context.getDist(), "stats.txt"), node_path_1.default.join(context.getDist(), `stats.${this._watchOptions.stepName}.txt`));
58
96
  node_fs_1.default.renameSync(node_path_1.default.join(context.getDist(), "stats.json"), node_path_1.default.join(context.getDist(), `stats.${this._watchOptions.stepName}.json`));
@@ -1,5 +1,3 @@
1
- /// <reference types="jest" />
2
- /// <reference types="../jest.d.ts" />
3
1
  import type { ITestEnv } from "../type";
4
2
  export type TRunnerRequirer = (currentDirectory: string, modulePath: string[] | string, context?: {
5
3
  file?: TBasicRunnerFile;
@@ -6,4 +6,4 @@ var EEsmMode;
6
6
  EEsmMode[EEsmMode["Unknown"] = 0] = "Unknown";
7
7
  EEsmMode[EEsmMode["Evaluated"] = 1] = "Evaluated";
8
8
  EEsmMode[EEsmMode["Unlinked"] = 2] = "Unlinked";
9
- })(EEsmMode = exports.EEsmMode || (exports.EEsmMode = {}));
9
+ })(EEsmMode || (exports.EEsmMode = EEsmMode = {}));
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getSimpleProcessorRunner = void 0;
3
+ exports.getSimpleProcessorRunner = getSimpleProcessorRunner;
4
4
  const context_1 = require("./context");
5
5
  const CONTEXT_MAP = new Map();
6
6
  function getSimpleProcessorRunner(src, dist, options = {}) {
@@ -41,4 +41,3 @@ function getSimpleProcessorRunner(src, dist, options = {}) {
41
41
  }
42
42
  return CONTEXT_MAP.get(key);
43
43
  }
44
- exports.getSimpleProcessorRunner = getSimpleProcessorRunner;
package/dist/type.d.ts CHANGED
@@ -1,6 +1,3 @@
1
- /// <reference types="node" />
2
- /// <reference types="jest" />
3
- /// <reference types="../jest.d.ts" />
4
1
  import type EventEmitter from "node:events";
5
2
  import type { Compiler as RspackCompiler, RspackOptions, Stats as RspackStats, StatsCompilation as RspackStatsCompilation } from "@rspack/core";
6
3
  import type { Compiler as WebpackCompiler, Configuration as WebpackOptions, Stats as WebpackStats, StatsCompilation as WebpackStatsCompilation } from "webpack";
package/dist/type.js CHANGED
@@ -6,7 +6,7 @@ var ECompilerType;
6
6
  (function (ECompilerType) {
7
7
  ECompilerType["Rspack"] = "rspack";
8
8
  ECompilerType["Webpack"] = "webpack";
9
- })(ECompilerType = exports.ECompilerType || (exports.ECompilerType = {}));
9
+ })(ECompilerType || (exports.ECompilerType = ECompilerType = {}));
10
10
  var ECompareResultType;
11
11
  (function (ECompareResultType) {
12
12
  ECompareResultType["Same"] = "same";
@@ -14,9 +14,9 @@ var ECompareResultType;
14
14
  ECompareResultType["OnlyDist"] = "only-dist";
15
15
  ECompareResultType["OnlySource"] = "only-source";
16
16
  ECompareResultType["Different"] = "different";
17
- })(ECompareResultType = exports.ECompareResultType || (exports.ECompareResultType = {}));
17
+ })(ECompareResultType || (exports.ECompareResultType = ECompareResultType = {}));
18
18
  var EDocumentType;
19
19
  (function (EDocumentType) {
20
20
  EDocumentType["Fake"] = "fake";
21
21
  EDocumentType["JSDOM"] = "jsdom";
22
- })(EDocumentType = exports.EDocumentType || (exports.EDocumentType = {}));
22
+ })(EDocumentType || (exports.EDocumentType = EDocumentType = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspack/test-tools",
3
- "version": "1.0.13",
3
+ "version": "1.0.14",
4
4
  "license": "MIT",
5
5
  "description": "Test tools for rspack",
6
6
  "main": "dist/index.js",
@@ -48,6 +48,7 @@
48
48
  "jsdom": "^25.0.0",
49
49
  "memfs": "4.8.1",
50
50
  "mkdirp": "0.5.6",
51
+ "path-serializer": "0.1.2",
51
52
  "pretty-format": "29.7.0",
52
53
  "rimraf": "3.0.2",
53
54
  "strip-ansi": "6.0.1",
@@ -99,10 +100,10 @@
99
100
  "source-map-loader": "^5.0.0",
100
101
  "style-loader": "^4.0.0",
101
102
  "terser": "5.27.2",
102
- "typescript": "5.0.2",
103
+ "typescript": "^5.6.3",
103
104
  "wast-loader": "^1.12.1",
104
- "@rspack/core": "1.0.13",
105
- "@rspack/cli": "1.0.13"
105
+ "@rspack/cli": "1.0.14",
106
+ "@rspack/core": "1.0.14"
106
107
  },
107
108
  "peerDependencies": {
108
109
  "@rspack/core": ">=0.7.0"