@rstest/core 0.0.4 → 0.0.5

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/dist/285.js CHANGED
@@ -55,7 +55,7 @@ export const __webpack_modules__ = {
55
55
  const hasError = list.some((file)=>file.errors?.length);
56
56
  if (hasError) {
57
57
  const { printError } = await Promise.all([
58
- __webpack_require__.e("502"),
58
+ __webpack_require__.e("723"),
59
59
  __webpack_require__.e("355")
60
60
  ]).then(__webpack_require__.bind(__webpack_require__, "./src/utils/error.ts"));
61
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("502"),
326
+ __webpack_require__.e("723"),
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);
@@ -452,7 +452,7 @@ export const __webpack_modules__ = {
452
452
  });
453
453
  return {
454
454
  command,
455
- version: "0.0.4",
455
+ version: "0.0.5",
456
456
  rootPath,
457
457
  reporters,
458
458
  snapshotManager,
@@ -467,14 +467,14 @@ export const __webpack_modules__ = {
467
467
  }, config);
468
468
  const runTests = async ()=>{
469
469
  const { runTests } = await Promise.all([
470
- __webpack_require__.e("992"),
470
+ __webpack_require__.e("612"),
471
471
  __webpack_require__.e("629")
472
472
  ]).then(__webpack_require__.bind(__webpack_require__, "./src/core/runTests.ts"));
473
473
  await runTests(context, fileFilters);
474
474
  };
475
475
  const listTests = async (options)=>{
476
476
  const { listTests } = await Promise.all([
477
- __webpack_require__.e("992"),
477
+ __webpack_require__.e("612"),
478
478
  __webpack_require__.e("285")
479
479
  ]).then(__webpack_require__.bind(__webpack_require__, "./src/core/listTests.ts"));
480
480
  await listTests(context, fileFilters, options);
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.27/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.29/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,5 +1,5 @@
1
1
  export const __webpack_ids__ = [
2
- "992"
2
+ "612"
3
3
  ];
4
4
  export const __webpack_modules__ = {
5
5
  "./src/core/rsbuild.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
@@ -11,6 +11,38 @@ export const __webpack_modules__ = {
11
11
  var core_ = __webpack_require__("@rsbuild/core");
12
12
  var external_pathe_ = __webpack_require__("pathe");
13
13
  var utils = __webpack_require__("./src/utils/index.ts");
14
+ var external_node_path_ = __webpack_require__("node:path");
15
+ var external_node_url_ = __webpack_require__("node:url");
16
+ const PLUGIN_CSS_FILTER = 'rstest:css-filter';
17
+ const css_filter_dirname = external_node_path_["default"].dirname((0, external_node_url_.fileURLToPath)(import.meta.url));
18
+ const pluginCSSFilter = ()=>({
19
+ name: PLUGIN_CSS_FILTER,
20
+ setup (api) {
21
+ api.modifyBundlerChain({
22
+ order: 'post',
23
+ handler: async (chain, { target, CHAIN_ID, environment })=>{
24
+ const emitCss = environment.config.output.emitCss ?? 'web' === target;
25
+ if (!emitCss) {
26
+ const ruleIds = [
27
+ CHAIN_ID.RULE.CSS,
28
+ CHAIN_ID.RULE.SASS,
29
+ CHAIN_ID.RULE.LESS,
30
+ CHAIN_ID.RULE.STYLUS
31
+ ];
32
+ for (const ruleId of ruleIds){
33
+ if (!chain.module.rules.has(ruleId)) continue;
34
+ const rule = chain.module.rule(ruleId);
35
+ if (!rule.uses.has(CHAIN_ID.USE.CSS)) continue;
36
+ const cssLoaderOptions = rule.use(CHAIN_ID.USE.CSS).get('options');
37
+ if (cssLoaderOptions.modules && ('object' != typeof cssLoaderOptions.modules || false !== cssLoaderOptions.modules.auto)) rule.use('rstest-css-pre-filter').loader(external_node_path_["default"].join(css_filter_dirname, 'cssFilterLoader.mjs')).options({
38
+ modules: cssLoaderOptions.modules
39
+ }).after(ruleId);
40
+ }
41
+ }
42
+ }
43
+ });
44
+ }
45
+ });
14
46
  class TestFileWatchPlugin {
15
47
  contextToWatch = null;
16
48
  constructor(contextToWatch){
@@ -47,8 +79,8 @@ export const __webpack_modules__ = {
47
79
  config.watchOptions.ignored = '**/**';
48
80
  const sourceEntries = await globTestSourceEntries();
49
81
  config.entry = {
50
- ...sourceEntries,
51
- ...setupFiles
82
+ ...setupFiles,
83
+ ...sourceEntries
52
84
  };
53
85
  }
54
86
  });
@@ -73,12 +105,155 @@ export const __webpack_modules__ = {
73
105
  });
74
106
  }
75
107
  };
108
+ class MockRuntimeRspackPlugin {
109
+ apply(compiler) {
110
+ const { RuntimeModule } = compiler.webpack;
111
+ class RetestImportRuntimeModule extends RuntimeModule {
112
+ constructor(){
113
+ super('rstest runtime');
114
+ }
115
+ generate() {
116
+ return `
117
+ if (typeof __webpack_require__ === 'undefined') {
118
+ return;
119
+ }
120
+
121
+ const originalRequire = __webpack_require__;
122
+ __webpack_require__ = function(...args) {
123
+ try {
124
+ return originalRequire(...args);
125
+ } catch (e) {
126
+ const errMsg = e.message ?? e.toString();
127
+ if (errMsg.includes('__webpack_modules__[moduleId] is not a function')) {
128
+ throw new Error(\`Cannot find module '\${args[0]}'\`)
129
+ }
130
+ throw e;
131
+ }
132
+ };
133
+
134
+ Object.keys(originalRequire).forEach(key => {
135
+ __webpack_require__[key] = originalRequire[key];
136
+ });
137
+
138
+ __webpack_require__.rstest_original_modules = {};
139
+
140
+ // TODO: Remove "reset_modules" in next Rspack version.
141
+ __webpack_require__.rstest_reset_modules = __webpack_require__.reset_modules = () => {
142
+ const mockedIds = Object.keys(__webpack_require__.rstest_original_modules)
143
+ Object.keys(__webpack_module_cache__).forEach(id => {
144
+ // Do not reset mocks registry.
145
+ if (!mockedIds.includes(id)) {
146
+ delete __webpack_module_cache__[id];
147
+ }
148
+ });
149
+ }
150
+
151
+ // TODO: Remove "unmock" in next Rspack version.
152
+ __webpack_require__.rstest_unmock = __webpack_require__.unmock = (id) => {
153
+ delete __webpack_module_cache__[id]
154
+ }
155
+
156
+ // TODO: Remove "require_actual" and "import_actual" in next Rspack version.
157
+ __webpack_require__.rstest_require_actual = __webpack_require__.rstest_import_actual = __webpack_require__.require_actual = __webpack_require__.import_actual = (id) => {
158
+ const originalModule = __webpack_require__.rstest_original_modules[id];
159
+ // Use fallback module if the module is not mocked.
160
+ const fallbackMod = __webpack_require__(id);
161
+ return originalModule ? originalModule : fallbackMod;
162
+ }
163
+
164
+ // TODO: Remove "set_mock" in next Rspack version.
165
+ __webpack_require__.rstest_set_mock = __webpack_require__.set_mock = (id, modFactory) => {
166
+ let requiredModule = undefined
167
+ try {
168
+ requiredModule = __webpack_require__(id);
169
+ } catch {
170
+ // TODO: non-resolved module
171
+ } finally {
172
+ __webpack_require__.rstest_original_modules[id] = requiredModule;
173
+ }
174
+ if (typeof modFactory === 'string' || typeof modFactory === 'number') {
175
+ __webpack_module_cache__[id] = { exports: __webpack_require__(modFactory) };
176
+ } else if (typeof modFactory === 'function') {
177
+ let exports = modFactory();
178
+ __webpack_require__.r(exports);
179
+ __webpack_module_cache__[id] = { exports, id, loaded: true };
180
+ }
181
+ };
182
+ `;
183
+ }
184
+ }
185
+ compiler.hooks.thisCompilation.tap('CustomPlugin', (compilation)=>{
186
+ compilation.hooks.additionalTreeRuntimeRequirements.tap('CustomPlugin', (chunk)=>{
187
+ compilation.addRuntimeModule(chunk, new RetestImportRuntimeModule());
188
+ });
189
+ });
190
+ }
191
+ }
192
+ const pluginMockRuntime = {
193
+ name: 'rstest:mock-runtime',
194
+ setup: (api)=>{
195
+ api.modifyRspackConfig(async (config)=>{
196
+ config.plugins.push(new MockRuntimeRspackPlugin());
197
+ });
198
+ }
199
+ };
200
+ class RstestCacheControlPlugin {
201
+ apply(compiler) {
202
+ const { RuntimeModule } = compiler.webpack;
203
+ class RetestCacheControlModule extends RuntimeModule {
204
+ constructor(){
205
+ super('rstest_cache_control');
206
+ }
207
+ generate() {
208
+ return `
209
+ global.setupIds = [];
210
+
211
+ function __rstest_clean_core_cache__() {
212
+ if (typeof __webpack_require__ === 'undefined') {
213
+ return;
214
+ }
215
+ delete __webpack_module_cache__['@rstest/core'];
216
+
217
+ global.setupIds.forEach((id) => {
218
+ delete __webpack_module_cache__[id];
219
+ });
220
+ }
221
+
222
+ global.__rstest_clean_core_cache__ = __rstest_clean_core_cache__;
223
+ `;
224
+ }
225
+ }
226
+ compiler.hooks.thisCompilation.tap('CustomPlugin', (compilation)=>{
227
+ compilation.hooks.additionalTreeRuntimeRequirements.tap('CustomPlugin', (chunk)=>{
228
+ compilation.addRuntimeModule(chunk, new RetestCacheControlModule());
229
+ });
230
+ });
231
+ }
232
+ }
233
+ const pluginCacheControl = (setupFiles)=>({
234
+ name: 'rstest:cache-control',
235
+ setup: (api)=>{
236
+ api.transform({
237
+ test: setupFiles
238
+ }, ({ code })=>({
239
+ code: `
240
+ ${code}
241
+ if (global.setupIds && __webpack_module__.id) {
242
+ global.setupIds.push(__webpack_module__.id);
243
+ }
244
+ `
245
+ }));
246
+ api.modifyRspackConfig(async (config)=>{
247
+ config.plugins.push(new RstestCacheControlPlugin());
248
+ });
249
+ }
250
+ });
76
251
  const isMultiCompiler = (compiler)=>'compilers' in compiler && Array.isArray(compiler.compilers);
77
252
  const autoExternalNodeModules = ({ context, request, dependencyType, getResolve }, callback)=>{
78
253
  if (!request) return callback();
79
254
  if (request.startsWith('@swc/helpers/')) return callback();
80
255
  const doExternal = (externalPath = request)=>{
81
- callback(void 0, externalPath, 'commonjs' === dependencyType ? 'commonjs' : 'module-import');
256
+ callback(void 0, externalPath, 'commonjs' === dependencyType ? 'commonjs' : 'import');
82
257
  };
83
258
  const resolver = getResolve?.();
84
259
  if (!resolver) return callback();
@@ -98,7 +273,7 @@ export const __webpack_modules__ = {
98
273
  else callback();
99
274
  };
100
275
  const prepareRsbuild = async (context, globTestSourceEntries, setupFiles)=>{
101
- const { command, normalizedConfig: { name, plugins, resolve, source, output, tools, testEnvironment, performance, dev = {} } } = context;
276
+ const { command, normalizedConfig: { isolate, name, plugins, resolve, source, output, tools, testEnvironment, performance, dev = {} } } = context;
102
277
  const debugMode = (0, utils.L1)();
103
278
  core_.logger.level = debugMode ? 'verbose' : 'error';
104
279
  const writeToDisk = dev.writeToDisk || debugMode;
@@ -143,9 +318,9 @@ export const __webpack_modules__ = {
143
318
  config.output.devtoolModuleFilenameTemplate = '[absolute-resource-path]';
144
319
  config.plugins.push(new core_.rspack.experiments.RstestPlugin({
145
320
  injectModulePathName: true,
146
- hoistMockModule: true,
147
321
  importMetaPathName: true,
148
- manualMockRoot: context.rootPath
322
+ hoistMockModule: true,
323
+ manualMockRoot: external_pathe_["default"].resolve(context.rootPath, '__mocks__')
149
324
  }));
150
325
  config.externals = (0, utils.XQ)(config.externals) || [];
151
326
  config.externals.unshift({
@@ -162,12 +337,12 @@ export const __webpack_modules__ = {
162
337
  requireAsExpression: false,
163
338
  ...config.module.parser.javascript || {}
164
339
  };
165
- if ('node' === testEnvironment && ((0, utils.mP)()[0] || 0) < 20) {
166
- config.resolve ??= {};
167
- config.resolve.mainFields = config.resolve.mainFields?.filter((filed)=>'module' !== filed) || [
168
- 'main'
169
- ];
170
- }
340
+ config.resolve ??= {};
341
+ config.resolve.extensions ??= [];
342
+ config.resolve.extensions.push('.cjs');
343
+ if ('node' === testEnvironment && (0, utils.mP)().major < 20) config.resolve.mainFields = config.resolve.mainFields?.filter((filed)=>'module' !== filed) || [
344
+ 'main'
345
+ ];
171
346
  config.optimization = {
172
347
  moduleIds: 'named',
173
348
  chunkIds: 'named',
@@ -180,6 +355,8 @@ export const __webpack_modules__ = {
180
355
  },
181
356
  plugins: [
182
357
  pluginIgnoreResolveError,
358
+ pluginMockRuntime,
359
+ pluginCSSFilter(),
183
360
  pluginEntryWatch({
184
361
  globTestSourceEntries,
185
362
  setupFiles,
@@ -190,6 +367,9 @@ export const __webpack_modules__ = {
190
367
  }
191
368
  }
192
369
  });
370
+ if (!isolate) rsbuildInstance.addPlugins([
371
+ pluginCacheControl(Object.values(setupFiles))
372
+ ]);
193
373
  return rsbuildInstance;
194
374
  };
195
375
  const createRsbuildServer = async ({ name, globTestSourceEntries, setupFiles, rsbuildInstance, normalizedConfig })=>{
@@ -405,8 +585,9 @@ export const __webpack_modules__ = {
405
585
  ...execArgv,
406
586
  '--experimental-vm-modules',
407
587
  '--experimental-import-meta-resolve',
408
- '--no-warnings'
409
- ],
588
+ '--no-warnings',
589
+ (0, utils.PA)() ? '--experimental-detect-module' : void 0
590
+ ].filter(Boolean),
410
591
  env: {
411
592
  NODE_ENV: 'test',
412
593
  FORCE_COLOR: '1',
@@ -429,7 +610,8 @@ export const __webpack_modules__ = {
429
610
  maxConcurrency,
430
611
  printConsoleTrace,
431
612
  disableConsoleIntercept,
432
- testEnvironment
613
+ testEnvironment,
614
+ isolate
433
615
  };
434
616
  const rpcMethods = {
435
617
  onTestCaseResult: async (result)=>{
@@ -1,8 +1,8 @@
1
1
  export const __webpack_ids__ = [
2
- "502"
2
+ "723"
3
3
  ];
4
4
  export const __webpack_modules__ = {
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__) {
5
+ "../../node_modules/.pnpm/@jridgewell+trace-mapping@0.3.29/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
package/dist/867.js CHANGED
@@ -1594,10 +1594,13 @@ export const __webpack_modules__ = {
1594
1594
  return rstest;
1595
1595
  },
1596
1596
  mock: ()=>{},
1597
+ mockRequire: ()=>{},
1597
1598
  doMock: ()=>{},
1598
- unMock: ()=>{},
1599
- doUnMock: ()=>{},
1599
+ doMockRequire: ()=>{},
1600
+ unmock: ()=>{},
1601
+ doUnmock: ()=>{},
1600
1602
  importMock: async ()=>({}),
1603
+ requireMock: ()=>({}),
1601
1604
  importActual: async ()=>({}),
1602
1605
  requireActual: ()=>({}),
1603
1606
  resetModules: ()=>rstest,
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
+ PA: ()=>needFlagExperimentalDetectModule,
2295
2296
  Tn: ()=>NODE_BUILTINS,
2296
2297
  XQ: ()=>castArray,
2297
2298
  Yz: ()=>getTaskNameWithPrefix,
@@ -2355,11 +2356,27 @@ var __webpack_modules__ = {
2355
2356
  testNamePattern: testNamePattern && 'string' != typeof testNamePattern ? wrapRegex(testNamePattern) : testNamePattern
2356
2357
  };
2357
2358
  };
2358
- const getNodeVersion = ()=>'string' == typeof process.versions?.node ? process.versions.node.split('.').map(Number) : [
2359
- 0,
2360
- 0,
2361
- 0
2362
- ];
2359
+ const getNodeVersion = ()=>{
2360
+ if ('string' == typeof process.versions?.node) {
2361
+ const [major = 0, minor = 0, patch = 0] = process.versions.node.split('.').map(Number);
2362
+ return {
2363
+ major,
2364
+ minor,
2365
+ patch
2366
+ };
2367
+ }
2368
+ return {
2369
+ major: 0,
2370
+ minor: 0,
2371
+ patch: 0
2372
+ };
2373
+ };
2374
+ const needFlagExperimentalDetectModule = ()=>{
2375
+ const { major, minor } = getNodeVersion();
2376
+ if (20 === major && minor >= 10) return true;
2377
+ if (22 === major && minor < 7) return true;
2378
+ return false;
2379
+ };
2363
2380
  const NODE_BUILTINS = [
2364
2381
  'assert',
2365
2382
  'assert/strict',
@@ -2434,6 +2451,7 @@ var __webpack_modules__ = {
2434
2451
  Tn: ()=>helper.Tn,
2435
2452
  $_: ()=>helper.$_,
2436
2453
  Yz: ()=>helper.Yz,
2454
+ PA: ()=>helper.PA,
2437
2455
  L1: ()=>logger.L,
2438
2456
  v8: ()=>helper.v8,
2439
2457
  Qd: ()=>constants.Qd,
@@ -3647,7 +3665,7 @@ function prepareCli() {
3647
3665
  if (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) console.log();
3648
3666
  }
3649
3667
  function showRstest() {
3650
- logger.k.greet(" Rstest v0.0.4");
3668
+ logger.k.greet(" Rstest v0.0.5");
3651
3669
  logger.k.log('');
3652
3670
  }
3653
3671
  const applyCommonOptions = (cli)=>{
@@ -3691,7 +3709,7 @@ async function initCli(options) {
3691
3709
  function setupCommands() {
3692
3710
  const cli = dist('rstest');
3693
3711
  cli.help();
3694
- cli.version("0.0.4");
3712
+ cli.version("0.0.5");
3695
3713
  applyCommonOptions(cli);
3696
3714
  cli.command('[...filters]', 'run tests').action(async (filters, options)=>{
3697
3715
  showRstest();
@@ -0,0 +1,22 @@
1
+ const CSS_MODULES_REGEX = /\.module\.\w+$/i;
2
+ const isCSSModules = ({ resourcePath, resourceQuery, resourceFragment, modules })=>{
3
+ if ('boolean' == typeof modules) return modules;
4
+ if ('string' == typeof modules) return 'global' !== modules;
5
+ const { auto } = modules;
6
+ if ('boolean' == typeof auto) return auto && CSS_MODULES_REGEX.test(resourcePath);
7
+ if (auto instanceof RegExp) return auto.test(resourcePath);
8
+ if ('function' == typeof auto) return auto(resourcePath, resourceQuery, resourceFragment);
9
+ return true;
10
+ };
11
+ function loader(content) {
12
+ const { resourcePath, resourceQuery, resourceFragment } = this;
13
+ const { modules = true } = this.getOptions() || {};
14
+ if (isCSSModules({
15
+ resourcePath,
16
+ resourceQuery,
17
+ resourceFragment,
18
+ modules
19
+ })) return content;
20
+ return '';
21
+ }
22
+ export { loader as default };
package/dist/worker.js CHANGED
@@ -5649,6 +5649,7 @@ const loadModule_createRequire = (filename, distPath, rstestContext, assetFiles,
5649
5649
  const defineRstestDynamicImport = ({ testPath, interopDefault, returnModule = false })=>async (specifier, importAttributes)=>{
5650
5650
  const resolvedPath = isAbsolute(specifier) ? pathToFileURL(specifier) : await import.meta.resolve(specifier, pathToFileURL(testPath));
5651
5651
  const modulePath = 'string' == typeof resolvedPath ? resolvedPath : resolvedPath.pathname;
5652
+ if (importAttributes?.with?.rstest) delete importAttributes.with.rstest;
5652
5653
  const importedModule = await import(modulePath, importAttributes);
5653
5654
  if (shouldInterop({
5654
5655
  interopDefault,
@@ -5844,10 +5845,20 @@ const preparePool = async ({ entryInfo: { distPath, testPath }, sourceMaps, upda
5844
5845
  }
5845
5846
  };
5846
5847
  };
5847
- const loadFiles = async ({ setupEntries, assetFiles, rstestContext, distPath, testPath, interopDefault })=>{
5848
+ const loadFiles = async ({ setupEntries, assetFiles, rstestContext, distPath, testPath, interopDefault, isolate })=>{
5849
+ if (!isolate) await loadModule({
5850
+ codeContent: `if (global && typeof global.__rstest_clean_core_cache__ === 'function') {
5851
+ global.__rstest_clean_core_cache__();
5852
+ }`,
5853
+ distPath,
5854
+ testPath,
5855
+ rstestContext,
5856
+ assetFiles,
5857
+ interopDefault
5858
+ });
5848
5859
  for (const { distPath, testPath } of setupEntries){
5849
5860
  const setupCodeContent = assetFiles[distPath];
5850
- await cacheableLoadModule({
5861
+ await loadModule({
5851
5862
  codeContent: setupCodeContent,
5852
5863
  distPath,
5853
5864
  testPath,
@@ -5856,7 +5867,7 @@ const loadFiles = async ({ setupEntries, assetFiles, rstestContext, distPath, te
5856
5867
  interopDefault
5857
5868
  });
5858
5869
  }
5859
- await cacheableLoadModule({
5870
+ await loadModule({
5860
5871
  codeContent: assetFiles[distPath],
5861
5872
  distPath,
5862
5873
  testPath,
@@ -5866,7 +5877,7 @@ const loadFiles = async ({ setupEntries, assetFiles, rstestContext, distPath, te
5866
5877
  });
5867
5878
  };
5868
5879
  const runInPool = async (options)=>{
5869
- const { entryInfo: { distPath, testPath }, setupEntries, assetFiles, type } = options;
5880
+ const { entryInfo: { distPath, testPath }, setupEntries, assetFiles, type, context: { runtimeConfig: { isolate } } } = options;
5870
5881
  const cleanups = [];
5871
5882
  if ('collect' === type) try {
5872
5883
  const { rstestContext, runner, cleanup, unhandledErrors, interopDefault } = await preparePool(options);
@@ -5877,7 +5888,8 @@ const runInPool = async (options)=>{
5877
5888
  testPath,
5878
5889
  assetFiles,
5879
5890
  setupEntries,
5880
- interopDefault
5891
+ interopDefault,
5892
+ isolate
5881
5893
  });
5882
5894
  const tests = await runner.collectTests();
5883
5895
  return {
@@ -5907,7 +5919,8 @@ const runInPool = async (options)=>{
5907
5919
  testPath,
5908
5920
  assetFiles,
5909
5921
  setupEntries,
5910
- interopDefault
5922
+ interopDefault,
5923
+ isolate
5911
5924
  });
5912
5925
  const results = await runner.runTests(testPath, {
5913
5926
  onTestFileStart: async (test)=>{
@@ -715,42 +715,46 @@ declare type RstestUtilities = {
715
715
  */
716
716
  restoreAllMocks: () => RstestUtilities;
717
717
  /**
718
- * @todo
719
718
  * Mock a module
720
719
  */
721
720
  mock: <T = unknown>(moduleName: string, moduleFactory?: () => T) => void;
722
721
  /**
723
- * @todo
722
+ * Mock a module
723
+ */
724
+ mockRequire: <T = unknown>(moduleName: string, moduleFactory?: () => T) => void;
725
+ /**
724
726
  * Mock a module, not hoisted.
725
727
  */
726
728
  doMock: <T = unknown>(moduleName: string, moduleFactory?: () => T) => void;
727
729
  /**
728
- * @todo
730
+ * Mock a module, not hoisted.
731
+ */
732
+ doMockRequire: <T = unknown>(moduleName: string, moduleFactory?: () => T) => void;
733
+ /**
729
734
  * Removes module from the mocked registry.
730
735
  */
731
- unMock: (path: string) => void;
736
+ unmock: (path: string) => void;
732
737
  /**
733
- * @todo
734
738
  * Removes module from the mocked registry, not hoisted.
735
739
  */
736
- doUnMock: (path: string) => void;
740
+ doUnmock: (path: string) => void;
737
741
  /**
738
- * @todo
739
742
  * Imports a module with all of its properties (including nested properties) mocked.
740
743
  */
741
744
  importMock: <T = Record<string, unknown>>(path: string) => Promise<T>;
742
745
  /**
743
- * @todo
746
+ * Imports a module with all of its properties (including nested properties) mocked.
747
+ */
748
+ requireMock: <T = Record<string, unknown>>(path: string) => T;
749
+ /**
744
750
  * Import and return the actual module instead of a mock, bypassing all checks on whether the module should receive a mock implementation or not.
745
751
  */
746
752
  importActual: <T = Record<string, unknown>>(path: string) => Promise<T>;
747
753
  /**
748
- * @todo
749
754
  * Require and return the actual module instead of a mock, bypassing all checks on whether the module should receive a mock implementation or not.
750
755
  */
751
756
  requireActual: <T = Record<string, unknown>>(path: string) => T;
752
757
  /**
753
- * @todo
754
758
  * Resets modules registry by clearing the cache of all modules.
755
759
  */
756
760
  resetModules: () => RstestUtilities;
@@ -457,7 +457,7 @@ declare const runInPool: (options: RunWorkerOptions["options"]) => Promise<{
457
457
  } | TestFileResult>;
458
458
  export default runInPool;
459
459
 
460
- declare type RuntimeConfig = Pick<RstestContext['normalizedConfig'], 'testTimeout' | 'testNamePattern' | 'globals' | 'passWithNoTests' | 'retry' | 'clearMocks' | 'resetMocks' | 'restoreMocks' | 'unstubEnvs' | 'unstubGlobals' | 'maxConcurrency' | 'printConsoleTrace' | 'disableConsoleIntercept' | 'testEnvironment'>;
460
+ declare type RuntimeConfig = Pick<RstestContext['normalizedConfig'], 'testTimeout' | 'testNamePattern' | 'globals' | 'passWithNoTests' | 'retry' | 'clearMocks' | 'resetMocks' | 'restoreMocks' | 'unstubEnvs' | 'unstubGlobals' | 'maxConcurrency' | 'printConsoleTrace' | 'disableConsoleIntercept' | 'testEnvironment' | 'isolate'>;
461
461
 
462
462
  /** Runtime to Server */
463
463
  declare type RuntimeRPC = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rstest/core",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
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.2",
51
+ "@rsbuild/core": "1.4.3",
52
52
  "@types/chai": "^5.2.2",
53
53
  "@vitest/expect": "^3.2.4",
54
54
  "@vitest/snapshot": "^3.2.4",
@@ -61,7 +61,7 @@
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.27",
64
+ "@jridgewell/trace-mapping": "0.3.29",
65
65
  "@microsoft/api-extractor": "^7.52.8",
66
66
  "@rslib/core": "0.10.4",
67
67
  "@types/babel__code-frame": "^7.0.6",
@@ -73,7 +73,7 @@
73
73
  "jest-diff": "^30.0.3",
74
74
  "license-webpack-plugin": "^4.0.2",
75
75
  "picocolors": "^1.1.1",
76
- "rslog": "^1.2.8",
76
+ "rslog": "^1.2.9",
77
77
  "source-map-support": "^0.5.21",
78
78
  "stacktrace-parser": "0.1.11",
79
79
  "tinyglobby": "^0.2.14",