@rstest/core 0.0.2 → 0.0.4

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.
package/LICENSE CHANGED
@@ -139,9 +139,9 @@ Licensed under MIT license in the repository at https://github.com/jestjs/jest.g
139
139
 
140
140
  ### @jridgewell/trace-mapping
141
141
 
142
- Licensed under MIT license in the repository at git+https://github.com/jridgewell/trace-mapping.git.
142
+ Licensed under MIT license in the repository at git+https://github.com/jridgewell/sourcemaps.git.
143
143
 
144
- > Copyright 2022 Justin Ridgewell <justin@ridgewell.name>
144
+ > Copyright 2024 Justin Ridgewell <justin@ridgewell.name>
145
145
  >
146
146
  > Permission is hereby granted, free of charge, to any person obtaining a copy
147
147
  > of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -6,6 +6,14 @@
6
6
 
7
7
  Rstest is a testing framework powered by Rspack.
8
8
 
9
- ## 📖 License
9
+ ## Documentation
10
+
11
+ See [Documentation](https://rstest.rs).
12
+
13
+ ## Contributing
14
+
15
+ Please read the [Contributing Guide](https://github.com/web-infra-dev/rstest/blob/main/CONTRIBUTING.md).
16
+
17
+ ## License
10
18
 
11
19
  Rstest is licensed under the [MIT License](https://github.com/web-infra-dev/rstest/blob/main/LICENSE).
package/dist/285.js CHANGED
@@ -26,6 +26,7 @@ export const __webpack_modules__ = {
26
26
  const getRsbuildStats = await (0, _rsbuild__WEBPACK_IMPORTED_MODULE_4__.r)({
27
27
  name,
28
28
  globTestSourceEntries,
29
+ normalizedConfig: context.normalizedConfig,
29
30
  setupFiles,
30
31
  rsbuildInstance,
31
32
  rootPath
@@ -54,7 +55,7 @@ export const __webpack_modules__ = {
54
55
  const hasError = list.some((file)=>file.errors?.length);
55
56
  if (hasError) {
56
57
  const { printError } = await Promise.all([
57
- __webpack_require__.e("973"),
58
+ __webpack_require__.e("502"),
58
59
  __webpack_require__.e("355")
59
60
  ]).then(__webpack_require__.bind(__webpack_require__, "./src/utils/error.ts"));
60
61
  process.exitCode = 1;
package/dist/353.js CHANGED
@@ -323,7 +323,7 @@ export const __webpack_modules__ = {
323
323
  utils.kg.log(`${utils.$_.bgRed(' FAIL ')} ${(0, utils.aj)(relativePath)} ${nameStr.length ? `${utils.$_.dim(utils.Qd)} ${nameStr}` : ''}`);
324
324
  if (test.errors) {
325
325
  const { printError } = await Promise.all([
326
- __webpack_require__.e("973"),
326
+ __webpack_require__.e("502"),
327
327
  __webpack_require__.e("355")
328
328
  ]).then(__webpack_require__.bind(__webpack_require__, "./src/utils/error.ts"));
329
329
  for (const error of test.errors)await printError(error, getSourcemap, rootPath);
@@ -374,7 +374,8 @@ export const __webpack_modules__ = {
374
374
  const icon = isSlowCase && 'pass' === result.status ? utils.$_.yellow(statusStr[result.status]) : statusColorfulStr[result.status];
375
375
  const nameStr = (0, utils.Yz)(result);
376
376
  const duration = void 0 !== result.duration ? ` (${(0, utils.AS)(result.duration, false)})` : '';
377
- console.log(` ${icon} ${nameStr}${utils.$_.gray(duration)}`);
377
+ const retry = result.retryCount ? utils.$_.yellow(` (retry x${result.retryCount})`) : '';
378
+ console.log(` ${icon} ${nameStr}${utils.$_.gray(duration)}${retry}`);
378
379
  if (result.errors) for (const error of result.errors)console.error(utils.$_.red(` ${error.message}`));
379
380
  }
380
381
  }
@@ -451,7 +452,7 @@ export const __webpack_modules__ = {
451
452
  });
452
453
  return {
453
454
  command,
454
- version: "0.0.2",
455
+ version: "0.0.4",
455
456
  rootPath,
456
457
  reporters,
457
458
  snapshotManager,
package/dist/355.js CHANGED
@@ -7,7 +7,7 @@ export const __webpack_modules__ = {
7
7
  printError: ()=>printError
8
8
  });
9
9
  var node_fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("node:fs");
10
- var _jridgewell_trace_mapping__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("../../node_modules/.pnpm/@jridgewell+trace-mapping@0.3.25/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.mjs");
10
+ var _jridgewell_trace_mapping__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("../../node_modules/.pnpm/@jridgewell+trace-mapping@0.3.27/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.mjs");
11
11
  var stacktrace_parser__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("../../node_modules/.pnpm/stacktrace-parser@0.1.11/node_modules/stacktrace-parser/dist/stack-trace-parser.esm.js");
12
12
  var _utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./src/utils/index.ts");
13
13
  async function printError(error, getSourcemap, rootPath) {
@@ -1,8 +1,8 @@
1
1
  export const __webpack_ids__ = [
2
- "973"
2
+ "502"
3
3
  ];
4
4
  export const __webpack_modules__ = {
5
- "../../node_modules/.pnpm/@jridgewell+trace-mapping@0.3.25/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.mjs": function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
5
+ "../../node_modules/.pnpm/@jridgewell+trace-mapping@0.3.27/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.mjs": function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
6
6
  __webpack_require__.d(__webpack_exports__, {
7
7
  s7: ()=>TraceMap,
8
8
  Sk: ()=>originalPositionFor
@@ -212,7 +212,7 @@ export const __webpack_modules__ = {
212
212
  if (!path || addTrailingSlash && !path.endsWith('/..')) path += '/';
213
213
  url.path = path;
214
214
  }
215
- function resolve(input, base) {
215
+ function resolve_uri_resolve(input, base) {
216
216
  if (!input && !base) return '';
217
217
  const url = parseUrl(input);
218
218
  let inputType = url.type;
@@ -255,20 +255,21 @@ export const __webpack_modules__ = {
255
255
  return url.scheme + '//' + url.user + url.host + url.port + url.path + queryHash;
256
256
  }
257
257
  }
258
- function trace_mapping_resolve(input, base) {
259
- if (base && !base.endsWith('/')) base += '/';
260
- return resolve(input, base);
261
- }
262
258
  function stripFilename(path) {
263
- if (!path) return '';
264
- const index = path.lastIndexOf('/');
259
+ if (!path) return "";
260
+ const index = path.lastIndexOf("/");
265
261
  return path.slice(0, index + 1);
266
262
  }
267
- const COLUMN = 0;
268
- const SOURCES_INDEX = 1;
269
- const SOURCE_LINE = 2;
270
- const SOURCE_COLUMN = 3;
271
- const NAMES_INDEX = 4;
263
+ function resolver(mapUrl, sourceRoot) {
264
+ const from = stripFilename(mapUrl);
265
+ const prefix = sourceRoot ? sourceRoot + "/" : "";
266
+ return (source)=>resolve_uri_resolve(prefix + (source || ""), from);
267
+ }
268
+ var COLUMN = 0;
269
+ var SOURCES_INDEX = 1;
270
+ var SOURCE_LINE = 2;
271
+ var SOURCE_COLUMN = 3;
272
+ var NAMES_INDEX = 4;
272
273
  function maybeSort(mappings, owned) {
273
274
  const unsortedIndex = nextUnsortedSegmentLine(mappings, 0);
274
275
  if (unsortedIndex === mappings.length) return mappings;
@@ -291,7 +292,7 @@ export const __webpack_modules__ = {
291
292
  function trace_mapping_sortComparator(a, b) {
292
293
  return a[COLUMN] - b[COLUMN];
293
294
  }
294
- let found = false;
295
+ var found = false;
295
296
  function binarySearch(haystack, needle, low, high) {
296
297
  while(low <= high){
297
298
  const mid = low + (high - low >> 1);
@@ -337,15 +338,18 @@ export const __webpack_modules__ = {
337
338
  state.lastNeedle = needle;
338
339
  return state.lastIndex = binarySearch(haystack, needle, low, high);
339
340
  }
340
- const LINE_GTR_ZERO = '`line` must be greater than 0 (lines start at line 1)';
341
- const COL_GTR_EQ_ZERO = '`column` must be greater than or equal to 0 (columns start at column 0)';
342
- const LEAST_UPPER_BOUND = -1;
343
- const GREATEST_LOWER_BOUND = 1;
344
- class TraceMap {
341
+ function parse(map) {
342
+ return "string" == typeof map ? JSON.parse(map) : map;
343
+ }
344
+ var LINE_GTR_ZERO = "`line` must be greater than 0 (lines start at line 1)";
345
+ var COL_GTR_EQ_ZERO = "`column` must be greater than or equal to 0 (columns start at column 0)";
346
+ var LEAST_UPPER_BOUND = -1;
347
+ var GREATEST_LOWER_BOUND = 1;
348
+ var TraceMap = class {
345
349
  constructor(map, mapUrl){
346
- const isString = 'string' == typeof map;
350
+ const isString = "string" == typeof map;
347
351
  if (!isString && map._decodedMemo) return map;
348
- const parsed = isString ? JSON.parse(map) : map;
352
+ const parsed = parse(map);
349
353
  const { version, file, names, sourceRoot, sources, sourcesContent } = parsed;
350
354
  this.version = version;
351
355
  this.file = file;
@@ -354,21 +358,22 @@ export const __webpack_modules__ = {
354
358
  this.sources = sources;
355
359
  this.sourcesContent = sourcesContent;
356
360
  this.ignoreList = parsed.ignoreList || parsed.x_google_ignoreList || void 0;
357
- const from = trace_mapping_resolve(sourceRoot || '', stripFilename(mapUrl));
358
- this.resolvedSources = sources.map((s)=>trace_mapping_resolve(s || '', from));
361
+ const resolve = resolver(mapUrl, sourceRoot);
362
+ this.resolvedSources = sources.map(resolve);
359
363
  const { mappings } = parsed;
360
- if ('string' == typeof mappings) {
364
+ if ("string" == typeof mappings) {
361
365
  this._encoded = mappings;
362
366
  this._decoded = void 0;
363
- } else {
367
+ } else if (Array.isArray(mappings)) {
364
368
  this._encoded = void 0;
365
369
  this._decoded = maybeSort(mappings, isString);
366
- }
370
+ } else if (parsed.sections) throw new Error("TraceMap passed sectioned source map, please use FlattenMap export instead");
371
+ else throw new Error(`invalid source map: ${JSON.stringify(parsed)}`);
367
372
  this._decodedMemo = memoizedState();
368
373
  this._bySources = void 0;
369
374
  this._bySourceMemos = void 0;
370
375
  }
371
- }
376
+ };
372
377
  function cast(map) {
373
378
  return map;
374
379
  }
package/dist/629.js CHANGED
@@ -33,6 +33,7 @@ export const __webpack_modules__ = {
33
33
  const rsbuildInstance = await (0, _rsbuild__WEBPACK_IMPORTED_MODULE_2__.z)(context, globTestSourceEntries, setupFiles);
34
34
  const getRsbuildStats = await (0, _rsbuild__WEBPACK_IMPORTED_MODULE_2__.r)({
35
35
  name,
36
+ normalizedConfig: context.normalizedConfig,
36
37
  globTestSourceEntries,
37
38
  setupFiles,
38
39
  rsbuildInstance,
package/dist/813.js CHANGED
@@ -129,10 +129,11 @@ export const __webpack_modules__ = {
129
129
  $_: ()=>helper.$_,
130
130
  Yz: ()=>helper.Yz
131
131
  });
132
+ var constants = __webpack_require__("./src/utils/constants.ts");
132
133
  var helper = __webpack_require__("./src/utils/helper.ts");
133
134
  __webpack_require__("./src/utils/logger.ts");
135
+ __webpack_require__("node:fs");
134
136
  __webpack_require__("node:fs/promises");
135
137
  __webpack_require__("pathe");
136
- var constants = __webpack_require__("./src/utils/constants.ts");
137
138
  }
138
139
  };
package/dist/867.js CHANGED
@@ -277,6 +277,8 @@ export const __webpack_modules__ = {
277
277
  const isNot = utils.flag(this, 'negate');
278
278
  if (isNot) throw new Error('toThrowErrorMatchingInlineSnapshot cannot be used with "not"');
279
279
  const test = getTest('toThrowErrorMatchingInlineSnapshot', this);
280
+ const isInsideEach = test.each || test.inTestEach;
281
+ if (isInsideEach) throw new Error('InlineSnapshot cannot be used inside of test.each or describe.each');
280
282
  const expected = utils.flag(this, 'object');
281
283
  const error = utils.flag(this, 'error');
282
284
  const promise = utils.flag(this, 'promise');
@@ -675,7 +677,7 @@ export const __webpack_modules__ = {
675
677
  }
676
678
  ]
677
679
  };
678
- } catch (error) {
680
+ } catch (_err) {
679
681
  result = {
680
682
  status: 'pass',
681
683
  parentNames: test.parentNames,
@@ -811,6 +813,7 @@ export const __webpack_modules__ = {
811
813
  retryCount++;
812
814
  }while (retryCount <= retry && 'fail' === result.status);
813
815
  result.duration = RealDate.now() - start;
816
+ result.retryCount = retryCount - 1;
814
817
  hooks.onTestCaseResult?.(result);
815
818
  results.push(result);
816
819
  }
@@ -1725,10 +1728,11 @@ export const __webpack_modules__ = {
1725
1728
  $_: ()=>helper.$_,
1726
1729
  Yz: ()=>helper.Yz
1727
1730
  });
1731
+ var constants = __webpack_require__("./src/utils/constants.ts");
1728
1732
  var helper = __webpack_require__("./src/utils/helper.ts");
1729
1733
  __webpack_require__("./src/utils/logger.ts");
1734
+ __webpack_require__("node:fs");
1730
1735
  __webpack_require__("node:fs/promises");
1731
1736
  __webpack_require__("pathe");
1732
- var constants = __webpack_require__("./src/utils/constants.ts");
1733
1737
  }
1734
1738
  };
package/dist/992.js CHANGED
@@ -37,27 +37,27 @@ export const __webpack_modules__ = {
37
37
  ...setupFiles
38
38
  };
39
39
  };
40
+ config.watchOptions ??= {};
41
+ config.watchOptions.ignored = (0, utils.XQ)(config.watchOptions.ignored || []);
42
+ if (0 === config.watchOptions.ignored.length) config.watchOptions.ignored.push('**/.git', '**/node_modules');
43
+ config.watchOptions.ignored.push(utils.f1);
40
44
  } else {
45
+ config.watch = false;
46
+ config.watchOptions ??= {};
47
+ config.watchOptions.ignored = '**/**';
41
48
  const sourceEntries = await globTestSourceEntries();
42
49
  config.entry = {
43
50
  ...sourceEntries,
44
51
  ...setupFiles
45
52
  };
46
53
  }
47
- config.watchOptions ??= {};
48
- config.watchOptions.ignored = (0, utils.XQ)(config.watchOptions.ignored || []);
49
- if (0 === config.watchOptions.ignored.length) config.watchOptions.ignored.push('**/.git', '**/node_modules');
50
- config.watchOptions.ignored.push(utils.f1);
51
54
  });
52
55
  }
53
56
  });
54
57
  class IgnoreModuleNotFoundErrorPlugin {
55
58
  apply(compiler) {
56
59
  compiler.hooks.done.tap('Rstest:IgnoreModuleNotFoundPlugin', (stats)=>{
57
- stats.compilation.errors = stats.compilation.errors.filter((error)=>{
58
- if (/Module not found/.test(error.message)) return false;
59
- return true;
60
- });
60
+ for(let i = stats.compilation.errors.length - 1; i >= 0; i--)if (/Module not found/.test(stats.compilation.errors[i].message)) stats.compilation.errors.splice(i, 1);
61
61
  });
62
62
  }
63
63
  }
@@ -75,7 +75,7 @@ export const __webpack_modules__ = {
75
75
  };
76
76
  const isMultiCompiler = (compiler)=>'compilers' in compiler && Array.isArray(compiler.compilers);
77
77
  const autoExternalNodeModules = ({ context, request, dependencyType, getResolve }, callback)=>{
78
- if (!request || request.startsWith('node:')) return callback();
78
+ if (!request) return callback();
79
79
  if (request.startsWith('@swc/helpers/')) return callback();
80
80
  const doExternal = (externalPath = request)=>{
81
81
  callback(void 0, externalPath, 'commonjs' === dependencyType ? 'commonjs' : 'module-import');
@@ -88,10 +88,20 @@ export const __webpack_modules__ = {
88
88
  return callback();
89
89
  });
90
90
  };
91
+ const autoExternalNodeBuiltin = ({ request, dependencyType }, callback)=>{
92
+ if (!request) return callback();
93
+ const isNodeBuiltin = utils.Tn.some((builtin)=>{
94
+ if ('string' == typeof builtin) return builtin === request;
95
+ return builtin.test(request);
96
+ });
97
+ if (isNodeBuiltin) callback(void 0, request, 'commonjs' === dependencyType ? 'commonjs' : 'module-import');
98
+ else callback();
99
+ };
91
100
  const prepareRsbuild = async (context, globTestSourceEntries, setupFiles)=>{
92
- const { command, normalizedConfig: { name, plugins, resolve, source, output, tools, testEnvironment } } = context;
93
- core_.logger.level = (0, utils.L1)() ? 'verbose' : 'error';
94
- const writeToDisk = 'true' === process.env.DEBUG_RSTEST_OUTPUTS;
101
+ const { command, normalizedConfig: { name, plugins, resolve, source, output, tools, testEnvironment, performance, dev = {} } } = context;
102
+ const debugMode = (0, utils.L1)();
103
+ core_.logger.level = debugMode ? 'verbose' : 'error';
104
+ const writeToDisk = dev.writeToDisk || debugMode;
95
105
  const rsbuildInstance = await (0, core_.createRsbuild)({
96
106
  rsbuildConfig: {
97
107
  tools,
@@ -104,6 +114,7 @@ export const __webpack_modules__ = {
104
114
  strictPort: false,
105
115
  middlewareMode: true
106
116
  },
117
+ performance,
107
118
  environments: {
108
119
  [name]: {
109
120
  dev: {
@@ -122,25 +133,28 @@ export const __webpack_modules__ = {
122
133
  distPath: {
123
134
  root: utils.Nk
124
135
  },
125
- externals: [
126
- {
127
- '@rstest/core': 'global @rstest/core'
128
- },
129
- 'node' === testEnvironment ? autoExternalNodeModules : {}
130
- ],
131
136
  target: 'node'
132
137
  },
133
138
  tools: {
134
139
  rspack: (config)=>{
135
140
  config.output ??= {};
136
141
  config.output.iife = false;
137
- config.externalsPresets = {
138
- node: true
139
- };
142
+ config.output.importFunctionName = '__rstest_dynamic_import__';
140
143
  config.output.devtoolModuleFilenameTemplate = '[absolute-resource-path]';
141
- config.plugins.push(new core_.rspack.RstestPlugin({
142
- injectModulePathName: true
144
+ config.plugins.push(new core_.rspack.experiments.RstestPlugin({
145
+ injectModulePathName: true,
146
+ hoistMockModule: true,
147
+ importMetaPathName: true,
148
+ manualMockRoot: context.rootPath
143
149
  }));
150
+ config.externals = (0, utils.XQ)(config.externals) || [];
151
+ config.externals.unshift({
152
+ '@rstest/core': 'global @rstest/core'
153
+ });
154
+ if ('node' === testEnvironment) config.externals.push(autoExternalNodeModules);
155
+ config.externalsPresets ??= {};
156
+ config.externalsPresets.node = false;
157
+ config.externals.push(autoExternalNodeBuiltin);
144
158
  config.module.parser ??= {};
145
159
  config.module.parser.javascript = {
146
160
  importDynamic: false,
@@ -155,13 +169,11 @@ export const __webpack_modules__ = {
155
169
  ];
156
170
  }
157
171
  config.optimization = {
158
- ...config.optimization || {},
159
172
  moduleIds: 'named',
160
173
  chunkIds: 'named',
161
- splitChunks: {
162
- chunks: 'all',
163
- minSize: 0,
164
- maxInitialRequests: Number.POSITIVE_INFINITY
174
+ ...config.optimization || {},
175
+ runtimeChunk: {
176
+ name: 'runtime'
165
177
  }
166
178
  };
167
179
  }
@@ -180,7 +192,7 @@ export const __webpack_modules__ = {
180
192
  });
181
193
  return rsbuildInstance;
182
194
  };
183
- const createRsbuildServer = async ({ name, globTestSourceEntries, setupFiles, rsbuildInstance })=>{
195
+ const createRsbuildServer = async ({ name, globTestSourceEntries, setupFiles, rsbuildInstance, normalizedConfig })=>{
184
196
  let rspackCompiler;
185
197
  const rstestCompilerPlugin = {
186
198
  name: 'rstest:compiler',
@@ -197,7 +209,10 @@ export const __webpack_modules__ = {
197
209
  getPortSilently: true
198
210
  });
199
211
  if ((0, utils.L1)()) await rsbuildInstance.inspectConfig({
200
- writeToDisk: true
212
+ writeToDisk: true,
213
+ extraConfigs: {
214
+ retest: normalizedConfig
215
+ }
201
216
  });
202
217
  const outputFileSystem = (isMultiCompiler(rspackCompiler) ? rspackCompiler.compilers[0].outputFileSystem : rspackCompiler.outputFileSystem) || external_node_fs_["default"];
203
218
  const getRsbuildStats = async ()=>{
package/dist/cli.js CHANGED
@@ -2292,6 +2292,7 @@ var __webpack_modules__ = {
2292
2292
  $_: ()=>picocolors__WEBPACK_IMPORTED_MODULE_2___default.a,
2293
2293
  AS: ()=>prettyTime,
2294
2294
  H: ()=>parsePosix,
2295
+ Tn: ()=>NODE_BUILTINS,
2295
2296
  XQ: ()=>castArray,
2296
2297
  Yz: ()=>getTaskNameWithPrefix,
2297
2298
  Z: ()=>formatError,
@@ -2359,6 +2360,64 @@ var __webpack_modules__ = {
2359
2360
  0,
2360
2361
  0
2361
2362
  ];
2363
+ const NODE_BUILTINS = [
2364
+ 'assert',
2365
+ 'assert/strict',
2366
+ 'async_hooks',
2367
+ 'buffer',
2368
+ 'child_process',
2369
+ 'cluster',
2370
+ 'console',
2371
+ 'constants',
2372
+ 'crypto',
2373
+ 'dgram',
2374
+ 'diagnostics_channel',
2375
+ 'dns',
2376
+ 'dns/promises',
2377
+ 'domain',
2378
+ 'events',
2379
+ 'fs',
2380
+ 'fs/promises',
2381
+ 'http',
2382
+ 'http2',
2383
+ 'https',
2384
+ 'inspector',
2385
+ 'inspector/promises',
2386
+ 'module',
2387
+ 'net',
2388
+ 'os',
2389
+ 'path',
2390
+ 'path/posix',
2391
+ 'path/win32',
2392
+ 'perf_hooks',
2393
+ 'process',
2394
+ 'punycode',
2395
+ 'querystring',
2396
+ 'readline',
2397
+ 'readline/promises',
2398
+ 'repl',
2399
+ 'stream',
2400
+ 'stream/consumers',
2401
+ 'stream/promises',
2402
+ 'stream/web',
2403
+ 'string_decoder',
2404
+ 'sys',
2405
+ 'timers',
2406
+ 'timers/promises',
2407
+ 'tls',
2408
+ 'trace_events',
2409
+ 'tty',
2410
+ 'url',
2411
+ 'util',
2412
+ 'util/types',
2413
+ 'v8',
2414
+ 'vm',
2415
+ 'wasi',
2416
+ 'worker_threads',
2417
+ 'zlib',
2418
+ /^node:/,
2419
+ 'pnpapi'
2420
+ ];
2362
2421
  },
2363
2422
  "./src/utils/index.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
2364
2423
  __webpack_require__.d(__webpack_exports__, {
@@ -2371,8 +2430,9 @@ var __webpack_modules__ = {
2371
2430
  mP: ()=>helper.mP,
2372
2431
  Ps: ()=>formatTestPath,
2373
2432
  XQ: ()=>helper.XQ,
2374
- $_: ()=>helper.$_,
2375
2433
  Nk: ()=>constants.Nk,
2434
+ Tn: ()=>helper.Tn,
2435
+ $_: ()=>helper.$_,
2376
2436
  Yz: ()=>helper.Yz,
2377
2437
  L1: ()=>logger.L,
2378
2438
  v8: ()=>helper.v8,
@@ -2380,8 +2440,10 @@ var __webpack_modules__ = {
2380
2440
  f1: ()=>constants.f1,
2381
2441
  AS: ()=>helper.AS
2382
2442
  });
2443
+ var constants = __webpack_require__("./src/utils/constants.ts");
2383
2444
  var helper = __webpack_require__("./src/utils/helper.ts");
2384
2445
  var logger = __webpack_require__("./src/utils/logger.ts");
2446
+ var external_node_fs_ = __webpack_require__("node:fs");
2385
2447
  var promises_ = __webpack_require__("node:fs/promises");
2386
2448
  var external_pathe_ = __webpack_require__("pathe");
2387
2449
  var dist = __webpack_require__("../../node_modules/.pnpm/tinyglobby@0.2.14/node_modules/tinyglobby/dist/index.mjs");
@@ -2398,6 +2460,7 @@ var __webpack_modules__ = {
2398
2460
  });
2399
2461
  };
2400
2462
  const hasInSourceTestCode = (code)=>code.includes('import.meta.rstest');
2463
+ const formatTestEntryName = (name)=>name.replace(/\.*[/\\]/g, '_').replace(/\./g, '~');
2401
2464
  const getTestEntries = async ({ include, exclude, root, fileFilters, includeSource })=>{
2402
2465
  const testFiles = await (0, dist.zA)(include, {
2403
2466
  cwd: root,
@@ -2424,18 +2487,23 @@ var __webpack_modules__ = {
2424
2487
  }));
2425
2488
  }
2426
2489
  return Object.fromEntries(filterFiles(testFiles, fileFilters, root).map((entry)=>{
2427
- const name = external_pathe_["default"].relative(root, entry);
2490
+ const relativePath = external_pathe_["default"].relative(root, entry);
2428
2491
  return [
2429
- name,
2492
+ formatTestEntryName(relativePath),
2430
2493
  entry
2431
2494
  ];
2432
2495
  }));
2433
2496
  };
2434
2497
  const getSetupFiles = (setups, rootPath)=>Object.fromEntries((0, helper.XQ)(setups).map((setupFile)=>{
2435
2498
  const setupFilePath = (0, helper.ZY)(rootPath, setupFile);
2436
- const name = external_pathe_["default"].relative(rootPath, setupFilePath);
2499
+ if (!(0, external_node_fs_.existsSync)(setupFilePath)) {
2500
+ let errorMessage = `Setup file ${helper.$_.red(setupFile)} not found`;
2501
+ if (setupFilePath !== setupFile) errorMessage += helper.$_.gray(` (resolved path: ${setupFilePath})`);
2502
+ throw errorMessage;
2503
+ }
2504
+ const relativePath = external_pathe_["default"].relative(rootPath, setupFilePath);
2437
2505
  return [
2438
- name,
2506
+ formatTestEntryName(relativePath),
2439
2507
  setupFilePath
2440
2508
  ];
2441
2509
  }));
@@ -2448,7 +2516,6 @@ var __webpack_modules__ = {
2448
2516
  if (external_pathe_["default"].isAbsolute(testPath) && testPath.includes(root)) testPath = external_pathe_["default"].relative(root, testPath);
2449
2517
  return prettyTestPath(testPath);
2450
2518
  };
2451
- var constants = __webpack_require__("./src/utils/constants.ts");
2452
2519
  },
2453
2520
  "./src/utils/logger.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
2454
2521
  __webpack_require__.d(__webpack_exports__, {
@@ -3580,7 +3647,7 @@ function prepareCli() {
3580
3647
  if (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) console.log();
3581
3648
  }
3582
3649
  function showRstest() {
3583
- logger.k.greet(" Rstest v0.0.2");
3650
+ logger.k.greet(" Rstest v0.0.4");
3584
3651
  logger.k.log('');
3585
3652
  }
3586
3653
  const applyCommonOptions = (cli)=>{
@@ -3624,7 +3691,7 @@ async function initCli(options) {
3624
3691
  function setupCommands() {
3625
3692
  const cli = dist('rstest');
3626
3693
  cli.help();
3627
- cli.version("0.0.2");
3694
+ cli.version("0.0.4");
3628
3695
  applyCommonOptions(cli);
3629
3696
  cli.command('[...filters]', 'run tests').action(async (filters, options)=>{
3630
3697
  showRstest();
package/dist/worker.js CHANGED
@@ -7,6 +7,7 @@ import * as __WEBPACK_EXTERNAL_MODULE_chai__ from "chai";
7
7
  import * as __WEBPACK_EXTERNAL_MODULE_fs__ from "fs";
8
8
  import * as __WEBPACK_EXTERNAL_MODULE_node_assert_3e74d44e__ from "node:assert";
9
9
  import * as __WEBPACK_EXTERNAL_MODULE_node_console_8631dfae__ from "node:console";
10
+ import * as __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__ from "node:fs";
10
11
  import * as __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__ from "node:fs/promises";
11
12
  import * as __WEBPACK_EXTERNAL_MODULE_node_os_74b4b876__ from "node:os";
12
13
  import * as __WEBPACK_EXTERNAL_MODULE_node_timers_7045d530__ from "node:timers";
@@ -2886,7 +2887,7 @@ var __webpack_modules__ = {
2886
2887
  return -1 !== position && (-1 === terminatorPosition || position < terminatorPosition);
2887
2888
  };
2888
2889
  },
2889
- "../../node_modules/.pnpm/jest-diff@30.0.2/node_modules/jest-diff/build/index.js": function(module, __unused_webpack_exports, __webpack_require__) {
2890
+ "../../node_modules/.pnpm/jest-diff@30.0.3/node_modules/jest-diff/build/index.js": function(module, __unused_webpack_exports, __webpack_require__) {
2890
2891
  /*!
2891
2892
  * /**
2892
2893
  * * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -3200,6 +3201,7 @@ var __webpack_modules__ = {
3200
3201
  exports.printDiffLines = exports.diffLinesUnified2 = exports.diffLinesUnified = exports.diffLinesRaw = void 0;
3201
3202
  var _diffSequences = _interopRequireDefault(__webpack_require__("../../node_modules/.pnpm/@jest+diff-sequences@30.0.1/node_modules/@jest/diff-sequences/build/index.js"));
3202
3203
  var _cleanupSemantic = __nested_webpack_require_20541_20560__("./src/cleanupSemantic.ts");
3204
+ var _escapeControlCharacters = __nested_webpack_require_20541_20560__("./src/escapeControlCharacters.ts");
3203
3205
  var _joinAlignedDiffs = __nested_webpack_require_20541_20560__("./src/joinAlignedDiffs.ts");
3204
3206
  var _normalizeDiffOptions = __nested_webpack_require_20541_20560__("./src/normalizeDiffOptions.ts");
3205
3207
  function _interopRequireDefault(e) {
@@ -3246,7 +3248,7 @@ var __webpack_modules__ = {
3246
3248
  };
3247
3249
  const printDiffLines = (diffs, options)=>printAnnotation(options, countChanges(diffs)) + (options.expand ? (0, _joinAlignedDiffs.joinAlignedDiffsExpand)(diffs, options) : (0, _joinAlignedDiffs.joinAlignedDiffsNoExpand)(diffs, options));
3248
3250
  exports.printDiffLines = printDiffLines;
3249
- const diffLinesUnified = (aLines, bLines, options)=>printDiffLines(diffLinesRaw(isEmptyString(aLines) ? [] : aLines, isEmptyString(bLines) ? [] : bLines), (0, _normalizeDiffOptions.normalizeDiffOptions)(options));
3251
+ const diffLinesUnified = (aLines, bLines, options)=>printDiffLines(diffLinesRaw(isEmptyString(aLines) ? [] : aLines.map(_escapeControlCharacters.escapeControlCharacters), isEmptyString(bLines) ? [] : bLines.map(_escapeControlCharacters.escapeControlCharacters)), (0, _normalizeDiffOptions.normalizeDiffOptions)(options));
3250
3252
  exports.diffLinesUnified = diffLinesUnified;
3251
3253
  const diffLinesUnified2 = (aLinesDisplay, bLinesDisplay, aLinesCompare, bLinesCompare, options)=>{
3252
3254
  if (isEmptyString(aLinesDisplay) && isEmptyString(aLinesCompare)) {
@@ -3297,13 +3299,13 @@ var __webpack_modules__ = {
3297
3299
  };
3298
3300
  exports.diffLinesRaw = diffLinesRaw;
3299
3301
  },
3300
- "./src/diffStrings.ts": (__unused_webpack_module, exports, __nested_webpack_require_26333_26352__)=>{
3302
+ "./src/diffStrings.ts": (__unused_webpack_module, exports, __nested_webpack_require_26529_26548__)=>{
3301
3303
  Object.defineProperty(exports, "__esModule", {
3302
3304
  value: true
3303
3305
  });
3304
3306
  exports["default"] = void 0;
3305
3307
  var _diffSequences = _interopRequireDefault(__webpack_require__("../../node_modules/.pnpm/@jest+diff-sequences@30.0.1/node_modules/@jest/diff-sequences/build/index.js"));
3306
- var _cleanupSemantic = __nested_webpack_require_26333_26352__("./src/cleanupSemantic.ts");
3308
+ var _cleanupSemantic = __nested_webpack_require_26529_26548__("./src/cleanupSemantic.ts");
3307
3309
  function _interopRequireDefault(e) {
3308
3310
  return e && e.__esModule ? e : {
3309
3311
  default: e
@@ -3328,12 +3330,34 @@ var __webpack_modules__ = {
3328
3330
  };
3329
3331
  exports["default"] = diffStrings;
3330
3332
  },
3331
- "./src/getAlignedDiffs.ts": (__unused_webpack_module, exports, __nested_webpack_require_28166_28185__)=>{
3333
+ "./src/escapeControlCharacters.ts": (__unused_webpack_module, exports)=>{
3334
+ Object.defineProperty(exports, "__esModule", {
3335
+ value: true
3336
+ });
3337
+ exports.escapeControlCharacters = void 0;
3338
+ const escapeControlCharacters = (str)=>str.replaceAll(/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F-\u009F]/g, (match)=>{
3339
+ switch(match){
3340
+ case '\b':
3341
+ return '\\b';
3342
+ case '\f':
3343
+ return '\\f';
3344
+ case '\v':
3345
+ return '\\v';
3346
+ default:
3347
+ {
3348
+ const code = match.codePointAt(0);
3349
+ return `\\x${code.toString(16).padStart(2, '0')}`;
3350
+ }
3351
+ }
3352
+ });
3353
+ exports.escapeControlCharacters = escapeControlCharacters;
3354
+ },
3355
+ "./src/getAlignedDiffs.ts": (__unused_webpack_module, exports, __nested_webpack_require_29271_29290__)=>{
3332
3356
  Object.defineProperty(exports, "__esModule", {
3333
3357
  value: true
3334
3358
  });
3335
3359
  exports["default"] = void 0;
3336
- var _cleanupSemantic = __nested_webpack_require_28166_28185__("./src/cleanupSemantic.ts");
3360
+ var _cleanupSemantic = __nested_webpack_require_29271_29290__("./src/cleanupSemantic.ts");
3337
3361
  const concatenateRelevantDiffs = (op, diffs, changeColor)=>diffs.reduce((reduced, diff)=>reduced + (diff[0] === _cleanupSemantic.DIFF_EQUAL ? diff[1] : diff[0] === op && diff[1].length > 0 ? changeColor(diff[1]) : ''), '');
3338
3362
  class ChangeBuffer {
3339
3363
  op;
@@ -3439,12 +3463,12 @@ var __webpack_modules__ = {
3439
3463
  };
3440
3464
  exports["default"] = getAlignedDiffs;
3441
3465
  },
3442
- "./src/joinAlignedDiffs.ts": (__unused_webpack_module, exports, __nested_webpack_require_35036_35055__)=>{
3466
+ "./src/joinAlignedDiffs.ts": (__unused_webpack_module, exports, __nested_webpack_require_36141_36160__)=>{
3443
3467
  Object.defineProperty(exports, "__esModule", {
3444
3468
  value: true
3445
3469
  });
3446
3470
  exports.joinAlignedDiffsNoExpand = exports.joinAlignedDiffsExpand = void 0;
3447
- var _cleanupSemantic = __nested_webpack_require_35036_35055__("./src/cleanupSemantic.ts");
3471
+ var _cleanupSemantic = __nested_webpack_require_36141_36160__("./src/cleanupSemantic.ts");
3448
3472
  const formatTrailingSpaces = (line, trailingSpaceFormatter)=>line.replace(/\s+$/, (match)=>trailingSpaceFormatter(match));
3449
3473
  const printDiffLine = (line, isFirstOrLast, color, indicator, trailingSpaceFormatter, emptyFirstOrLastLinePlaceholder)=>0 === line.length ? ' ' === indicator ? isFirstOrLast && emptyFirstOrLastLinePlaceholder.length > 0 ? color(`${indicator} ${emptyFirstOrLastLinePlaceholder}`) : '' : color(indicator) : color(`${indicator} ${formatTrailingSpaces(line, trailingSpaceFormatter)}`);
3450
3474
  const printDeleteLine = (line, isFirstOrLast, { aColor, aIndicator, changeLineTrailingSpaceColor, emptyFirstOrLastLinePlaceholder })=>printDiffLine(line, isFirstOrLast, aColor, aIndicator, changeLineTrailingSpaceColor, emptyFirstOrLastLinePlaceholder);
@@ -3612,16 +3636,16 @@ var __webpack_modules__ = {
3612
3636
  });
3613
3637
  exports.normalizeDiffOptions = normalizeDiffOptions;
3614
3638
  },
3615
- "./src/printDiffs.ts": (__unused_webpack_module, exports, __nested_webpack_require_44431_44450__)=>{
3639
+ "./src/printDiffs.ts": (__unused_webpack_module, exports, __nested_webpack_require_45536_45555__)=>{
3616
3640
  Object.defineProperty(exports, "__esModule", {
3617
3641
  value: true
3618
3642
  });
3619
3643
  exports.diffStringsUnified = exports.diffStringsRaw = void 0;
3620
- var _cleanupSemantic = __nested_webpack_require_44431_44450__("./src/cleanupSemantic.ts");
3621
- var _diffLines = __nested_webpack_require_44431_44450__("./src/diffLines.ts");
3622
- var _diffStrings = _interopRequireDefault(__nested_webpack_require_44431_44450__("./src/diffStrings.ts"));
3623
- var _getAlignedDiffs = _interopRequireDefault(__nested_webpack_require_44431_44450__("./src/getAlignedDiffs.ts"));
3624
- var _normalizeDiffOptions = __nested_webpack_require_44431_44450__("./src/normalizeDiffOptions.ts");
3644
+ var _cleanupSemantic = __nested_webpack_require_45536_45555__("./src/cleanupSemantic.ts");
3645
+ var _diffLines = __nested_webpack_require_45536_45555__("./src/diffLines.ts");
3646
+ var _diffStrings = _interopRequireDefault(__nested_webpack_require_45536_45555__("./src/diffStrings.ts"));
3647
+ var _getAlignedDiffs = _interopRequireDefault(__nested_webpack_require_45536_45555__("./src/getAlignedDiffs.ts"));
3648
+ var _normalizeDiffOptions = __nested_webpack_require_45536_45555__("./src/normalizeDiffOptions.ts");
3625
3649
  function _interopRequireDefault(e) {
3626
3650
  return e && e.__esModule ? e : {
3627
3651
  default: e
@@ -3656,13 +3680,13 @@ var __webpack_modules__ = {
3656
3680
  }
3657
3681
  };
3658
3682
  var __webpack_module_cache__ = {};
3659
- function __nested_webpack_require_47190__(moduleId) {
3683
+ function __nested_webpack_require_48295__(moduleId) {
3660
3684
  var cachedModule = __webpack_module_cache__[moduleId];
3661
3685
  if (void 0 !== cachedModule) return cachedModule.exports;
3662
3686
  var module = __webpack_module_cache__[moduleId] = {
3663
3687
  exports: {}
3664
3688
  };
3665
- __webpack_modules__[moduleId](module, module.exports, __nested_webpack_require_47190__);
3689
+ __webpack_modules__[moduleId](module, module.exports, __nested_webpack_require_48295__);
3666
3690
  return module.exports;
3667
3691
  }
3668
3692
  var __nested_webpack_exports__ = {};
@@ -3729,11 +3753,12 @@ var __webpack_modules__ = {
3729
3753
  var _chalk = _interopRequireDefault(__webpack_require__("../../node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/source/index.js"));
3730
3754
  var _getType = __webpack_require__("../../node_modules/.pnpm/@jest+get-type@30.0.1/node_modules/@jest/get-type/build/index.js");
3731
3755
  var _prettyFormat = __webpack_require__("../../node_modules/.pnpm/pretty-format@30.0.2/node_modules/pretty-format/build/index.js");
3732
- var _cleanupSemantic = __nested_webpack_require_47190__("./src/cleanupSemantic.ts");
3733
- var _constants = __nested_webpack_require_47190__("./src/constants.ts");
3734
- var _diffLines = __nested_webpack_require_47190__("./src/diffLines.ts");
3735
- var _normalizeDiffOptions = __nested_webpack_require_47190__("./src/normalizeDiffOptions.ts");
3736
- var _printDiffs = __nested_webpack_require_47190__("./src/printDiffs.ts");
3756
+ var _cleanupSemantic = __nested_webpack_require_48295__("./src/cleanupSemantic.ts");
3757
+ var _constants = __nested_webpack_require_48295__("./src/constants.ts");
3758
+ var _diffLines = __nested_webpack_require_48295__("./src/diffLines.ts");
3759
+ var _escapeControlCharacters = __nested_webpack_require_48295__("./src/escapeControlCharacters.ts");
3760
+ var _normalizeDiffOptions = __nested_webpack_require_48295__("./src/normalizeDiffOptions.ts");
3761
+ var _printDiffs = __nested_webpack_require_48295__("./src/printDiffs.ts");
3737
3762
  function _interopRequireDefault(e) {
3738
3763
  return e && e.__esModule ? e : {
3739
3764
  default: e
@@ -3776,7 +3801,7 @@ var __webpack_modules__ = {
3776
3801
  if (omitDifference) return null;
3777
3802
  switch(aType){
3778
3803
  case 'string':
3779
- return (0, _diffLines.diffLinesUnified)(a.split('\n'), b.split('\n'), options);
3804
+ return (0, _diffLines.diffLinesUnified)((0, _escapeControlCharacters.escapeControlCharacters)(a).split('\n'), (0, _escapeControlCharacters.escapeControlCharacters)(b).split('\n'), options);
3780
3805
  case 'boolean':
3781
3806
  case 'number':
3782
3807
  return comparePrimitive(a, b, options);
@@ -4953,7 +4978,7 @@ var __webpack_modules__ = {
4953
4978
  o: ()=>formatTestError
4954
4979
  });
4955
4980
  var external_node_util_ = __webpack_require__("node:util");
4956
- var build = __webpack_require__("../../node_modules/.pnpm/jest-diff@30.0.2/node_modules/jest-diff/build/index.js");
4981
+ var build = __webpack_require__("../../node_modules/.pnpm/jest-diff@30.0.3/node_modules/jest-diff/build/index.js");
4957
4982
  build.DIFF_DELETE;
4958
4983
  build.DIFF_EQUAL;
4959
4984
  build.DIFF_INSERT;
@@ -5391,6 +5416,9 @@ var __webpack_modules__ = {
5391
5416
  "node:console": function(module) {
5392
5417
  module.exports = __WEBPACK_EXTERNAL_MODULE_node_console_8631dfae__;
5393
5418
  },
5419
+ "node:fs": function(module) {
5420
+ module.exports = __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__;
5421
+ },
5394
5422
  "node:fs/promises": function(module) {
5395
5423
  module.exports = __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__;
5396
5424
  },
@@ -5600,7 +5628,7 @@ const loadModule_createRequire = (filename, distPath, rstestContext, assetFiles,
5600
5628
  const joinedPath = isRelativePath(id) ? external_pathe_["default"].join(currentDirectory, id) : id;
5601
5629
  const content = assetFiles[joinedPath];
5602
5630
  if (content) try {
5603
- return loadModule({
5631
+ return cacheableLoadModule({
5604
5632
  codeContent: content,
5605
5633
  testPath: joinedPath,
5606
5634
  distPath: joinedPath,
@@ -5618,6 +5646,39 @@ const loadModule_createRequire = (filename, distPath, rstestContext, assetFiles,
5618
5646
  require1.main = _require.main;
5619
5647
  return require1;
5620
5648
  };
5649
+ const defineRstestDynamicImport = ({ testPath, interopDefault, returnModule = false })=>async (specifier, importAttributes)=>{
5650
+ const resolvedPath = isAbsolute(specifier) ? pathToFileURL(specifier) : await import.meta.resolve(specifier, pathToFileURL(testPath));
5651
+ const modulePath = 'string' == typeof resolvedPath ? resolvedPath : resolvedPath.pathname;
5652
+ const importedModule = await import(modulePath, importAttributes);
5653
+ if (shouldInterop({
5654
+ interopDefault,
5655
+ modulePath,
5656
+ mod: importedModule
5657
+ })) {
5658
+ const { mod, defaultExport } = interopModule(importedModule);
5659
+ if (returnModule) return asModule(mod, defaultExport);
5660
+ return new Proxy(mod, {
5661
+ get (mod, prop) {
5662
+ if ('default' === prop) return defaultExport;
5663
+ return mod[prop] ?? defaultExport?.[prop];
5664
+ },
5665
+ has (mod, prop) {
5666
+ if ('default' === prop) return void 0 !== defaultExport;
5667
+ return prop in mod || defaultExport && prop in defaultExport;
5668
+ },
5669
+ getOwnPropertyDescriptor (mod, prop) {
5670
+ const descriptor = Reflect.getOwnPropertyDescriptor(mod, prop);
5671
+ if (descriptor) return descriptor;
5672
+ if ('default' === prop && void 0 !== defaultExport) return {
5673
+ value: defaultExport,
5674
+ enumerable: true,
5675
+ configurable: true
5676
+ };
5677
+ }
5678
+ });
5679
+ }
5680
+ return importedModule;
5681
+ };
5621
5682
  const loadModule = ({ codeContent, distPath, testPath, rstestContext, assetFiles, interopDefault })=>{
5622
5683
  const fileDir = external_pathe_["default"].dirname(testPath);
5623
5684
  const localModule = {
@@ -5633,6 +5694,10 @@ const loadModule = ({ codeContent, distPath, testPath, rstestContext, assetFiles
5633
5694
  module: localModule,
5634
5695
  exports: localModule.exports,
5635
5696
  require: loadModule_createRequire(testPath, distPath, rstestContext, assetFiles, interopDefault),
5697
+ __rstest_dynamic_import__: defineRstestDynamicImport({
5698
+ testPath,
5699
+ interopDefault
5700
+ }),
5636
5701
  __dirname: fileDir,
5637
5702
  __filename: testPath,
5638
5703
  ...rstestContext
@@ -5643,24 +5708,29 @@ const loadModule = ({ codeContent, distPath, testPath, rstestContext, assetFiles
5643
5708
  filename: distPath,
5644
5709
  lineOffset: 0,
5645
5710
  columnOffset: -codeDefinition.length,
5646
- importModuleDynamically: async (specifier, _referencer, importAttributes)=>{
5647
- const resolvedPath = isAbsolute(specifier) ? pathToFileURL(specifier) : await import.meta.resolve(specifier, pathToFileURL(testPath));
5648
- const modulePath = 'string' == typeof resolvedPath ? resolvedPath : resolvedPath.pathname;
5649
- const importedModule = await import(modulePath, importAttributes);
5650
- if (shouldInterop({
5711
+ importModuleDynamically: (specifier, _referencer, importAttributes)=>defineRstestDynamicImport({
5712
+ testPath,
5651
5713
  interopDefault,
5652
- modulePath,
5653
- mod: importedModule
5654
- })) {
5655
- const { mod, defaultExport } = interopModule(importedModule);
5656
- return asModule(mod, defaultExport);
5657
- }
5658
- return importedModule;
5659
- }
5714
+ returnModule: true
5715
+ })(specifier, importAttributes)
5660
5716
  });
5661
5717
  fn(...Object.values(context));
5662
5718
  return localModule.exports;
5663
5719
  };
5720
+ const moduleCache = new Map();
5721
+ const cacheableLoadModule = ({ codeContent, distPath, testPath, rstestContext, assetFiles, interopDefault })=>{
5722
+ if (moduleCache.has(testPath)) return moduleCache.get(testPath);
5723
+ const mod = loadModule({
5724
+ codeContent,
5725
+ distPath,
5726
+ testPath,
5727
+ rstestContext,
5728
+ assetFiles,
5729
+ interopDefault
5730
+ });
5731
+ moduleCache.set(testPath, mod);
5732
+ return mod;
5733
+ };
5664
5734
  const processSend = process.send.bind(process);
5665
5735
  const processOn = process.on.bind(process);
5666
5736
  const processOff = process.off.bind(process);
@@ -5777,7 +5847,7 @@ const preparePool = async ({ entryInfo: { distPath, testPath }, sourceMaps, upda
5777
5847
  const loadFiles = async ({ setupEntries, assetFiles, rstestContext, distPath, testPath, interopDefault })=>{
5778
5848
  for (const { distPath, testPath } of setupEntries){
5779
5849
  const setupCodeContent = assetFiles[distPath];
5780
- await loadModule({
5850
+ await cacheableLoadModule({
5781
5851
  codeContent: setupCodeContent,
5782
5852
  distPath,
5783
5853
  testPath,
@@ -5786,7 +5856,7 @@ const loadFiles = async ({ setupEntries, assetFiles, rstestContext, distPath, te
5786
5856
  interopDefault
5787
5857
  });
5788
5858
  }
5789
- await loadModule({
5859
+ await cacheableLoadModule({
5790
5860
  codeContent: assetFiles[distPath],
5791
5861
  distPath,
5792
5862
  testPath,
@@ -5824,7 +5894,11 @@ const runInPool = async (options)=>{
5824
5894
  } finally{
5825
5895
  await Promise.all(cleanups.map((fn)=>fn()));
5826
5896
  }
5897
+ const exit = process.exit;
5827
5898
  try {
5899
+ process.exit = (code = process.exitCode || 0)=>{
5900
+ throw new Error(`process.exit unexpectedly called with "${code}"`);
5901
+ };
5828
5902
  const { rstestContext, runner, rpc, api, cleanup, unhandledErrors, interopDefault } = await preparePool(options);
5829
5903
  cleanups.push(cleanup);
5830
5904
  await loadFiles({
@@ -5861,6 +5935,7 @@ const runInPool = async (options)=>{
5861
5935
  };
5862
5936
  } finally{
5863
5937
  await Promise.all(cleanups.map((fn)=>fn()));
5938
+ process.exit = exit;
5864
5939
  }
5865
5940
  };
5866
5941
  const worker = runInPool;
@@ -79,7 +79,7 @@ declare type NormalizedConfig = Required<Omit<RstestConfig, OptionalKeys | 'pool
79
79
  pool: RstestPoolOptions;
80
80
  };
81
81
 
82
- declare type OptionalKeys = 'setupFiles' | 'testNamePattern' | 'plugins' | 'source' | 'resolve' | 'output' | 'tools' | 'onConsoleLog';
82
+ declare type OptionalKeys = 'setupFiles' | 'testNamePattern' | 'plugins' | 'source' | 'resolve' | 'output' | 'performance' | 'tools' | 'dev' | 'onConsoleLog';
83
83
 
84
84
  export declare interface Reporter {
85
85
  /**
@@ -120,6 +120,14 @@ declare const reportersMap: {
120
120
 
121
121
  declare type ReporterWithOptions<Name extends BuiltInReporterNames = BuiltInReporterNames> = Name extends keyof BuiltinReporterOptions ? [Name, Partial<BuiltinReporterOptions[Name]>] : [Name, Record<string, unknown>];
122
122
 
123
+ declare type Ro<T> = T extends Array<infer V> ? V[] | Readonly<V[]> | RoArray<V> | Readonly<RoArray<V>> : T extends object ? T | Readonly<T> | RoObject<T> | Readonly<RoObject<T>> : T;
124
+
125
+ declare type RoArray<T> = Ro<T>[];
126
+
127
+ declare type RoObject<T> = {
128
+ [K in keyof T]: T[K] | Ro<T[K]>;
129
+ };
130
+
123
131
  export declare type RstestCommand = 'watch' | 'run' | 'list';
124
132
 
125
133
  export declare interface RstestConfig {
@@ -163,7 +171,7 @@ export declare interface RstestConfig {
163
171
  */
164
172
  retry?: number;
165
173
  /**
166
- * Allows the test suite to pass when no files are found.
174
+ * Pass when no tests are found.
167
175
  *
168
176
  * @default false
169
177
  */
@@ -263,7 +271,9 @@ export declare interface RstestConfig {
263
271
  onConsoleLog?: (content: string) => boolean | void;
264
272
  plugins?: RsbuildConfig['plugins'];
265
273
  source?: Pick<NonNullable<RsbuildConfig['source']>, 'define' | 'tsconfigPath' | 'decorators' | 'include' | 'exclude'>;
266
- output?: Pick<NonNullable<RsbuildConfig['output']>, 'cssModules'>;
274
+ performance?: Pick<NonNullable<RsbuildConfig['performance']>, 'bundleAnalyze'>;
275
+ dev?: Pick<NonNullable<RsbuildConfig['dev']>, 'writeToDisk'>;
276
+ output?: Pick<NonNullable<RsbuildConfig['output']>, 'cssModules' | 'externals' | 'cleanDistPath'>;
267
277
  resolve?: RsbuildConfig['resolve'];
268
278
  tools?: Pick<NonNullable<RsbuildConfig['tools']>, 'rspack' | 'swc' | 'bundlerChain'>;
269
279
  }
@@ -312,11 +322,11 @@ declare interface SourceMapV3 {
312
322
 
313
323
  declare type SourcesIndex = number;
314
324
 
315
- declare type TestFileInfo = {
325
+ export declare type TestFileInfo = {
316
326
  testPath: TestPath;
317
327
  };
318
328
 
319
- declare type TestFileResult = TestResult & {
329
+ export declare type TestFileResult = TestResult & {
320
330
  results: TestResult[];
321
331
  snapshotResult?: SnapshotResult;
322
332
  };
@@ -324,13 +334,14 @@ declare type TestFileResult = TestResult & {
324
334
  /** The test file original path */
325
335
  declare type TestPath = string;
326
336
 
327
- declare type TestResult = {
337
+ export declare type TestResult = {
328
338
  status: TestResultStatus;
329
339
  name: string;
330
340
  testPath: TestPath;
331
341
  parentNames?: string[];
332
342
  duration?: number;
333
343
  errors?: FormattedError[];
344
+ retryCount?: number;
334
345
  };
335
346
 
336
347
  declare type TestResultStatus = 'skip' | 'pass' | 'fail' | 'todo';
@@ -349,7 +360,7 @@ declare class TraceMap implements SourceMap {
349
360
  private _decodedMemo;
350
361
  private _bySources;
351
362
  private _bySourceMemos;
352
- constructor(map: SourceMapInput, mapUrl?: string | null);
363
+ constructor(map: Ro<SourceMapInput>, mapUrl?: string | null);
353
364
  }
354
365
 
355
366
  declare interface UserConsoleLog {
@@ -364,19 +364,19 @@ declare interface MockInstance<T extends FunctionLike = FunctionLike> {
364
364
  /**
365
365
  * Returns current mock implementation if there is one.
366
366
  */
367
- getMockImplementation(): T | undefined;
367
+ getMockImplementation(): NormalizedProcedure<T> | undefined;
368
368
  /**
369
369
  * Accepts a function that should be used as the implementation of the mock.
370
370
  */
371
- mockImplementation(fn: T): this;
371
+ mockImplementation(fn: NormalizedProcedure<T>): this;
372
372
  /**
373
373
  * Accepts a function that will be used as an implementation of the mock for one call to the mocked function.
374
374
  */
375
- mockImplementationOnce(fn: T): this;
375
+ mockImplementationOnce(fn: NormalizedProcedure<T>): this;
376
376
  /**
377
377
  * Accepts a function which should be temporarily used as the implementation of the mock while the callback is being executed.
378
378
  */
379
- withImplementation<T2>(fn: T, callback: () => T2): T2 extends Promise<unknown> ? Promise<void> : void;
379
+ withImplementation<T2>(fn: NormalizedProcedure<T>, callback: () => T2): T2 extends Promise<unknown> ? Promise<void> : void;
380
380
  /**
381
381
  * Return the `this` context from the method without invoking the actual implementation.
382
382
  */
@@ -437,16 +437,6 @@ declare interface MockSettledResultFulfilled<T> {
437
437
  value: T;
438
438
  }
439
439
 
440
- declare interface MockSettledResultFulfilled<T> {
441
- type: 'fulfilled';
442
- value: T;
443
- }
444
-
445
- declare interface MockSettledResultRejected {
446
- type: 'rejected';
447
- value: any;
448
- }
449
-
450
440
  declare interface MockSettledResultRejected {
451
441
  type: 'rejected';
452
442
  value: any;
@@ -460,7 +450,11 @@ declare type NormalizedConfig = Required<Omit<RstestConfig, OptionalKeys | 'pool
460
450
  pool: RstestPoolOptions;
461
451
  };
462
452
 
463
- declare type OptionalKeys = 'setupFiles' | 'testNamePattern' | 'plugins' | 'source' | 'resolve' | 'output' | 'tools' | 'onConsoleLog';
453
+ declare type NormalizedProcedure<T extends Procedure> = (...args: Parameters<T>) => ReturnType<T>;
454
+
455
+ declare type OptionalKeys = 'setupFiles' | 'testNamePattern' | 'plugins' | 'source' | 'resolve' | 'output' | 'performance' | 'tools' | 'dev' | 'onConsoleLog';
456
+
457
+ declare type Procedure = (...args: any[]) => any;
464
458
 
465
459
  declare type Promisify<O> = {
466
460
  [K in keyof O]: O[K] extends (...args: infer A) => infer R ? Promisify<O[K]> & ((...args: A) => Promise<R>) : O[K];
@@ -507,6 +501,14 @@ declare const reportersMap: {
507
501
 
508
502
  declare type ReporterWithOptions<Name extends BuiltInReporterNames = BuiltInReporterNames> = Name extends keyof BuiltinReporterOptions ? [Name, Partial<BuiltinReporterOptions[Name]>] : [Name, Record<string, unknown>];
509
503
 
504
+ declare type Ro<T> = T extends Array<infer V> ? V[] | Readonly<V[]> | RoArray<V> | Readonly<RoArray<V>> : T extends object ? T | Readonly<T> | RoObject<T> | Readonly<RoObject<T>> : T;
505
+
506
+ declare type RoArray<T> = Ro<T>[];
507
+
508
+ declare type RoObject<T> = {
509
+ [K in keyof T]: T[K] | Ro<T[K]>;
510
+ };
511
+
510
512
  export declare const rs: RstestUtilities;
511
513
 
512
514
  declare type Rstest = RunnerAPI & {
@@ -559,7 +561,7 @@ export declare interface RstestConfig {
559
561
  */
560
562
  retry?: number;
561
563
  /**
562
- * Allows the test suite to pass when no files are found.
564
+ * Pass when no tests are found.
563
565
  *
564
566
  * @default false
565
567
  */
@@ -659,7 +661,9 @@ export declare interface RstestConfig {
659
661
  onConsoleLog?: (content: string) => boolean | void;
660
662
  plugins?: RsbuildConfig['plugins'];
661
663
  source?: Pick<NonNullable<RsbuildConfig['source']>, 'define' | 'tsconfigPath' | 'decorators' | 'include' | 'exclude'>;
662
- output?: Pick<NonNullable<RsbuildConfig['output']>, 'cssModules'>;
664
+ performance?: Pick<NonNullable<RsbuildConfig['performance']>, 'bundleAnalyze'>;
665
+ dev?: Pick<NonNullable<RsbuildConfig['dev']>, 'writeToDisk'>;
666
+ output?: Pick<NonNullable<RsbuildConfig['output']>, 'cssModules' | 'externals' | 'cleanDistPath'>;
663
667
  resolve?: RsbuildConfig['resolve'];
664
668
  tools?: Pick<NonNullable<RsbuildConfig['tools']>, 'rspack' | 'swc' | 'bundlerChain'>;
665
669
  }
@@ -904,6 +908,7 @@ declare type TestResult = {
904
908
  parentNames?: string[];
905
909
  duration?: number;
906
910
  errors?: FormattedError[];
911
+ retryCount?: number;
907
912
  };
908
913
 
909
914
  declare type TestResultStatus = 'skip' | 'pass' | 'fail' | 'todo';
@@ -922,7 +927,7 @@ declare class TraceMap implements SourceMap {
922
927
  private _decodedMemo;
923
928
  private _bySources;
924
929
  private _bySourceMemos;
925
- constructor(map: SourceMapInput, mapUrl?: string | null);
930
+ constructor(map: Ro<SourceMapInput>, mapUrl?: string | null);
926
931
  }
927
932
 
928
933
  declare type Use<T> = (value: T) => Promise<void>;
@@ -211,7 +211,7 @@ declare type NormalizedFixture = {
211
211
 
212
212
  declare type NormalizedFixtures = Record<string, NormalizedFixture>;
213
213
 
214
- declare type OptionalKeys = 'setupFiles' | 'testNamePattern' | 'plugins' | 'source' | 'resolve' | 'output' | 'tools' | 'onConsoleLog';
214
+ declare type OptionalKeys = 'setupFiles' | 'testNamePattern' | 'plugins' | 'source' | 'resolve' | 'output' | 'performance' | 'tools' | 'dev' | 'onConsoleLog';
215
215
 
216
216
  declare type Promisify<O> = {
217
217
  [K in keyof O]: O[K] extends (...args: infer A) => infer R ? Promisify<O[K]> & ((...args: A) => Promise<R>) : O[K];
@@ -258,6 +258,14 @@ declare const reportersMap: {
258
258
 
259
259
  declare type ReporterWithOptions<Name extends BuiltInReporterNames = BuiltInReporterNames> = Name extends keyof BuiltinReporterOptions ? [Name, Partial<BuiltinReporterOptions[Name]>] : [Name, Record<string, unknown>];
260
260
 
261
+ declare type Ro<T> = T extends Array<infer V> ? V[] | Readonly<V[]> | RoArray<V> | Readonly<RoArray<V>> : T extends object ? T | Readonly<T> | RoObject<T> | Readonly<RoObject<T>> : T;
262
+
263
+ declare type RoArray<T> = Ro<T>[];
264
+
265
+ declare type RoObject<T> = {
266
+ [K in keyof T]: T[K] | Ro<T[K]>;
267
+ };
268
+
261
269
  declare type RstestCommand = 'watch' | 'run' | 'list';
262
270
 
263
271
  declare interface RstestConfig {
@@ -301,7 +309,7 @@ declare interface RstestConfig {
301
309
  */
302
310
  retry?: number;
303
311
  /**
304
- * Allows the test suite to pass when no files are found.
312
+ * Pass when no tests are found.
305
313
  *
306
314
  * @default false
307
315
  */
@@ -401,7 +409,9 @@ declare interface RstestConfig {
401
409
  onConsoleLog?: (content: string) => boolean | void;
402
410
  plugins?: RsbuildConfig['plugins'];
403
411
  source?: Pick<NonNullable<RsbuildConfig['source']>, 'define' | 'tsconfigPath' | 'decorators' | 'include' | 'exclude'>;
404
- output?: Pick<NonNullable<RsbuildConfig['output']>, 'cssModules'>;
412
+ performance?: Pick<NonNullable<RsbuildConfig['performance']>, 'bundleAnalyze'>;
413
+ dev?: Pick<NonNullable<RsbuildConfig['dev']>, 'writeToDisk'>;
414
+ output?: Pick<NonNullable<RsbuildConfig['output']>, 'cssModules' | 'externals' | 'cleanDistPath'>;
405
415
  resolve?: RsbuildConfig['resolve'];
406
416
  tools?: Pick<NonNullable<RsbuildConfig['tools']>, 'rspack' | 'swc' | 'bundlerChain'>;
407
417
  }
@@ -582,6 +592,7 @@ declare type TestResult = {
582
592
  parentNames?: string[];
583
593
  duration?: number;
584
594
  errors?: FormattedError[];
595
+ retryCount?: number;
585
596
  };
586
597
 
587
598
  declare type TestResultStatus = 'skip' | 'pass' | 'fail' | 'todo';
@@ -620,7 +631,7 @@ declare class TraceMap implements SourceMap {
620
631
  private _decodedMemo;
621
632
  private _bySources;
622
633
  private _bySourceMemos;
623
- constructor(map: SourceMapInput, mapUrl?: string | null);
634
+ constructor(map: Ro<SourceMapInput>, mapUrl?: string | null);
624
635
  }
625
636
 
626
637
  declare type Use<T> = (value: T) => Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rstest/core",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "description": "The Rsbuild-based test tool.",
5
5
  "bugs": {
6
6
  "url": "https://github.com/web-infra-dev/rstest/issues"
@@ -48,7 +48,7 @@
48
48
  "importMeta.d.ts"
49
49
  ],
50
50
  "dependencies": {
51
- "@rsbuild/core": "^1.4.0-beta.5",
51
+ "@rsbuild/core": "1.4.2",
52
52
  "@types/chai": "^5.2.2",
53
53
  "@vitest/expect": "^3.2.4",
54
54
  "@vitest/snapshot": "^3.2.4",
@@ -61,19 +61,19 @@
61
61
  "devDependencies": {
62
62
  "@sinonjs/fake-timers": "^14.0.0",
63
63
  "@babel/code-frame": "^7.27.1",
64
- "@jridgewell/trace-mapping": "0.3.25",
64
+ "@jridgewell/trace-mapping": "0.3.27",
65
65
  "@microsoft/api-extractor": "^7.52.8",
66
- "@rslib/core": "0.10.2",
66
+ "@rslib/core": "0.10.4",
67
67
  "@types/babel__code-frame": "^7.0.6",
68
68
  "@types/sinonjs__fake-timers": "^8.1.5",
69
69
  "@types/jsdom": "^21.1.7",
70
70
  "jsdom": "^26.1.0",
71
71
  "@types/source-map-support": "^0.5.10",
72
72
  "cac": "^6.7.14",
73
- "jest-diff": "^30.0.2",
73
+ "jest-diff": "^30.0.3",
74
74
  "license-webpack-plugin": "^4.0.2",
75
75
  "picocolors": "^1.1.1",
76
- "rslog": "^1.2.7",
76
+ "rslog": "^1.2.8",
77
77
  "source-map-support": "^0.5.21",
78
78
  "stacktrace-parser": "0.1.11",
79
79
  "tinyglobby": "^0.2.14",
@@ -98,6 +98,7 @@
98
98
  },
99
99
  "scripts": {
100
100
  "build": "rslib build",
101
+ "typecheck": "tsc --noEmit",
101
102
  "dev": "rslib build --watch",
102
103
  "test": "npx rstest run --globals"
103
104
  }