@rspack/test-tools 1.5.6 → 1.5.8

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 (125) hide show
  1. package/dist/case/builtin.d.ts +2 -0
  2. package/dist/case/builtin.js +173 -13
  3. package/dist/case/cache.d.ts +1 -1
  4. package/dist/case/cache.js +210 -11
  5. package/dist/case/common.d.ts +10 -0
  6. package/dist/case/common.js +239 -0
  7. package/dist/case/compiler.d.ts +7 -4
  8. package/dist/case/compiler.js +144 -109
  9. package/dist/case/config.d.ts +5 -1
  10. package/dist/case/config.js +102 -16
  11. package/dist/case/defaults.d.ts +12 -4
  12. package/dist/case/defaults.js +67 -12
  13. package/dist/case/diagnostic.d.ts +6 -0
  14. package/dist/case/diagnostic.js +123 -14
  15. package/dist/case/diff.d.ts +17 -1
  16. package/dist/case/diff.js +170 -22
  17. package/dist/case/error.d.ts +14 -4
  18. package/dist/case/error.js +117 -10
  19. package/dist/case/esm-output.d.ts +1 -0
  20. package/dist/case/esm-output.js +96 -0
  21. package/dist/case/hash.d.ts +1 -1
  22. package/dist/case/hash.js +70 -9
  23. package/dist/case/hook.d.ts +35 -4
  24. package/dist/case/hook.js +210 -21
  25. package/dist/case/hot-step.js +307 -9
  26. package/dist/case/hot.d.ts +8 -1
  27. package/dist/case/hot.js +235 -8
  28. package/dist/case/incremental.d.ts +1 -1
  29. package/dist/case/incremental.js +39 -41
  30. package/dist/case/index.d.ts +21 -20
  31. package/dist/case/index.js +46 -34
  32. package/dist/case/native-watcher.js +10 -23
  33. package/dist/case/normal.js +174 -12
  34. package/dist/case/runner.d.ts +18 -0
  35. package/dist/case/runner.js +108 -0
  36. package/dist/case/serial.d.ts +1 -1
  37. package/dist/case/serial.js +8 -12
  38. package/dist/case/stats-api.d.ts +0 -5
  39. package/dist/case/stats-api.js +71 -10
  40. package/dist/case/stats-output.d.ts +10 -0
  41. package/dist/case/stats-output.js +198 -9
  42. package/dist/case/treeshaking.js +34 -7
  43. package/dist/case/watch.d.ts +27 -0
  44. package/dist/case/watch.js +321 -21
  45. package/dist/helper/plugins/hot-update.d.ts +2 -2
  46. package/dist/index.d.ts +0 -2
  47. package/dist/index.js +0 -2
  48. package/dist/runner/index.d.ts +2 -7
  49. package/dist/runner/index.js +2 -7
  50. package/dist/runner/{runner/node → node}/index.d.ts +1 -2
  51. package/dist/runner/{runner/node → node}/index.js +13 -9
  52. package/dist/runner/{runner/web → web}/fake.d.ts +1 -2
  53. package/dist/runner/{runner/web → web}/fake.js +7 -7
  54. package/dist/runner/{runner/web → web}/index.d.ts +2 -2
  55. package/dist/runner/{runner/web → web}/index.js +1 -1
  56. package/dist/runner/{runner/web → web}/jsdom.d.ts +1 -2
  57. package/dist/runner/{runner/web → web}/jsdom.js +4 -4
  58. package/dist/test/context.d.ts +3 -5
  59. package/dist/test/context.js +22 -12
  60. package/dist/test/creator.d.ts +13 -12
  61. package/dist/test/creator.js +52 -43
  62. package/dist/test/tester.js +4 -1
  63. package/dist/type.d.ts +42 -11
  64. package/dist/type.js +7 -1
  65. package/package.json +6 -6
  66. package/dist/processor/basic.d.ts +0 -24
  67. package/dist/processor/basic.js +0 -147
  68. package/dist/processor/builtin.d.ts +0 -9
  69. package/dist/processor/builtin.js +0 -171
  70. package/dist/processor/cache.d.ts +0 -20
  71. package/dist/processor/cache.js +0 -131
  72. package/dist/processor/config.d.ts +0 -11
  73. package/dist/processor/config.js +0 -88
  74. package/dist/processor/defaults.d.ts +0 -30
  75. package/dist/processor/defaults.js +0 -72
  76. package/dist/processor/diagnostic.d.ts +0 -15
  77. package/dist/processor/diagnostic.js +0 -104
  78. package/dist/processor/diff.d.ts +0 -30
  79. package/dist/processor/diff.js +0 -140
  80. package/dist/processor/error.d.ts +0 -23
  81. package/dist/processor/error.js +0 -95
  82. package/dist/processor/hash.d.ts +0 -10
  83. package/dist/processor/hash.js +0 -65
  84. package/dist/processor/hook.d.ts +0 -44
  85. package/dist/processor/hook.js +0 -206
  86. package/dist/processor/hot-incremental.d.ts +0 -14
  87. package/dist/processor/hot-incremental.js +0 -43
  88. package/dist/processor/hot-step.d.ts +0 -18
  89. package/dist/processor/hot-step.js +0 -307
  90. package/dist/processor/hot.d.ts +0 -17
  91. package/dist/processor/hot.js +0 -147
  92. package/dist/processor/index.d.ts +0 -20
  93. package/dist/processor/index.js +0 -36
  94. package/dist/processor/multi.d.ts +0 -17
  95. package/dist/processor/multi.js +0 -73
  96. package/dist/processor/normal.d.ts +0 -12
  97. package/dist/processor/normal.js +0 -170
  98. package/dist/processor/simple.d.ts +0 -24
  99. package/dist/processor/simple.js +0 -51
  100. package/dist/processor/snapshot.d.ts +0 -12
  101. package/dist/processor/snapshot.js +0 -66
  102. package/dist/processor/stats-api.d.ts +0 -18
  103. package/dist/processor/stats-api.js +0 -48
  104. package/dist/processor/stats.d.ts +0 -18
  105. package/dist/processor/stats.js +0 -206
  106. package/dist/processor/treeshaking.d.ts +0 -10
  107. package/dist/processor/treeshaking.js +0 -33
  108. package/dist/processor/watch.d.ts +0 -30
  109. package/dist/processor/watch.js +0 -252
  110. package/dist/runner/basic.d.ts +0 -10
  111. package/dist/runner/basic.js +0 -64
  112. package/dist/runner/cache.d.ts +0 -5
  113. package/dist/runner/cache.js +0 -92
  114. package/dist/runner/hot.d.ts +0 -5
  115. package/dist/runner/hot.js +0 -91
  116. package/dist/runner/multiple.d.ts +0 -11
  117. package/dist/runner/multiple.js +0 -52
  118. package/dist/runner/runner/index.d.ts +0 -2
  119. package/dist/runner/runner/index.js +0 -18
  120. package/dist/runner/type.d.ts +0 -42
  121. package/dist/runner/type.js +0 -9
  122. package/dist/runner/watch.d.ts +0 -7
  123. package/dist/runner/watch.js +0 -71
  124. package/dist/test/simple.d.ts +0 -5
  125. package/dist/test/simple.js +0 -43
@@ -1,42 +0,0 @@
1
- import type { ITestEnv } from "../type";
2
- export type TRunnerRequirer = (currentDirectory: string, modulePath: string[] | string, context?: {
3
- file?: TRunnerFile;
4
- esmMode?: EEsmMode;
5
- }) => Object | Promise<Object>;
6
- export type TRunnerFile = {
7
- path: string;
8
- content: string;
9
- subPath: string;
10
- };
11
- export declare enum EEsmMode {
12
- Unknown = 0,
13
- Evaluated = 1,
14
- Unlinked = 2
15
- }
16
- export interface IModuleScope extends ITestEnv {
17
- console: Record<string, (...args: any[]) => void>;
18
- expect: jest.Expect;
19
- [key: string]: any;
20
- }
21
- export interface IGlobalContext {
22
- console: Record<string, (...args: any[]) => void>;
23
- setTimeout: typeof setTimeout;
24
- clearTimeout: typeof clearTimeout;
25
- [key: string]: any;
26
- }
27
- export type TModuleObject = {
28
- exports: unknown;
29
- };
30
- export type THotStepRuntimeLangData = {
31
- outdatedModules: string[];
32
- outdatedDependencies: Record<string, string[]>;
33
- updatedModules: string[];
34
- updatedRuntime: string[];
35
- acceptedModules: string[];
36
- disposedModules: string[];
37
- };
38
- export type THotStepRuntimeData = {
39
- javascript: THotStepRuntimeLangData;
40
- css: THotStepRuntimeLangData;
41
- statusPath: string[];
42
- };
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EEsmMode = void 0;
4
- var EEsmMode;
5
- (function (EEsmMode) {
6
- EEsmMode[EEsmMode["Unknown"] = 0] = "Unknown";
7
- EEsmMode[EEsmMode["Evaluated"] = 1] = "Evaluated";
8
- EEsmMode[EEsmMode["Unlinked"] = 2] = "Unlinked";
9
- })(EEsmMode || (exports.EEsmMode = EEsmMode = {}));
@@ -1,7 +0,0 @@
1
- import { type ECompilerType, type ITestEnv, type ITestRunner, type TCompilerOptions, type TCompilerStatsCompilation } from "../type";
2
- import { BasicRunnerFactory } from "./basic";
3
- export declare class WatchRunnerFactory<T extends ECompilerType> extends BasicRunnerFactory<T> {
4
- protected getRunnerKey(file: string): string;
5
- protected createStatsGetter(): () => TCompilerStatsCompilation<T>;
6
- protected createRunner(file: string, stats: () => TCompilerStatsCompilation<T>, compilerOptions: TCompilerOptions<T>, env: ITestEnv): ITestRunner;
7
- }
@@ -1,71 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WatchRunnerFactory = void 0;
4
- const type_1 = require("../type");
5
- const basic_1 = require("./basic");
6
- const runner_1 = require("./runner");
7
- class WatchRunnerFactory extends basic_1.BasicRunnerFactory {
8
- getRunnerKey(file) {
9
- const stepName = this.context.getValue(this.name, "watchStepName");
10
- return `${this.name}-${stepName}`;
11
- }
12
- createStatsGetter() {
13
- const compiler = this.context.getCompiler(this.name);
14
- const stepName = this.context.getValue(this.name, "watchStepName");
15
- const statsGetter = (() => {
16
- const cached = {};
17
- return () => {
18
- if (cached[stepName]) {
19
- return cached[stepName];
20
- }
21
- cached[stepName] = compiler.getStats().toJson({
22
- errorDetails: true
23
- });
24
- return cached[stepName];
25
- };
26
- })();
27
- return statsGetter;
28
- }
29
- createRunner(file, stats, compilerOptions, env) {
30
- this.context.getCompiler(this.name);
31
- const stepName = this.context.getValue(this.name, "watchStepName");
32
- if (!stepName) {
33
- throw new Error("Can not get watch step name from context");
34
- }
35
- const state = this.context.getValue(this.name, "watchState");
36
- if (!state) {
37
- throw new Error("Can not get watch state from context");
38
- }
39
- const isWeb = Array.isArray(compilerOptions)
40
- ? compilerOptions.some(option => {
41
- return option.target === "web" || option.target === "webworker";
42
- })
43
- : compilerOptions.target === "web" ||
44
- compilerOptions.target === "webworker";
45
- const testConfig = this.context.getTestConfig();
46
- const documentType = this.context.getValue(this.name, "documentType") || type_1.EDocumentType.Fake;
47
- return new runner_1.WebRunner({
48
- dom: documentType,
49
- env,
50
- stats,
51
- name: this.name,
52
- runInNewContext: isWeb,
53
- cachable: false,
54
- testConfig: {
55
- ...(testConfig || {}),
56
- moduleScope: (ms, stats, options) => {
57
- ms.STATE = state;
58
- ms.WATCH_STEP = stepName;
59
- if (typeof testConfig.moduleScope === "function") {
60
- return testConfig.moduleScope(ms, stats, options);
61
- }
62
- return ms;
63
- }
64
- },
65
- source: this.context.getSource(),
66
- dist: this.context.getDist(),
67
- compilerOptions
68
- });
69
- }
70
- }
71
- exports.WatchRunnerFactory = WatchRunnerFactory;
@@ -1,5 +0,0 @@
1
- import type { ITestContext, ITestEnv, ITestProcessor } from "../type";
2
- export declare function getSimpleProcessorRunner(src: string, dist: string, options?: {
3
- env?: () => ITestEnv;
4
- context?: (src: string, dist: string) => ITestContext;
5
- }): (name: string, processor: ITestProcessor) => Promise<void>;
@@ -1,43 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getSimpleProcessorRunner = getSimpleProcessorRunner;
4
- const context_1 = require("./context");
5
- const CONTEXT_MAP = new Map();
6
- function getSimpleProcessorRunner(src, dist, options = {}) {
7
- const createEnv = options.env || (() => ({ expect, it, beforeEach, afterEach, jest }));
8
- const createContext = options.context ||
9
- ((src, dist) => new context_1.TestContext({ src, dist }));
10
- const key = `src: ${src}, dist: ${dist}`;
11
- if (!CONTEXT_MAP.has(key)) {
12
- const context = createContext(src, dist);
13
- const runner = async function run(name, processor) {
14
- try {
15
- await processor.beforeAll?.(context);
16
- await processor.before?.(context);
17
- await processor.config?.(context);
18
- await processor.compiler?.(context);
19
- await processor.build?.(context);
20
- }
21
- catch (e) {
22
- context.emitError(name, e);
23
- }
24
- finally {
25
- if (!context.hasError()) {
26
- await processor.run?.(createEnv(), context);
27
- }
28
- await processor.check?.(createEnv(), context);
29
- await processor.after?.(context);
30
- await processor.afterAll?.(context);
31
- }
32
- if (context.hasError()) {
33
- const errors = context
34
- .getError()
35
- .map(i => `${i.stack}`.split("\n").join("\t\n"))
36
- .join("\n\n");
37
- throw new Error(`Case "${name}" failed:\n${errors}`);
38
- }
39
- };
40
- CONTEXT_MAP.set(key, runner);
41
- }
42
- return CONTEXT_MAP.get(key);
43
- }