@rspack/test-tools 1.7.0-beta.1 → 1.7.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 (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
@@ -14,22 +14,22 @@ const EventSourceForNode_1 = __importDefault(require("../../helper/legacy/EventS
14
14
  const urlToRelativePath_1 = __importDefault(require("../../helper/legacy/urlToRelativePath"));
15
15
  const node_1 = require("../node");
16
16
  // Compatibility code to suppress iconv-lite warnings
17
- require("iconv-lite").skipDecodeWarning = true;
17
+ require('iconv-lite').skipDecodeWarning = true;
18
18
  const FAKE_HOSTS = [
19
- "https://example.com/public/path",
20
- "https://example.com",
21
- "https://test.cases/path/",
22
- "https://test.cases/server/",
23
- "https://test.cases"
19
+ 'https://example.com/public/path',
20
+ 'https://example.com',
21
+ 'https://test.cases/path/',
22
+ 'https://test.cases/server/',
23
+ 'https://test.cases',
24
24
  ];
25
- const FAKE_TEST_ROOT_HOST = "https://test.cases/root/";
25
+ const FAKE_TEST_ROOT_HOST = 'https://test.cases/root/';
26
26
  class WebRunner extends node_1.NodeRunner {
27
27
  constructor(_webOptions) {
28
28
  super(_webOptions);
29
29
  this._webOptions = _webOptions;
30
30
  const virtualConsole = new jsdom_1.VirtualConsole({});
31
31
  virtualConsole.sendTo(console, {
32
- omitJSDOMErrors: true
32
+ omitJSDOMErrors: true,
33
33
  });
34
34
  this.dom = new jsdom_1.JSDOM(`
35
35
  <!doctype html>
@@ -40,8 +40,8 @@ class WebRunner extends node_1.NodeRunner {
40
40
  `, {
41
41
  url: this._webOptions.location,
42
42
  resources: this.createResourceLoader(),
43
- runScripts: "dangerously",
44
- virtualConsole
43
+ runScripts: 'dangerously',
44
+ virtualConsole,
45
45
  });
46
46
  this.dom.window.console = console;
47
47
  // compat with FakeDocument
@@ -71,11 +71,11 @@ class WebRunner extends node_1.NodeRunner {
71
71
  }
72
72
  }
73
73
  run(file) {
74
- if (!file.endsWith(".js") && !file.endsWith(".mjs")) {
74
+ if (!file.endsWith('.js') && !file.endsWith('.mjs')) {
75
75
  this.log(`css: ${file}`);
76
- const cssElement = this.dom.window.document.createElement("link");
76
+ const cssElement = this.dom.window.document.createElement('link');
77
77
  cssElement.href = file;
78
- cssElement.rel = "stylesheet";
78
+ cssElement.rel = 'stylesheet';
79
79
  this.dom.window.document.head.appendChild(cssElement);
80
80
  return Promise.resolve();
81
81
  }
@@ -105,7 +105,7 @@ class WebRunner extends node_1.NodeRunner {
105
105
  const filePath = that.urlToPath(url);
106
106
  that.log(`resource loader: ${url} -> ${filePath}`);
107
107
  let finalCode;
108
- if (node_path_1.default.extname(filePath) === ".js") {
108
+ if (node_path_1.default.extname(filePath) === '.js') {
109
109
  const currentDirectory = node_path_1.default.dirname(filePath);
110
110
  const file = that.getFile(filePath, currentDirectory);
111
111
  if (!file) {
@@ -118,13 +118,13 @@ class WebRunner extends node_1.NodeRunner {
118
118
  finalCode = node_fs_1.default.readFileSync(filePath);
119
119
  }
120
120
  try {
121
- that.dom.window["__LINK_SHEET__"] ??= {};
122
- that.dom.window["__LINK_SHEET__"][url] = finalCode.toString();
121
+ that.dom.window['__LINK_SHEET__'] ??= {};
122
+ that.dom.window['__LINK_SHEET__'][url] = finalCode.toString();
123
123
  return Promise.resolve(finalCode);
124
124
  }
125
125
  catch (err) {
126
126
  console.error(err);
127
- if (err.code === "ENOENT") {
127
+ if (err.code === 'ENOENT') {
128
128
  return null;
129
129
  }
130
130
  throw err;
@@ -134,7 +134,7 @@ class WebRunner extends node_1.NodeRunner {
134
134
  return new CustomResourceLoader();
135
135
  }
136
136
  urlToPath(url) {
137
- if (url.startsWith("file://")) {
137
+ if (url.startsWith('file://')) {
138
138
  return (0, node_url_1.fileURLToPath)(url);
139
139
  }
140
140
  if (url.startsWith(FAKE_TEST_ROOT_HOST)) {
@@ -147,7 +147,7 @@ class WebRunner extends node_1.NodeRunner {
147
147
  break;
148
148
  }
149
149
  }
150
- return node_path_1.default.resolve(this._webOptions.dist, `./${dist}`).split("?")[0];
150
+ return node_path_1.default.resolve(this._webOptions.dist, `./${dist}`).split('?')[0];
151
151
  }
152
152
  createBaseModuleScope() {
153
153
  const moduleScope = super.createBaseModuleScope();
@@ -160,14 +160,14 @@ class WebRunner extends node_1.NodeRunner {
160
160
  return {
161
161
  status: 200,
162
162
  ok: true,
163
- json: async () => JSON.parse(buffer.toString("utf-8"))
163
+ json: async () => JSON.parse(buffer.toString('utf-8')),
164
164
  };
165
165
  }
166
166
  catch (err) {
167
- if (err.code === "ENOENT") {
167
+ if (err.code === 'ENOENT') {
168
168
  return {
169
169
  status: 404,
170
- ok: false
170
+ ok: false,
171
171
  };
172
172
  }
173
173
  throw err;
@@ -177,7 +177,7 @@ class WebRunner extends node_1.NodeRunner {
177
177
  moduleScope.importScripts = (url) => {
178
178
  const path = (0, urlToRelativePath_1.default)(url);
179
179
  this.log(`importScripts: ${url} -> ${path}`);
180
- this.requirers.get("entry")(this._options.dist, path);
180
+ this.requirers.get('entry')(this._options.dist, path);
181
181
  };
182
182
  moduleScope.getComputedStyle = (element) => {
183
183
  const computedStyle = this.dom.window.getComputedStyle(element);
@@ -186,30 +186,30 @@ class WebRunner extends node_1.NodeRunner {
186
186
  ...computedStyle,
187
187
  getPropertyValue(v) {
188
188
  return getPropertyValue(v);
189
- }
189
+ },
190
190
  };
191
191
  };
192
192
  moduleScope.window = this.dom.window;
193
193
  moduleScope.document = this.dom.window.document;
194
194
  moduleScope.getLinkSheet = (link) => {
195
- return this.dom.window["__LINK_SHEET__"][link.href];
195
+ return this.dom.window['__LINK_SHEET__'][link.href];
196
196
  };
197
197
  return moduleScope;
198
198
  }
199
199
  getModuleContent(file) {
200
200
  const m = {
201
- exports: {}
201
+ exports: {},
202
202
  };
203
203
  const currentModuleScope = this.createModuleScope(this.getRequire(), m, file);
204
204
  if (this._options.testConfig.moduleScope) {
205
205
  this._options.testConfig.moduleScope(currentModuleScope, this._options.stats, this._options.compilerOptions);
206
206
  }
207
- if (file.content.includes("__STATS__")) {
207
+ if (file.content.includes('__STATS__')) {
208
208
  currentModuleScope.__STATS__ = this._options.stats?.();
209
209
  }
210
- if (file.content.includes("__STATS_I__")) {
210
+ if (file.content.includes('__STATS_I__')) {
211
211
  const statsIndex = this._options.stats?.()?.__index__;
212
- if (typeof statsIndex === "number") {
212
+ if (typeof statsIndex === 'number') {
213
213
  currentModuleScope.__STATS_I__ = statsIndex;
214
214
  }
215
215
  }
@@ -245,7 +245,7 @@ class WebRunner extends node_1.NodeRunner {
245
245
  return Reflect.set(target, prop, value, receiver);
246
246
  }
247
247
  });`;
248
- const proxyLines = proxyCode.split("\n");
248
+ const proxyLines = proxyCode.split('\n');
249
249
  const locatedError = (0, exports.createLocatedError)(this._options.errors || [], proxyLines.length + 1);
250
250
  const originIt = currentModuleScope.it;
251
251
  currentModuleScope.it = (description, fn) => {
@@ -259,23 +259,23 @@ class WebRunner extends node_1.NodeRunner {
259
259
  });
260
260
  };
261
261
  const scopeKey = (0, helper_1.escapeSep)(file.path);
262
- const args = Object.keys(currentModuleScope).filter(arg => !["window", "self", "globalThis", "console"].includes(arg));
262
+ const args = Object.keys(currentModuleScope).filter((arg) => !['window', 'self', 'globalThis', 'console'].includes(arg));
263
263
  const argValues = args
264
- .map(arg => `window["${scopeKey}"]["${arg}"]`)
265
- .join(", ");
264
+ .map((arg) => `window["${scopeKey}"]["${arg}"]`)
265
+ .join(', ');
266
266
  this.dom.window[scopeKey] = currentModuleScope;
267
- this.dom.window["__GLOBAL_SHARED__"] = this.globalContext;
268
- this.dom.window["__LOCATED_ERROR__"] = locatedError;
269
- this.dom.window["__FILE__"] = file;
267
+ this.dom.window['__GLOBAL_SHARED__'] = this.globalContext;
268
+ this.dom.window['__LOCATED_ERROR__'] = locatedError;
269
+ this.dom.window['__FILE__'] = file;
270
270
  return [
271
271
  m,
272
272
  `${proxyCode}
273
- (function(window, self, globalThis, console, ${args.join(", ")}) { try {
273
+ (function(window, self, globalThis, console, ${args.join(', ')}) { try {
274
274
  ${file.content}
275
275
  } catch (e) {
276
276
  throw __LOCATED_ERROR__(e, window["__FILE__"]);
277
277
  }})($$g$$, $$self$$, $$g$$, window["console"], ${argValues});`,
278
- proxyLines.length + 1
278
+ proxyLines.length + 1,
279
279
  ];
280
280
  }
281
281
  createJSDOMRequirer() {
@@ -283,7 +283,7 @@ class WebRunner extends node_1.NodeRunner {
283
283
  const file = context.file || this.getFile(modulePath, currentDirectory);
284
284
  this.log(`jsdom: ${modulePath} -> ${file?.path}`);
285
285
  if (!file) {
286
- return this.requirers.get("miss")(currentDirectory, modulePath);
286
+ return this.requirers.get('miss')(currentDirectory, modulePath);
287
287
  }
288
288
  if (file.path in this.requireCache) {
289
289
  return this.requireCache[file.path].exports;
@@ -295,7 +295,7 @@ class WebRunner extends node_1.NodeRunner {
295
295
  const vmContext = this.dom.getInternalVMContext();
296
296
  script.runInContext(vmContext, {
297
297
  filename: file.path,
298
- lineOffset: -lineOffset
298
+ lineOffset: -lineOffset,
299
299
  });
300
300
  }
301
301
  catch (e) {
@@ -311,7 +311,7 @@ class WebRunner extends node_1.NodeRunner {
311
311
  }
312
312
  createRunner() {
313
313
  super.createRunner();
314
- this.requirers.set("cjs", this.createJSDOMRequirer());
314
+ this.requirers.set('cjs', this.createJSDOMRequirer());
315
315
  }
316
316
  }
317
317
  exports.WebRunner = WebRunner;
@@ -321,15 +321,15 @@ const createLocatedError = (collectedErrors, offset) => {
321
321
  if (match) {
322
322
  const [, line] = match;
323
323
  const realLine = Number(line) - offset;
324
- const codeLines = file.content.split("\n");
324
+ const codeLines = file.content.split('\n');
325
325
  const lineContents = [
326
326
  ...codeLines
327
327
  .slice(Math.max(0, realLine - 3), Math.max(0, realLine - 1))
328
- .map(line => `│ ${line}`),
328
+ .map((line) => `│ ${line}`),
329
329
  `│> ${codeLines[realLine - 1]}`,
330
- ...codeLines.slice(realLine, realLine + 2).map(line => `│ ${line}`)
330
+ ...codeLines.slice(realLine, realLine + 2).map((line) => `│ ${line}`),
331
331
  ];
332
- const message = `Error in JSDOM when running file '${file.path}' at line ${realLine}: ${e.message}\n${lineContents.join("\n")}`;
332
+ const message = `Error in JSDOM when running file '${file.path}' at line ${realLine}: ${e.message}\n${lineContents.join('\n')}`;
333
333
  const finalError = new Error(message);
334
334
  finalError.stack = `${message}\n${e.stack}`;
335
335
  collectedErrors.push(finalError);
@@ -1,5 +1,5 @@
1
- import type { ITestCompilerManager, ITestContext, ITestEnv, ITesterConfig, ITestRunner, TTestConfig } from "../type";
2
- export type TTestContextOptions = Omit<ITesterConfig, "steps">;
1
+ import type { ITestCompilerManager, ITestContext, ITestEnv, ITesterConfig, ITestRunner, TTestConfig } from '../type';
2
+ export type TTestContextOptions = Omit<ITesterConfig, 'steps'>;
3
3
  export declare class TestContext implements ITestContext {
4
4
  private config;
5
5
  protected errors: Error[];
@@ -43,7 +43,7 @@ class TestContext {
43
43
  }
44
44
  getRunner(file, env) {
45
45
  if (!this.config.runnerCreator) {
46
- throw new Error("TestContext: Runner creator not found");
46
+ throw new Error('TestContext: Runner creator not found');
47
47
  }
48
48
  const runnerKey = this.config.runnerCreator.key(this, this.config.name, file);
49
49
  let runner = this.runners.get(runnerKey);
@@ -53,7 +53,7 @@ class TestContext {
53
53
  getRunnerInfo[file] = {
54
54
  runnerKey,
55
55
  reused: true,
56
- runnerType: runner.constructor.name
56
+ runnerType: runner.constructor.name,
57
57
  };
58
58
  this.setValue(debug_1.DEBUG_SCOPES.RunGetRunner, getRunnerInfo);
59
59
  }
@@ -66,7 +66,7 @@ class TestContext {
66
66
  getRunnerInfo[file] = {
67
67
  runnerKey,
68
68
  reused: false,
69
- runnerType: runner.constructor.name
69
+ runnerType: runner.constructor.name,
70
70
  };
71
71
  this.setValue(debug_1.DEBUG_SCOPES.RunGetRunner, getRunnerInfo);
72
72
  }
@@ -86,7 +86,7 @@ class TestContext {
86
86
  return this.errors.length > 0;
87
87
  }
88
88
  emitError(err) {
89
- this.errors.push(typeof err === "string" ? new Error(err) : err);
89
+ this.errors.push(typeof err === 'string' ? new Error(err) : err);
90
90
  }
91
91
  getError() {
92
92
  return this.errors;
@@ -1,4 +1,4 @@
1
- import type { ITestContext, ITestEnv, ITester, ITesterConfig, ITestProcessor, TTestConfig, TTestRunnerCreator } from "../type";
1
+ import type { ITestContext, ITestEnv, ITester, ITesterConfig, ITestProcessor, TTestConfig, TTestRunnerCreator } from '../type';
2
2
  declare global {
3
3
  var testFilter: string | undefined;
4
4
  }
@@ -21,10 +21,10 @@ class BasicCaseCreator {
21
21
  create(name, src, dist, temp, caseOptions) {
22
22
  const options = {
23
23
  ...this._options,
24
- ...caseOptions
24
+ ...caseOptions,
25
25
  };
26
26
  const testConfig = this.readTestConfig(src);
27
- if (typeof options.testConfig === "function") {
27
+ if (typeof options.testConfig === 'function') {
28
28
  options.testConfig(testConfig);
29
29
  }
30
30
  const skipped = this.checkSkipped(src, testConfig, options);
@@ -33,7 +33,7 @@ class BasicCaseCreator {
33
33
  return;
34
34
  }
35
35
  if (options.clean) {
36
- this.clean([dist, temp || ""].filter(Boolean));
36
+ this.clean([dist, temp || ''].filter(Boolean));
37
37
  }
38
38
  const run = this.shouldRun(name);
39
39
  const tester = this.createTester(name, src, dist, temp, testConfig, options);
@@ -51,7 +51,7 @@ class BasicCaseCreator {
51
51
  }
52
52
  else {
53
53
  describe.skip(name, () => {
54
- it.skip("skipped", () => { });
54
+ it.skip('skipped', () => { });
55
55
  });
56
56
  }
57
57
  }
@@ -65,14 +65,14 @@ class BasicCaseCreator {
65
65
  }
66
66
  }
67
67
  else {
68
- it.skip("skipped", () => { });
68
+ it.skip('skipped', () => { });
69
69
  }
70
70
  }
71
71
  return tester;
72
72
  }
73
73
  shouldRun(name) {
74
74
  // TODO: more flexible filter
75
- if (typeof global.testFilter !== "string" || !global.testFilter) {
75
+ if (typeof global.testFilter !== 'string' || !global.testFilter) {
76
76
  return true;
77
77
  }
78
78
  return name.includes(global.testFilter);
@@ -94,11 +94,11 @@ class BasicCaseCreator {
94
94
  }).catch(() => {
95
95
  // prevent unhandled rejection
96
96
  });
97
- const description = typeof options.description === "function"
97
+ const description = typeof options.description === 'function'
98
98
  ? options.description(name, index)
99
99
  : index
100
100
  ? `step [${index}] should pass`
101
- : "should pass";
101
+ : 'should pass';
102
102
  it(description, async () => {
103
103
  const e = await stepSignal;
104
104
  if (e) {
@@ -116,8 +116,8 @@ class BasicCaseCreator {
116
116
  if (!tester.next() && context.hasError()) {
117
117
  const errors = context
118
118
  .getError()
119
- .map(i => `${i.stack}`.split("\n").join("\t\n"))
120
- .join("\n\n");
119
+ .map((i) => `${i.stack}`.split('\n').join('\t\n'))
120
+ .join('\n\n');
121
121
  throw new Error(`Case "${name}" failed at step ${tester.step + 1}:\n${errors}`);
122
122
  }
123
123
  stepSignalResolve();
@@ -150,7 +150,7 @@ class BasicCaseCreator {
150
150
  });
151
151
  let bailout = false;
152
152
  for (let index = 0; index < tester.total; index++) {
153
- const description = typeof options.description === "function"
153
+ const description = typeof options.description === 'function'
154
154
  ? options.description(name, index)
155
155
  : `step [${index}] should pass`;
156
156
  it(description, async () => {
@@ -170,8 +170,8 @@ class BasicCaseCreator {
170
170
  bailout = true;
171
171
  const errors = context
172
172
  .getError()
173
- .map(i => `${i.stack}`.split("\n").join("\t\n"))
174
- .join("\n\n");
173
+ .map((i) => `${i.stack}`.split('\n').join('\t\n'))
174
+ .join('\n\n');
175
175
  throw new Error(`Case "${name}" failed at step ${tester.step + 1}:\n${errors}`);
176
176
  }
177
177
  }, options.timeout || 60000);
@@ -195,7 +195,7 @@ class BasicCaseCreator {
195
195
  const runFn = async (fn) => {
196
196
  if (fn.length) {
197
197
  await new Promise((resolve, reject) => {
198
- fn(e => {
198
+ fn((e) => {
199
199
  if (e) {
200
200
  reject(e);
201
201
  }
@@ -207,7 +207,7 @@ class BasicCaseCreator {
207
207
  }
208
208
  else {
209
209
  const res = fn();
210
- if (typeof res?.then === "function") {
210
+ if (typeof res?.then === 'function') {
211
211
  await res;
212
212
  }
213
213
  }
@@ -232,19 +232,19 @@ class BasicCaseCreator {
232
232
  },
233
233
  expect,
234
234
  it: (description, fn) => {
235
- expect(typeof description === "string");
236
- expect(typeof fn === "function");
235
+ expect(typeof description === 'string');
236
+ expect(typeof fn === 'function');
237
237
  tasks.push([description, fn]);
238
238
  },
239
239
  beforeEach: (fn) => {
240
- expect(typeof fn === "function");
240
+ expect(typeof fn === 'function');
241
241
  beforeTasks.push(fn);
242
242
  },
243
243
  afterEach: (fn) => {
244
- expect(typeof fn === "function");
244
+ expect(typeof fn === 'function');
245
245
  afterTasks.push(fn);
246
246
  },
247
- rstest
247
+ rstest,
248
248
  };
249
249
  }
250
250
  createEnv(testConfig, options) {
@@ -256,7 +256,7 @@ class BasicCaseCreator {
256
256
  it,
257
257
  beforeEach,
258
258
  afterEach,
259
- rstest
259
+ rstest,
260
260
  };
261
261
  }
262
262
  clean(folders) {
@@ -265,21 +265,21 @@ class BasicCaseCreator {
265
265
  }
266
266
  }
267
267
  skip(name, reason) {
268
- it(typeof reason === "string" ? `filtered by ${reason}` : "filtered", () => { });
268
+ it(typeof reason === 'string' ? `filtered by ${reason}` : 'filtered', () => { });
269
269
  }
270
270
  readTestConfig(src) {
271
- const testConfigFile = node_path_1.default.join(src, "test.config.js");
271
+ const testConfigFile = node_path_1.default.join(src, 'test.config.js');
272
272
  return node_fs_1.default.existsSync(testConfigFile) ? require(testConfigFile) : {};
273
273
  }
274
274
  checkSkipped(src, testConfig, options) {
275
- const filterPath = node_path_1.default.join(src, "test.filter.js");
275
+ const filterPath = node_path_1.default.join(src, 'test.filter.js');
276
276
  // no test.filter.js, should not skip
277
277
  if (!node_fs_1.default.existsSync(filterPath)) {
278
278
  return false;
279
279
  }
280
280
  // test.filter.js exists, skip if it returns false|string|array
281
281
  const filtered = require(filterPath)(options, testConfig);
282
- if (typeof filtered === "string" || Array.isArray(filtered)) {
282
+ if (typeof filtered === 'string' || Array.isArray(filtered)) {
283
283
  return true;
284
284
  }
285
285
  return !filtered;
@@ -299,8 +299,8 @@ class BasicCaseCreator {
299
299
  name,
300
300
  src,
301
301
  dist,
302
- temp
303
- })
302
+ temp,
303
+ }),
304
304
  });
305
305
  }
306
306
  tryRunTask(concurrent) {
@@ -312,7 +312,7 @@ class BasicCaseCreator {
312
312
  }
313
313
  }
314
314
  getMaxConcurrent(concurrent) {
315
- return typeof concurrent === "number" ? concurrent : DEFAULT_MAX_CONCURRENT;
315
+ return typeof concurrent === 'number' ? concurrent : DEFAULT_MAX_CONCURRENT;
316
316
  }
317
317
  registerConcurrentTask(name, starter, concurrent) {
318
318
  this.tasks.push([name, starter]);
@@ -1,4 +1,4 @@
1
- import type { ITestContext } from "../type";
1
+ import type { ITestContext } from '../type';
2
2
  export declare function generateDebugReport(context: ITestContext): void;
3
3
  export declare const DEBUG_SCOPES: {
4
4
  CompilerOptionsReadConfigFile: string;
@@ -48,7 +48,7 @@ ${generateRunLogsReport(context)}
48
48
  ${generateRunErrorsReport(context)}
49
49
 
50
50
  `;
51
- const dist = context.getDist("debug.md");
51
+ const dist = context.getDist('debug.md');
52
52
  fs_extra_1.default.ensureDirSync(node_path_1.default.dirname(dist));
53
53
  fs_extra_1.default.writeFileSync(dist, report);
54
54
  }
@@ -66,7 +66,7 @@ function generateCaseMetaTestConfigReport(context) {
66
66
  ### Test Config
67
67
 
68
68
  \`\`\`js
69
- // ${node_path_1.default.resolve(context.getSource(), "./test.config.js")}
69
+ // ${node_path_1.default.resolve(context.getSource(), './test.config.js')}
70
70
  ${(0, javascript_stringify_1.stringify)(context.getTestConfig(), null, 2)}
71
71
  \`\`\`
72
72
  `;
@@ -74,7 +74,7 @@ ${(0, javascript_stringify_1.stringify)(context.getTestConfig(), null, 2)}
74
74
  function generateReadConfigFileReport(context) {
75
75
  const configFileInfo = context.getValue(exports.DEBUG_SCOPES.CompilerOptionsReadConfigFile);
76
76
  if (!configFileInfo)
77
- return "";
77
+ return '';
78
78
  return `
79
79
  ### Read Config File
80
80
 
@@ -97,7 +97,7 @@ ${(0, stringify_config_1.default)(finalOptions)}
97
97
  function generateCreateCompilerInstanceReport(context) {
98
98
  const instanceInfo = context.getValue(exports.DEBUG_SCOPES.CreateCompilerInstance);
99
99
  if (!instanceInfo)
100
- return "";
100
+ return '';
101
101
  return `
102
102
  ### Create Compiler Instance
103
103
 
@@ -108,98 +108,98 @@ function generateCreateCompilerInstanceReport(context) {
108
108
  function generateCreateCompilerSetPropertiesReport(context) {
109
109
  const setPropertiesInfo = context.getValue(exports.DEBUG_SCOPES.CreateCompilerSetProperties);
110
110
  if (!setPropertiesInfo || setPropertiesInfo.length === 0)
111
- return "";
111
+ return '';
112
112
  return `
113
113
  ### Set Properties
114
114
 
115
- ${setPropertiesInfo.map(p => `- ${p}`).join("\n")}
115
+ ${setPropertiesInfo.map((p) => `- ${p}`).join('\n')}
116
116
  `;
117
117
  }
118
118
  function generateBuildMethodReport(context) {
119
119
  const buildMethod = context.getValue(exports.DEBUG_SCOPES.BuildMethod);
120
120
  if (!buildMethod)
121
- return "";
121
+ return '';
122
122
  return `
123
123
  ### Build Method
124
124
 
125
125
  - Method: \`compiler.${buildMethod.method}()\`
126
- ${buildMethod.options ? `- Options:\n\`\`\`js\n${(0, javascript_stringify_1.stringify)(buildMethod.options, null, 2)}\n\`\`\`` : ""}
126
+ ${buildMethod.options ? `- Options:\n\`\`\`js\n${(0, javascript_stringify_1.stringify)(buildMethod.options, null, 2)}\n\`\`\`` : ''}
127
127
  `;
128
128
  }
129
129
  function generateBuildErrorReport(context) {
130
130
  const buildError = context.getValue(exports.DEBUG_SCOPES.BuildError);
131
131
  if (!buildError)
132
- return "";
132
+ return '';
133
133
  return `
134
134
  ### Build Error
135
135
 
136
136
  type: ${buildError.type}
137
137
 
138
- ${buildError.errors.map(e => `\`\`\`\n// message:\n${e.message}\n// stack:\n${e.stack}\n\`\`\``).join("\n\n")}
138
+ ${buildError.errors.map((e) => `\`\`\`\n// message:\n${e.message}\n// stack:\n${e.stack}\n\`\`\``).join('\n\n')}
139
139
  `;
140
140
  }
141
141
  function generateBuildWarningReport(context) {
142
142
  const buildWarning = context.getValue(exports.DEBUG_SCOPES.BuildWarning);
143
143
  if (!buildWarning)
144
- return "";
144
+ return '';
145
145
  return `
146
146
  ### Build Warning
147
147
 
148
- ${buildWarning.map(w => `\`\`\`\n// message:\n${w.message}\n// stack:\n${w.stack}\n\`\`\``).join("\n\n")}
148
+ ${buildWarning.map((w) => `\`\`\`\n// message:\n${w.message}\n// stack:\n${w.stack}\n\`\`\``).join('\n\n')}
149
149
  `;
150
150
  }
151
151
  function generateRunFindBundleReport(context) {
152
152
  const runFindBundle = context.getValue(exports.DEBUG_SCOPES.RunFindBundle);
153
153
  if (!runFindBundle)
154
- return "";
154
+ return '';
155
155
  return `
156
156
  ### Find Bundle
157
157
 
158
- ${runFindBundle.map(b => `- ${context.getDist(b)}`).join("\n")}
158
+ ${runFindBundle.map((b) => `- ${context.getDist(b)}`).join('\n')}
159
159
  `;
160
160
  }
161
161
  function generateRunGetRunnerReport(context) {
162
162
  const getRunnerInfo = context.getValue(exports.DEBUG_SCOPES.RunGetRunner);
163
163
  if (!getRunnerInfo)
164
- return "";
164
+ return '';
165
165
  return `
166
166
  ### Get Runner
167
167
 
168
168
  ${Object.entries(getRunnerInfo)
169
169
  .map(([file, info]) => `- ${file}: ${info.runnerKey} (Reused: ${info.reused}, Type: \`${info.runnerType}\`)`)
170
- .join("\n")}
170
+ .join('\n')}
171
171
  `;
172
172
  }
173
173
  function generateRunLogsReport(context) {
174
174
  const runLogs = context.getValue(exports.DEBUG_SCOPES.RunLogs);
175
175
  if (!runLogs)
176
- return "";
176
+ return '';
177
177
  return `
178
178
  ### Run Logs
179
179
 
180
- ${runLogs.map(l => `- ${l}`).join("\n")}
180
+ ${runLogs.map((l) => `- ${l}`).join('\n')}
181
181
  `;
182
182
  }
183
183
  function generateRunErrorsReport(context) {
184
184
  const runErrors = context.getValue(exports.DEBUG_SCOPES.RunErrors);
185
185
  if (!runErrors)
186
- return "";
186
+ return '';
187
187
  return `
188
188
  ### Run Errors
189
189
 
190
- ${runErrors.map(e => `\`\`\`\n// message:\n${e.message}\n// stack:\n${e.stack}\n\`\`\``).join("\n\n")}
190
+ ${runErrors.map((e) => `\`\`\`\n// message:\n${e.message}\n// stack:\n${e.stack}\n\`\`\``).join('\n\n')}
191
191
  `;
192
192
  }
193
193
  exports.DEBUG_SCOPES = {
194
- CompilerOptionsReadConfigFile: "compiler-options:read-config-file",
195
- CompilerOptionsFinalOptions: "compiler-options:final-options",
196
- CreateCompilerInstance: "create-compiler:instance",
197
- CreateCompilerSetProperties: "create-compiler:set-properties",
198
- BuildMethod: "build:method",
199
- BuildError: "build:error",
200
- BuildWarning: "build:warning",
201
- RunFindBundle: "run:find-bundle",
202
- RunGetRunner: "run:get-runner",
203
- RunLogs: "run:logs",
204
- RunErrors: "run:errors"
194
+ CompilerOptionsReadConfigFile: 'compiler-options:read-config-file',
195
+ CompilerOptionsFinalOptions: 'compiler-options:final-options',
196
+ CreateCompilerInstance: 'create-compiler:instance',
197
+ CreateCompilerSetProperties: 'create-compiler:set-properties',
198
+ BuildMethod: 'build:method',
199
+ BuildError: 'build:error',
200
+ BuildWarning: 'build:warning',
201
+ RunFindBundle: 'run:find-bundle',
202
+ RunGetRunner: 'run:get-runner',
203
+ RunLogs: 'run:logs',
204
+ RunErrors: 'run:errors',
205
205
  };
@@ -1,4 +1,4 @@
1
- import type { ITestContext, ITestEnv, ITester, ITesterConfig } from "../type";
1
+ import type { ITestContext, ITestEnv, ITester, ITesterConfig } from '../type';
2
2
  export declare class Tester implements ITester {
3
3
  private config;
4
4
  private context;