@rspack/test-tools 1.7.0-beta.1 → 1.7.1

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 (117) hide show
  1. package/dist/case/builtin.d.ts +2 -2
  2. package/dist/case/builtin.js +58 -58
  3. package/dist/case/cache.d.ts +2 -2
  4. package/dist/case/cache.js +34 -34
  5. package/dist/case/common.d.ts +2 -2
  6. package/dist/case/common.js +45 -45
  7. package/dist/case/compiler.d.ts +3 -3
  8. package/dist/case/compiler.js +21 -21
  9. package/dist/case/config.d.ts +3 -3
  10. package/dist/case/config.js +19 -19
  11. package/dist/case/defaults.d.ts +2 -2
  12. package/dist/case/defaults.js +10 -10
  13. package/dist/case/diagnostic.js +29 -29
  14. package/dist/case/error.d.ts +2 -2
  15. package/dist/case/error.js +21 -21
  16. package/dist/case/esm-output.js +28 -28
  17. package/dist/case/example.js +7 -7
  18. package/dist/case/hash.d.ts +2 -2
  19. package/dist/case/hash.js +16 -16
  20. package/dist/case/hook.d.ts +3 -3
  21. package/dist/case/hook.js +42 -42
  22. package/dist/case/hot-step.d.ts +2 -2
  23. package/dist/case/hot-step.js +46 -46
  24. package/dist/case/hot.d.ts +5 -5
  25. package/dist/case/hot.js +43 -43
  26. package/dist/case/incremental.d.ts +2 -2
  27. package/dist/case/incremental.js +9 -9
  28. package/dist/case/index.d.ts +31 -31
  29. package/dist/case/multi-compiler.d.ts +3 -3
  30. package/dist/case/multi-compiler.js +15 -15
  31. package/dist/case/native-watcher.js +6 -6
  32. package/dist/case/normal.js +46 -46
  33. package/dist/case/runner.d.ts +2 -2
  34. package/dist/case/runner.js +22 -15
  35. package/dist/case/serial.d.ts +2 -2
  36. package/dist/case/serial.js +4 -4
  37. package/dist/case/stats-api.d.ts +2 -2
  38. package/dist/case/stats-api.js +7 -7
  39. package/dist/case/stats-output.d.ts +2 -2
  40. package/dist/case/stats-output.js +45 -45
  41. package/dist/case/treeshaking.js +6 -6
  42. package/dist/case/watch.d.ts +1 -1
  43. package/dist/case/watch.js +59 -59
  44. package/dist/compiler.d.ts +3 -3
  45. package/dist/compiler.js +31 -31
  46. package/dist/helper/directory.d.ts +1 -1
  47. package/dist/helper/directory.js +15 -15
  48. package/dist/helper/disable-iconv-lite-warning.js +3 -3
  49. package/dist/helper/expect/diff.js +8 -8
  50. package/dist/helper/expect/error.js +9 -9
  51. package/dist/helper/expect/placeholder.js +9 -9
  52. package/dist/helper/expect/rspack.js +5 -5
  53. package/dist/helper/expect/to-be-typeof.js +2 -2
  54. package/dist/helper/expect/to-end-with.js +3 -3
  55. package/dist/helper/expect/to-match-file-snapshot.d.ts +1 -1
  56. package/dist/helper/expect/to-match-file-snapshot.js +23 -23
  57. package/dist/helper/hot-update/index.d.ts +1 -1
  58. package/dist/helper/hot-update/loader.js +1 -1
  59. package/dist/helper/hot-update/plugin.d.ts +1 -1
  60. package/dist/helper/hot-update/plugin.js +15 -15
  61. package/dist/helper/index.d.ts +8 -8
  62. package/dist/helper/is.js +2 -2
  63. package/dist/helper/legacy/EventSourceForNode.js +8 -8
  64. package/dist/helper/legacy/LogTestPlugin.js +18 -18
  65. package/dist/helper/legacy/asModule.js +6 -6
  66. package/dist/helper/legacy/captureStdio.js +6 -6
  67. package/dist/helper/legacy/checkArrayExpectation.js +24 -24
  68. package/dist/helper/legacy/copyDiff.js +5 -5
  69. package/dist/helper/legacy/createFakeWorker.js +13 -13
  70. package/dist/helper/legacy/createLazyTestEnv.js +12 -12
  71. package/dist/helper/legacy/currentScript.js +1 -1
  72. package/dist/helper/legacy/deprecationTracking.js +5 -5
  73. package/dist/helper/legacy/expectSource.js +5 -5
  74. package/dist/helper/legacy/fakeSystem.js +14 -14
  75. package/dist/helper/legacy/findOutputFiles.js +4 -4
  76. package/dist/helper/legacy/parseResource.js +4 -4
  77. package/dist/helper/legacy/regexEscape.js +2 -2
  78. package/dist/helper/legacy/supportDefaultAssignment.js +2 -2
  79. package/dist/helper/legacy/supportsTextDecoder.js +2 -2
  80. package/dist/helper/legacy/supportsUsing.js +1 -1
  81. package/dist/helper/legacy/urlToRelativePath.js +3 -3
  82. package/dist/helper/parse-modules.js +13 -13
  83. package/dist/helper/read-config-file.d.ts +2 -2
  84. package/dist/helper/read-config-file.js +3 -3
  85. package/dist/helper/serializers.d.ts +1 -1
  86. package/dist/helper/serializers.js +11 -11
  87. package/dist/helper/setup-env.js +17 -17
  88. package/dist/helper/setup-expect.js +1 -1
  89. package/dist/helper/setup-wasm.js +4 -4
  90. package/dist/helper/stringify-config.d.ts +1 -1
  91. package/dist/helper/stringify-config.js +3 -3
  92. package/dist/helper/update-snapshot.js +1 -1
  93. package/dist/helper/util/checkSourceMap.js +16 -17
  94. package/dist/helper/util/checkStats.js +3 -3
  95. package/dist/helper/util/expectWarningFactory.js +2 -2
  96. package/dist/helper/util/filterUtil.js +9 -9
  97. package/dist/index.d.ts +8 -8
  98. package/dist/index.js +1 -1
  99. package/dist/plugin/index.d.ts +1 -1
  100. package/dist/plugin/lazy-compilation-test-plugin.d.ts +1 -1
  101. package/dist/plugin/lazy-compilation-test-plugin.js +13 -13
  102. package/dist/runner/index.d.ts +2 -2
  103. package/dist/runner/node/index.d.ts +2 -2
  104. package/dist/runner/node/index.js +75 -74
  105. package/dist/runner/web/index.d.ts +2 -2
  106. package/dist/runner/web/index.js +45 -45
  107. package/dist/test/context.d.ts +2 -2
  108. package/dist/test/context.js +4 -4
  109. package/dist/test/creator.d.ts +1 -1
  110. package/dist/test/creator.js +28 -28
  111. package/dist/test/debug.d.ts +1 -1
  112. package/dist/test/debug.js +31 -31
  113. package/dist/test/tester.d.ts +1 -1
  114. package/dist/test/tester.js +11 -11
  115. package/dist/type.d.ts +3 -3
  116. package/package.json +3 -3
  117. package/rstest.d.ts +12 -12
@@ -1,4 +1,4 @@
1
- import type { RspackOptions } from "@rspack/core";
2
- import type { ITestContext } from "../type";
1
+ import type { RspackOptions } from '@rspack/core';
2
+ import type { ITestContext } from '../type';
3
3
  export declare function createBuiltinCase(name: string, src: string, dist: string): void;
4
4
  export declare function defaultOptions(context: ITestContext): RspackOptions;
@@ -36,12 +36,12 @@ const creator = new creator_1.BasicCaseCreator({
36
36
  // no need to run, just check snapshot
37
37
  },
38
38
  check: async (env, context) => {
39
- await (0, common_1.checkSnapshot)(env, context, name, "output.snap.txt", filter);
40
- }
41
- }
39
+ await (0, common_1.checkSnapshot)(env, context, name, 'output.snap.txt', filter);
40
+ },
41
+ },
42
42
  ];
43
43
  },
44
- concurrent: true
44
+ concurrent: true,
45
45
  });
46
46
  function createBuiltinCase(name, src, dist) {
47
47
  creator.create(name, src, dist);
@@ -50,113 +50,113 @@ function defaultOptions(context) {
50
50
  let defaultOptions = {
51
51
  entry: {
52
52
  main: {
53
- import: "./index"
54
- }
53
+ import: './index',
54
+ },
55
55
  },
56
56
  output: {
57
- publicPath: "/",
57
+ publicPath: '/',
58
58
  path: context.getDist(),
59
- filename: "[name].js",
60
- chunkFilename: "[name].js",
61
- chunkFormat: "array-push",
62
- cssFilename: "[name].css",
63
- cssChunkFilename: "[name].css",
64
- assetModuleFilename: "[hash][ext][query]",
65
- sourceMapFilename: "[file].map",
66
- chunkLoadingGlobal: "webpackChunkwebpack",
67
- chunkLoading: "jsonp",
68
- uniqueName: "__rspack_test__",
69
- enabledLibraryTypes: ["system"],
59
+ filename: '[name].js',
60
+ chunkFilename: '[name].js',
61
+ chunkFormat: 'array-push',
62
+ cssFilename: '[name].css',
63
+ cssChunkFilename: '[name].css',
64
+ assetModuleFilename: '[hash][ext][query]',
65
+ sourceMapFilename: '[file].map',
66
+ chunkLoadingGlobal: 'webpackChunkwebpack',
67
+ chunkLoading: 'jsonp',
68
+ uniqueName: '__rspack_test__',
69
+ enabledLibraryTypes: ['system'],
70
70
  strictModuleErrorHandling: false,
71
71
  iife: true,
72
72
  module: false,
73
73
  asyncChunks: true,
74
74
  scriptType: false,
75
- globalObject: "self",
76
- importFunctionName: "import",
77
- wasmLoading: "fetch",
78
- webassemblyModuleFilename: "[hash].module.wasm",
79
- workerChunkLoading: "import-scripts",
80
- workerWasmLoading: "fetch"
75
+ globalObject: 'self',
76
+ importFunctionName: 'import',
77
+ wasmLoading: 'fetch',
78
+ webassemblyModuleFilename: '[hash].module.wasm',
79
+ workerChunkLoading: 'import-scripts',
80
+ workerWasmLoading: 'fetch',
81
81
  },
82
82
  module: {
83
83
  rules: [
84
84
  {
85
85
  test: /\.json$/,
86
- type: "json"
86
+ type: 'json',
87
87
  },
88
88
  {
89
89
  test: /\.mjs$/,
90
- type: "javascript/esm"
90
+ type: 'javascript/esm',
91
91
  },
92
92
  {
93
93
  test: /\.cjs$/,
94
- type: "javascript/dynamic"
94
+ type: 'javascript/dynamic',
95
95
  },
96
96
  {
97
97
  test: /\.js$/,
98
- type: "javascript/auto"
98
+ type: 'javascript/auto',
99
99
  },
100
100
  {
101
101
  test: /\.css$/,
102
- type: "css"
102
+ type: 'css',
103
103
  },
104
104
  {
105
105
  test: /\.wasm$/,
106
- type: "webassembly/async"
107
- }
108
- ]
106
+ type: 'webassembly/async',
107
+ },
108
+ ],
109
109
  },
110
110
  node: {
111
- __dirname: "mock",
112
- __filename: "mock",
113
- global: "warn"
111
+ __dirname: 'mock',
112
+ __filename: 'mock',
113
+ global: 'warn',
114
114
  },
115
115
  optimization: {
116
116
  runtimeChunk: {
117
- name: "runtime"
117
+ name: 'runtime',
118
118
  },
119
119
  minimize: false,
120
120
  removeAvailableModules: true,
121
121
  removeEmptyChunks: true,
122
- moduleIds: "named",
123
- chunkIds: "named",
122
+ moduleIds: 'named',
123
+ chunkIds: 'named',
124
124
  sideEffects: false,
125
125
  mangleExports: false,
126
126
  inlineExports: false,
127
127
  usedExports: false,
128
128
  concatenateModules: false,
129
- nodeEnv: false
129
+ nodeEnv: false,
130
130
  },
131
131
  resolve: {
132
132
  extensions: [
133
- ".js",
134
- ".jsx",
135
- ".ts",
136
- ".tsx",
137
- ".json",
138
- ".d.ts",
139
- ".css",
140
- ".wasm"
141
- ]
133
+ '.js',
134
+ '.jsx',
135
+ '.ts',
136
+ '.tsx',
137
+ '.json',
138
+ '.d.ts',
139
+ '.css',
140
+ '.wasm',
141
+ ],
142
142
  },
143
143
  resolveLoader: {
144
- extensions: [".js"]
144
+ extensions: ['.js'],
145
145
  },
146
146
  experiments: {
147
147
  css: true,
148
148
  futureDefaults: true,
149
149
  rspackFuture: {
150
150
  bundlerInfo: {
151
- force: false
152
- }
153
- }
151
+ force: false,
152
+ },
153
+ },
154
154
  },
155
155
  devtool: false,
156
156
  context: context.getSource(),
157
- plugins: []
157
+ plugins: [],
158
158
  };
159
- const testConfigFile = context.getSource("rspack.config.js");
159
+ const testConfigFile = context.getSource('rspack.config.js');
160
160
  if (fs_extra_1.default.existsSync(testConfigFile)) {
161
161
  const caseOptions = require(testConfigFile);
162
162
  if (caseOptions.entry) {
@@ -166,13 +166,13 @@ function defaultOptions(context) {
166
166
  }
167
167
  if (!global.printLogger) {
168
168
  defaultOptions.infrastructureLogging = {
169
- level: "error"
169
+ level: 'error',
170
170
  };
171
171
  }
172
172
  return defaultOptions;
173
173
  }
174
174
  const FILTERS = {
175
- "plugin-css": (file) => file.endsWith(".css"),
176
- "plugin-css-modules": (file) => file.endsWith(".css") || ((0, helper_1.isJavaScript)(file) && !file.includes("runtime")),
177
- "plugin-html": (file) => file.endsWith(".html")
175
+ 'plugin-css': (file) => file.endsWith('.css'),
176
+ 'plugin-css-modules': (file) => file.endsWith('.css') || ((0, helper_1.isJavaScript)(file) && !file.includes('runtime')),
177
+ 'plugin-html': (file) => file.endsWith('.html'),
178
178
  };
@@ -1,2 +1,2 @@
1
- import { type RspackOptions } from "@rspack/core";
2
- export declare function createCacheCase(name: string, src: string, dist: string, target: RspackOptions["target"], temp: string): void;
1
+ import { type RspackOptions } from '@rspack/core';
2
+ export declare function createCacheCase(name: string, src: string, dist: string, target: RspackOptions['target'], temp: string): void;
@@ -18,7 +18,7 @@ function createCacheProcessor(name, src, temp, target) {
18
18
  return {
19
19
  before: async (context) => {
20
20
  await updatePlugin.initialize();
21
- context.setValue("hotUpdateContext", updatePlugin);
21
+ context.setValue('hotUpdateContext', updatePlugin);
22
22
  },
23
23
  config: async (context) => {
24
24
  const compiler = context.getCompiler();
@@ -32,7 +32,7 @@ function createCacheProcessor(name, src, temp, target) {
32
32
  await (0, common_1.build)(context, name);
33
33
  },
34
34
  run: async (env, context) => {
35
- await (0, common_1.run)(env, context, name, context => findBundle(name, target, context));
35
+ await (0, common_1.run)(env, context, name, (context) => findBundle(name, target, context));
36
36
  },
37
37
  check: async (env, context) => {
38
38
  await (0, common_1.check)(env, context, name);
@@ -46,7 +46,7 @@ function createCacheProcessor(name, src, temp, target) {
46
46
  if (updateIndex + 1 !== totalUpdates) {
47
47
  throw new Error(`Should run all hot steps (${updateIndex + 1} / ${totalUpdates}): ${name}`);
48
48
  }
49
- }
49
+ },
50
50
  };
51
51
  }
52
52
  function getCreator(target) {
@@ -56,13 +56,13 @@ function getCreator(target) {
56
56
  describe: true,
57
57
  target,
58
58
  steps: ({ name, src, target, temp }) => [
59
- createCacheProcessor(name, src, temp, target)
59
+ createCacheProcessor(name, src, temp, target),
60
60
  ],
61
61
  runner: {
62
62
  key: (context, name, file) => name,
63
- runner: createRunner
63
+ runner: createRunner,
64
64
  },
65
- concurrent: true
65
+ concurrent: true,
66
66
  }));
67
67
  }
68
68
  return creators.get(target);
@@ -75,51 +75,51 @@ const creators = new Map();
75
75
  async function generateOptions(context, temp, target, updatePlugin) {
76
76
  let options = {
77
77
  context: temp,
78
- mode: "production",
78
+ mode: 'production',
79
79
  cache: true,
80
80
  devtool: false,
81
81
  output: {
82
82
  path: context.getDist(),
83
- filename: "bundle.js",
84
- chunkFilename: "[name].chunk.[fullhash].js",
85
- publicPath: "https://test.cases/path/",
86
- library: { type: "commonjs2" }
83
+ filename: 'bundle.js',
84
+ chunkFilename: '[name].chunk.[fullhash].js',
85
+ publicPath: 'https://test.cases/path/',
86
+ library: { type: 'commonjs2' },
87
87
  },
88
88
  optimization: {
89
- moduleIds: "named",
90
- emitOnErrors: true
89
+ moduleIds: 'named',
90
+ emitOnErrors: true,
91
91
  },
92
92
  target,
93
93
  experiments: {
94
94
  css: true,
95
95
  rspackFuture: {
96
96
  bundlerInfo: {
97
- force: false
98
- }
99
- }
100
- }
97
+ force: false,
98
+ },
99
+ },
100
+ },
101
101
  };
102
102
  options.plugins ??= [];
103
103
  options.plugins.push(new core_1.default.HotModuleReplacementPlugin());
104
- options = await (0, common_1.config)(context, "cacheCase", ["rspack.config.js", "webpack.config.js"].map(i => node_path_1.default.resolve(temp, i)), options);
104
+ options = await (0, common_1.config)(context, 'cacheCase', ['rspack.config.js', 'webpack.config.js'].map((i) => node_path_1.default.resolve(temp, i)), options);
105
105
  // overwrite
106
106
  if (!options.entry) {
107
- options.entry = "./index.js";
107
+ options.entry = './index.js';
108
108
  }
109
109
  // rewrite context to temp dir
110
110
  options.context = temp;
111
111
  options.module ??= {};
112
- for (const cssModuleType of ["css/auto", "css/module", "css"]) {
112
+ for (const cssModuleType of ['css/auto', 'css/module', 'css']) {
113
113
  options.module.generator ??= {};
114
114
  options.module.generator[cssModuleType] ??= {};
115
115
  options.module.generator[cssModuleType].exportsOnly ??=
116
- target === "async-node";
116
+ target === 'async-node';
117
117
  }
118
118
  options.plugins ??= [];
119
119
  options.plugins.push(updatePlugin);
120
120
  if (!global.printLogger) {
121
121
  options.infrastructureLogging = {
122
- level: "error"
122
+ level: 'error',
123
123
  };
124
124
  }
125
125
  return options;
@@ -129,15 +129,15 @@ function findBundle(name, target, context) {
129
129
  const prefiles = [];
130
130
  const compiler = context.getCompiler();
131
131
  if (!compiler)
132
- throw new Error("Compiler should exists when find bundle");
132
+ throw new Error('Compiler should exists when find bundle');
133
133
  const stats = compiler.getStats();
134
134
  if (!stats)
135
- throw new Error("Stats should exists when find bundle");
135
+ throw new Error('Stats should exists when find bundle');
136
136
  const info = stats.toJson({
137
137
  all: false,
138
- entrypoints: true
138
+ entrypoints: true,
139
139
  });
140
- if (target === "web" || target === "webworker") {
140
+ if (target === 'web' || target === 'webworker') {
141
141
  for (const file of info.entrypoints.main.assets) {
142
142
  if ((0, helper_1.isJavaScript)(file.name)) {
143
143
  files.push(file.name);
@@ -148,7 +148,7 @@ function findBundle(name, target, context) {
148
148
  }
149
149
  }
150
150
  else {
151
- const assets = info.entrypoints.main.assets.filter(s => (0, helper_1.isJavaScript)(s.name));
151
+ const assets = info.entrypoints.main.assets.filter((s) => (0, helper_1.isJavaScript)(s.name));
152
152
  files.push(assets[assets.length - 1].name);
153
153
  }
154
154
  return [...prefiles, ...files];
@@ -160,7 +160,7 @@ function createRunner(context, name, file, env) {
160
160
  const testConfig = context.getTestConfig();
161
161
  const source = context.getSource();
162
162
  const dist = context.getDist();
163
- const updatePlugin = context.getValue("hotUpdateContext");
163
+ const updatePlugin = context.getValue('hotUpdateContext');
164
164
  const getWebRunner = () => {
165
165
  return new runner_1.NodeRunner({
166
166
  env,
@@ -171,7 +171,7 @@ function createRunner(context, name, file, env) {
171
171
  testConfig: {
172
172
  ...testConfig,
173
173
  moduleScope(ms, stats, options) {
174
- const moduleScope = typeof testConfig.moduleScope === "function"
174
+ const moduleScope = typeof testConfig.moduleScope === 'function'
175
175
  ? testConfig.moduleScope(ms, stats, options)
176
176
  : ms;
177
177
  moduleScope.COMPILER_INDEX = compilerIndex;
@@ -179,18 +179,18 @@ function createRunner(context, name, file, env) {
179
179
  moduleScope.NEXT_START = nextStart;
180
180
  moduleScope.NEXT_MOVE_DIR_START = nextMoveDirStart;
181
181
  return moduleScope;
182
- }
182
+ },
183
183
  },
184
184
  source,
185
185
  dist,
186
- compilerOptions: options
186
+ compilerOptions: options,
187
187
  });
188
188
  };
189
189
  const checkStats = async (stats) => {
190
190
  const compilerOptions = compiler.getOptions();
191
191
  const updateIndex = updatePlugin.getUpdateIndex();
192
- await (0, checkArrayExpectation_1.default)(source, stats, "error", `errors${updateIndex}`, "Error", compilerOptions);
193
- await (0, checkArrayExpectation_1.default)(source, stats, "warning", `warnings${updateIndex}`, "Warning", compilerOptions);
192
+ await (0, checkArrayExpectation_1.default)(source, stats, 'error', `errors${updateIndex}`, 'Error', compilerOptions);
193
+ await (0, checkArrayExpectation_1.default)(source, stats, 'warning', `warnings${updateIndex}`, 'Warning', compilerOptions);
194
194
  };
195
195
  const nextHmr = async (m, options) => {
196
196
  await updatePlugin.goNext();
@@ -201,7 +201,7 @@ function createRunner(context, name, file, env) {
201
201
  await checkStats(jsonStats);
202
202
  const updatedModules = await m.hot.check(options || true);
203
203
  if (!updatedModules) {
204
- throw new Error("No update available");
204
+ throw new Error('No update available');
205
205
  }
206
206
  return jsonStats;
207
207
  };
@@ -1,5 +1,5 @@
1
- import type { Compiler, RspackOptions } from "@rspack/core";
2
- import type { ITestContext, ITestEnv } from "../type";
1
+ import type { Compiler, RspackOptions } from '@rspack/core';
2
+ import type { ITestContext, ITestEnv } from '../type';
3
3
  export declare function config(context: ITestContext, name: string, configFiles: string[], defaultOptions?: RspackOptions): Promise<RspackOptions>;
4
4
  export declare function compiler(context: ITestContext, name: string): Promise<Compiler>;
5
5
  export declare function build(context: ITestContext, name: string): Promise<Compiler>;
@@ -23,7 +23,7 @@ async function config(context, name, configFiles, defaultOptions = {}) {
23
23
  const compiler = context.getCompiler();
24
24
  compiler.setOptions(defaultOptions);
25
25
  if (Array.isArray(configFiles)) {
26
- const fileOptions = (0, helper_1.readConfigFile)(configFiles.map(i => context.getSource(i)), context, defaultOptions)[0];
26
+ const fileOptions = (0, helper_1.readConfigFile)(configFiles.map((i) => context.getSource(i)), context, defaultOptions)[0];
27
27
  compiler.mergeOptions(fileOptions);
28
28
  }
29
29
  return compiler.getOptions();
@@ -43,17 +43,17 @@ async function run(env, context, name, findBundle) {
43
43
  if (testConfig.noTests)
44
44
  return;
45
45
  const compiler = context.getCompiler();
46
- if (typeof testConfig.beforeExecute === "function") {
46
+ if (typeof testConfig.beforeExecute === 'function') {
47
47
  testConfig.beforeExecute(compiler.getOptions());
48
48
  }
49
49
  let bundles;
50
- if (typeof findBundle === "function") {
50
+ if (typeof findBundle === 'function') {
51
51
  bundles = findBundle(context, compiler.getOptions());
52
52
  }
53
53
  else {
54
54
  bundles = [];
55
55
  }
56
- if (typeof bundles === "string") {
56
+ if (typeof bundles === 'string') {
57
57
  bundles = [bundles];
58
58
  }
59
59
  if (__DEBUG__) {
@@ -76,11 +76,11 @@ async function run(env, context, name, findBundle) {
76
76
  runLogs?.push(`Start running entry: ${bundle} in ${runner.constructor.name}(${runner.__key__})`);
77
77
  }
78
78
  const mod = runner.run(bundle);
79
- const result = context.getValue("modules") || [];
79
+ const result = context.getValue('modules') || [];
80
80
  result.push(mod);
81
- context.setValue("modules", result);
81
+ context.setValue('modules', result);
82
82
  }
83
- const results = context.getValue("modules") || [];
83
+ const results = context.getValue('modules') || [];
84
84
  await Promise.all(results);
85
85
  }
86
86
  async function check(env, context, name) {
@@ -88,32 +88,32 @@ async function check(env, context, name) {
88
88
  if (testConfig.noTests)
89
89
  return;
90
90
  const compiler = context.getCompiler();
91
- const errors = (context.getError() || []).map(e => ({
91
+ const errors = (context.getError() || []).map((e) => ({
92
92
  message: e.message,
93
- stack: e.stack
93
+ stack: e.stack,
94
94
  }));
95
95
  const warnings = [];
96
96
  const stats = compiler.getStats();
97
97
  const options = compiler.getOptions();
98
98
  if (stats) {
99
99
  if (testConfig.writeStatsOuptut) {
100
- fs_extra_1.default.writeFileSync(path_1.default.join(context.getDist(), "stats.txt"), stats.toString({
101
- preset: "verbose",
102
- colors: false
103
- }), "utf-8");
100
+ fs_extra_1.default.writeFileSync(path_1.default.join(context.getDist(), 'stats.txt'), stats.toString({
101
+ preset: 'verbose',
102
+ colors: false,
103
+ }), 'utf-8');
104
104
  }
105
105
  if (testConfig.writeStatsJson) {
106
106
  const jsonStats = stats.toJson({
107
- errorDetails: true
107
+ errorDetails: true,
108
108
  });
109
- fs_extra_1.default.writeFileSync(path_1.default.join(context.getDist(), "stats.json"), JSON.stringify(jsonStats, null, 2), "utf-8");
109
+ fs_extra_1.default.writeFileSync(path_1.default.join(context.getDist(), 'stats.json'), JSON.stringify(jsonStats, null, 2), 'utf-8');
110
110
  }
111
- if (fs_extra_1.default.existsSync(context.getSource("errors.js")) ||
112
- fs_extra_1.default.existsSync(context.getSource("warnings.js")) ||
111
+ if (fs_extra_1.default.existsSync(context.getSource('errors.js')) ||
112
+ fs_extra_1.default.existsSync(context.getSource('warnings.js')) ||
113
113
  stats.hasErrors() ||
114
114
  stats.hasWarnings()) {
115
115
  const statsJson = stats.toJson({
116
- errorDetails: true
116
+ errorDetails: true,
117
117
  });
118
118
  if (statsJson.errors) {
119
119
  errors.push(...statsJson.errors);
@@ -123,26 +123,26 @@ async function check(env, context, name) {
123
123
  }
124
124
  }
125
125
  }
126
- await (0, checkArrayExpectation_1.default)(context.getSource(), { errors }, "error", "errors", "Error", options);
127
- await (0, checkArrayExpectation_1.default)(context.getSource(), { warnings }, "warning", "warnings", "Warning", options);
126
+ await (0, checkArrayExpectation_1.default)(context.getSource(), { errors }, 'error', 'errors', 'Error', options);
127
+ await (0, checkArrayExpectation_1.default)(context.getSource(), { warnings }, 'warning', 'warnings', 'Warning', options);
128
128
  // clear error if checked
129
- if (fs_extra_1.default.existsSync(context.getSource("errors.js"))) {
129
+ if (fs_extra_1.default.existsSync(context.getSource('errors.js'))) {
130
130
  context.clearError();
131
131
  }
132
132
  }
133
133
  async function checkSnapshot(env, context, name, snapshot, filter) {
134
- if (path_1.default.extname(snapshot) === ".snap") {
135
- throw new Error("Snapshot with `.snap` will be managed by rstest, please use `.snap.txt` instead");
134
+ if (path_1.default.extname(snapshot) === '.snap') {
135
+ throw new Error('Snapshot with `.snap` will be managed by rstest, please use `.snap.txt` instead');
136
136
  }
137
137
  const compilerManager = context.getCompiler();
138
138
  const stats = compilerManager.getStats();
139
139
  const compiler = compilerManager.getCompiler();
140
140
  if (!stats || !compiler)
141
141
  return;
142
- const compilers = "compilers" in compiler
142
+ const compilers = 'compilers' in compiler
143
143
  ? compiler.compilers
144
144
  : [compiler];
145
- const totalStats = "stats" in stats ? stats.stats : [stats];
145
+ const totalStats = 'stats' in stats ? stats.stats : [stats];
146
146
  const total = compilers.length;
147
147
  for (let i = 0; i < compilers.length; i++) {
148
148
  const c = compilers[i];
@@ -151,38 +151,38 @@ async function checkSnapshot(env, context, name, snapshot, filter) {
151
151
  const errors = [];
152
152
  errors.push(...stats.compilation.errors);
153
153
  throw new Error(`Failed to compile in fixture ${name}, Errors: ${errors
154
- ?.map(i => `${i.message}\n${i.stack}`)
155
- .join("\n\n")}`);
154
+ ?.map((i) => `${i.message}\n${i.stack}`)
155
+ .join('\n\n')}`);
156
156
  }
157
157
  const compilation = c._lastCompilation ||
158
158
  c._lastCompilation;
159
159
  const snapshotFileFilter = filter ||
160
- ((file) => (file.endsWith(".js") || file.endsWith(".mjs")) &&
161
- !file.includes("runtime.js"));
160
+ ((file) => (file.endsWith('.js') || file.endsWith('.mjs')) &&
161
+ !file.includes('runtime.js'));
162
162
  const fileContents = Object.entries(compilation.assets)
163
163
  .filter(([file]) => snapshotFileFilter(file))
164
164
  .map(([file, source]) => {
165
- const tag = path_1.default.extname(file).slice(1) || "txt";
165
+ const tag = path_1.default.extname(file).slice(1) || 'txt';
166
166
  let content = (0, placeholder_1.normalizePlaceholder)(source.source().toString());
167
167
  const testConfig = context.getTestConfig();
168
168
  if (testConfig.snapshotContent) {
169
169
  content = testConfig.snapshotContent(content);
170
170
  }
171
- const filePath = file.replaceAll(path_1.default.sep, "/");
171
+ const filePath = file.replaceAll(path_1.default.sep, '/');
172
172
  return `\`\`\`${tag} title=${filePath}\n${content}\n\`\`\``;
173
173
  });
174
174
  fileContents.sort();
175
- const content = fileContents.join("\n\n");
175
+ const content = fileContents.join('\n\n');
176
176
  const snapshotPath = path_1.default.isAbsolute(snapshot)
177
177
  ? snapshot
178
- : path_1.default.resolve(context.getSource(), path_1.default.join("__snapshots__", `${snapshot}${total > 1 ? `-${i}` : ""}`));
178
+ : path_1.default.resolve(context.getSource(), path_1.default.join('__snapshots__', `${snapshot}${total > 1 ? `-${i}` : ''}`));
179
179
  env.expect(content).toMatchFileSnapshotSync(snapshotPath);
180
180
  }
181
181
  }
182
182
  async function afterExecute(context, name) {
183
183
  const compiler = context.getCompiler();
184
184
  const testConfig = context.getTestConfig();
185
- if (typeof testConfig.afterExecute === "function") {
185
+ if (typeof testConfig.afterExecute === 'function') {
186
186
  let options = compiler.getOptions();
187
187
  if (Array.isArray(options) && options.length === 1) {
188
188
  options = options[0];
@@ -191,13 +191,13 @@ async function afterExecute(context, name) {
191
191
  }
192
192
  }
193
193
  function findMultiCompilerBundle(context, name, multiFindBundle) {
194
- if (typeof multiFindBundle !== "function") {
194
+ if (typeof multiFindBundle !== 'function') {
195
195
  return [];
196
196
  }
197
- const multiCompilerOptions = (context.getValue("multiCompilerOptions") ||
197
+ const multiCompilerOptions = (context.getValue('multiCompilerOptions') ||
198
198
  []);
199
199
  const result = [];
200
- const multiFileIndexMap = context.getValue("multiFileIndexMap") || {};
200
+ const multiFileIndexMap = context.getValue('multiFileIndexMap') || {};
201
201
  for (const [index, compilerOptions] of multiCompilerOptions.entries()) {
202
202
  const curBundles = multiFindBundle(index, context, compilerOptions);
203
203
  const bundles = Array.isArray(curBundles)
@@ -215,18 +215,18 @@ function findMultiCompilerBundle(context, name, multiFindBundle) {
215
215
  }
216
216
  result.push(...bundles);
217
217
  }
218
- context.setValue("multiFileIndexMap", multiFileIndexMap);
218
+ context.setValue('multiFileIndexMap', multiFileIndexMap);
219
219
  return result;
220
220
  }
221
221
  function configMultiCompiler(context, name, configFiles, defaultOptions, overrideOptions) {
222
222
  const multiCompilerOptions = [];
223
223
  const caseOptions = Array.isArray(configFiles)
224
- ? (0, helper_1.readConfigFile)(configFiles.map(i => context.getSource(i)), context, {}, configs => {
225
- return configs.flatMap(c => {
226
- if (typeof c === "function") {
224
+ ? (0, helper_1.readConfigFile)(configFiles.map((i) => context.getSource(i)), context, {}, (configs) => {
225
+ return configs.flatMap((c) => {
226
+ if (typeof c === 'function') {
227
227
  const options = {
228
228
  testPath: context.getDist(),
229
- env: undefined
229
+ env: undefined,
230
230
  };
231
231
  return c(options.env, options);
232
232
  }
@@ -235,15 +235,15 @@ function configMultiCompiler(context, name, configFiles, defaultOptions, overrid
235
235
  })
236
236
  : [{}];
237
237
  for (const [index, options] of caseOptions.entries()) {
238
- const compilerOptions = (0, webpack_merge_1.default)(typeof defaultOptions === "function"
238
+ const compilerOptions = (0, webpack_merge_1.default)(typeof defaultOptions === 'function'
239
239
  ? defaultOptions(index, context)
240
240
  : {}, options);
241
- if (typeof overrideOptions === "function") {
241
+ if (typeof overrideOptions === 'function') {
242
242
  overrideOptions(index, context, compilerOptions);
243
243
  }
244
244
  multiCompilerOptions.push(compilerOptions);
245
245
  }
246
246
  const compiler = context.getCompiler();
247
247
  compiler.setOptions(multiCompilerOptions);
248
- context.setValue("multiCompilerOptions", multiCompilerOptions);
248
+ context.setValue('multiCompilerOptions', multiCompilerOptions);
249
249
  }