@rstest/core 0.0.7 → 0.0.9

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
@@ -6,7 +6,7 @@ export const __webpack_modules__ = {
6
6
  __webpack_require__.d(__webpack_exports__, {
7
7
  listTests: ()=>listTests
8
8
  });
9
- var node_fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("node:fs");
9
+ var node_fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("fs");
10
10
  var node_path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("node:path");
11
11
  var _pool__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("./src/pool/index.ts");
12
12
  var _utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./src/utils/index.ts");
package/dist/353.js CHANGED
@@ -454,7 +454,7 @@ export const __webpack_modules__ = {
454
454
  });
455
455
  return {
456
456
  command,
457
- version: "0.0.7",
457
+ version: "0.0.9",
458
458
  rootPath,
459
459
  reporters,
460
460
  snapshotManager,
package/dist/355.js CHANGED
@@ -6,7 +6,7 @@ export const __webpack_modules__ = {
6
6
  __webpack_require__.d(__webpack_exports__, {
7
7
  printError: ()=>printError
8
8
  });
9
- var node_fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("node:fs");
9
+ var node_fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("fs");
10
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");
@@ -30,6 +30,7 @@ export const __webpack_modules__ = {
30
30
  if (error.stack) {
31
31
  const stackFrames = await parseErrorStacktrace({
32
32
  stack: error.stack,
33
+ fullStack: error.fullStack,
33
34
  getSourcemap
34
35
  });
35
36
  if (stackFrames[0]) await printCodeFrame(stackFrames[0]);
@@ -71,8 +72,8 @@ export const __webpack_modules__ = {
71
72
  /node:\w+/,
72
73
  '<anonymous>'
73
74
  ];
74
- async function parseErrorStacktrace({ stack, getSourcemap }) {
75
- return Promise.all((0, stacktrace_parser__WEBPACK_IMPORTED_MODULE_2__.Q)(stack).filter((frame)=>frame.file && !stackIgnores.some((entry)=>frame.file?.match(entry))).map(async (frame)=>{
75
+ async function parseErrorStacktrace({ stack, getSourcemap, fullStack }) {
76
+ return Promise.all((0, stacktrace_parser__WEBPACK_IMPORTED_MODULE_2__.Q)(stack).filter((frame)=>fullStack ? true : frame.file && !stackIgnores.some((entry)=>frame.file?.match(entry))).map(async (frame)=>{
76
77
  const sourcemap = getSourcemap(frame.file);
77
78
  if (sourcemap) {
78
79
  const traceMap = new _jridgewell_trace_mapping__WEBPACK_IMPORTED_MODULE_1__.s7(sourcemap);
package/dist/612.js CHANGED
@@ -7,7 +7,7 @@ export const __webpack_modules__ = {
7
7
  r: ()=>createRsbuildServer,
8
8
  z: ()=>prepareRsbuild
9
9
  });
10
- var external_node_fs_ = __webpack_require__("node:fs");
10
+ var external_node_fs_ = __webpack_require__("fs");
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");
@@ -263,15 +263,15 @@ global.__rstest_clean_core_cache__ = __rstest_clean_core_cache__;
263
263
  return callback();
264
264
  });
265
265
  };
266
- const autoExternalNodeBuiltin = ({ request, dependencyType }, callback)=>{
267
- if (!request) return callback();
266
+ function autoExternalNodeBuiltin({ request, dependencyType }, callback) {
267
+ if (!request) return void callback();
268
268
  const isNodeBuiltin = utils.Tn.some((builtin)=>{
269
269
  if ('string' == typeof builtin) return builtin === request;
270
270
  return builtin.test(request);
271
271
  });
272
272
  if (isNodeBuiltin) callback(void 0, request, 'commonjs' === dependencyType ? 'commonjs' : 'module-import');
273
273
  else callback();
274
- };
274
+ }
275
275
  const prepareRsbuild = async (context, globTestSourceEntries, setupFiles)=>{
276
276
  const { command, normalizedConfig: { isolate, name, plugins, resolve, source, output, tools, testEnvironment, performance, dev = {} } } = context;
277
277
  const debugMode = (0, utils.L1)();
@@ -311,6 +311,9 @@ global.__rstest_clean_core_cache__ = __rstest_clean_core_cache__;
311
311
  sourceMap: {
312
312
  js: 'source-map'
313
313
  },
314
+ externals: 'node' === testEnvironment ? [
315
+ autoExternalNodeModules
316
+ ] : void 0,
314
317
  distPath: {
315
318
  root: utils.Nk
316
319
  },
@@ -333,7 +336,6 @@ global.__rstest_clean_core_cache__ = __rstest_clean_core_cache__;
333
336
  config.externals.unshift({
334
337
  '@rstest/core': 'global @rstest/core'
335
338
  });
336
- if ('node' === testEnvironment) config.externals.push(autoExternalNodeModules);
337
339
  config.externalsPresets ??= {};
338
340
  config.externalsPresets.node = false;
339
341
  config.externals.push(autoExternalNodeBuiltin);
@@ -342,14 +344,21 @@ global.__rstest_clean_core_cache__ = __rstest_clean_core_cache__;
342
344
  importDynamic: false,
343
345
  requireDynamic: false,
344
346
  requireAsExpression: false,
347
+ requireResolve: false,
345
348
  ...config.module.parser.javascript || {}
346
349
  };
347
350
  config.resolve ??= {};
348
351
  config.resolve.extensions ??= [];
349
352
  config.resolve.extensions.push('.cjs');
350
- if ('node' === testEnvironment && (0, utils.mP)().major < 20) config.resolve.mainFields = config.resolve.mainFields?.filter((filed)=>'module' !== filed) || [
353
+ if ('node' === testEnvironment) config.resolve.mainFields = config.resolve.mainFields?.filter((filed)=>'module' !== filed) || [
351
354
  'main'
352
355
  ];
356
+ config.resolve.byDependency ??= {};
357
+ config.resolve.byDependency.commonjs ??= {};
358
+ config.resolve.byDependency.commonjs.mainFields = [
359
+ 'main',
360
+ '...'
361
+ ];
353
362
  config.optimization = {
354
363
  moduleIds: 'named',
355
364
  chunkIds: 'named',
@@ -399,7 +408,7 @@ global.__rstest_clean_core_cache__ = __rstest_clean_core_cache__;
399
408
  if ((0, utils.L1)()) await rsbuildInstance.inspectConfig({
400
409
  writeToDisk: true,
401
410
  extraConfigs: {
402
- retest: normalizedConfig
411
+ rstest: normalizedConfig
403
412
  }
404
413
  });
405
414
  const outputFileSystem = (isMultiCompiler(rspackCompiler) ? rspackCompiler.compilers[0].outputFileSystem : rspackCompiler.outputFileSystem) || external_node_fs_["default"];
@@ -664,6 +673,17 @@ global.__rstest_clean_core_cache__ = __rstest_clean_core_cache__;
664
673
  updateSnapshot
665
674
  },
666
675
  rpcMethods
676
+ }).catch((err)=>{
677
+ err.fullStack = true;
678
+ return {
679
+ testPath: entryInfo.testPath,
680
+ status: 'fail',
681
+ name: '',
682
+ results: [],
683
+ errors: [
684
+ err
685
+ ]
686
+ };
667
687
  });
668
688
  }));
669
689
  for (const result of results)if (result.snapshotResult) context.snapshotManager.add(result.snapshotResult);
@@ -689,6 +709,15 @@ global.__rstest_clean_core_cache__ = __rstest_clean_core_cache__;
689
709
  updateSnapshot
690
710
  },
691
711
  rpcMethods
712
+ }).catch((err)=>{
713
+ err.fullStack = true;
714
+ return {
715
+ testPath: entryInfo.testPath,
716
+ tests: [],
717
+ errors: [
718
+ err
719
+ ]
720
+ };
692
721
  });
693
722
  })),
694
723
  close: ()=>pool.close()
package/dist/64.js CHANGED
@@ -35,7 +35,7 @@ export const __webpack_modules__ = {
35
35
  "../../node_modules/.pnpm/source-map-support@0.5.21/node_modules/source-map-support/source-map-support.js": function(module, exports, __webpack_require__) {
36
36
  module = __webpack_require__.nmd(module);
37
37
  var SourceMapConsumer = __webpack_require__("../../node_modules/.pnpm/source-map@0.6.1/node_modules/source-map/source-map.js").SourceMapConsumer;
38
- var path = __webpack_require__("path");
38
+ var path = __webpack_require__("node:path");
39
39
  var fs;
40
40
  try {
41
41
  fs = __webpack_require__("fs");
package/dist/81.js CHANGED
@@ -212,7 +212,7 @@ export const __webpack_modules__ = {
212
212
  isPresent.hrtime = _global.process && "function" == typeof _global.process.hrtime;
213
213
  isPresent.hrtimeBigint = isPresent.hrtime && "function" == typeof _global.process.hrtime.bigint;
214
214
  isPresent.nextTick = _global.process && "function" == typeof _global.process.nextTick;
215
- const utilPromisify = _global.process && __webpack_require__("util").promisify;
215
+ const utilPromisify = _global.process && __webpack_require__("node:util").promisify;
216
216
  isPresent.performance = _global.performance && "function" == typeof _global.performance.now;
217
217
  const hasPerformancePrototype = _global.Performance && (typeof _global.Performance).match(/^(function|object)$/);
218
218
  const hasPerformanceConstructorPrototype = _global.performance && _global.performance.constructor && _global.performance.constructor.prototype;
package/dist/813.js CHANGED
@@ -132,7 +132,7 @@ export const __webpack_modules__ = {
132
132
  var constants = __webpack_require__("./src/utils/constants.ts");
133
133
  var helper = __webpack_require__("./src/utils/helper.ts");
134
134
  __webpack_require__("./src/utils/logger.ts");
135
- __webpack_require__("node:fs");
135
+ __webpack_require__("fs");
136
136
  __webpack_require__("node:fs/promises");
137
137
  __webpack_require__("node:module");
138
138
  __webpack_require__("pathe");
package/dist/867.js CHANGED
@@ -927,14 +927,12 @@ export const __webpack_modules__ = {
927
927
  testPath;
928
928
  collectStatus = 'lazy';
929
929
  currentCollectList = [];
930
- defaultHookTimeout;
931
- defaultTestTimeout;
932
- constructor({ testPath, testTimeout, hookTimeout }){
930
+ runtimeConfig;
931
+ constructor({ testPath, runtimeConfig }){
933
932
  this.testPath = testPath;
934
- this.defaultTestTimeout = testTimeout;
935
- this.defaultHookTimeout = hookTimeout;
933
+ this.runtimeConfig = runtimeConfig;
936
934
  }
937
- afterAll(fn, timeout = this.defaultHookTimeout) {
935
+ afterAll(fn, timeout = this.runtimeConfig.hookTimeout) {
938
936
  const currentSuite = this.getCurrentSuite();
939
937
  registerTestSuiteListener(currentSuite, 'afterAll', wrapTimeout({
940
938
  name: 'afterAll hook',
@@ -943,7 +941,7 @@ export const __webpack_modules__ = {
943
941
  stackTraceError: new Error('STACK_TRACE_ERROR')
944
942
  }));
945
943
  }
946
- beforeAll(fn, timeout = this.defaultHookTimeout) {
944
+ beforeAll(fn, timeout = this.runtimeConfig.hookTimeout) {
947
945
  const currentSuite = this.getCurrentSuite();
948
946
  registerTestSuiteListener(currentSuite, 'beforeAll', wrapTimeout({
949
947
  name: 'beforeAll hook',
@@ -952,7 +950,7 @@ export const __webpack_modules__ = {
952
950
  stackTraceError: new Error('STACK_TRACE_ERROR')
953
951
  }));
954
952
  }
955
- afterEach(fn, timeout = this.defaultHookTimeout) {
953
+ afterEach(fn, timeout = this.runtimeConfig.hookTimeout) {
956
954
  const currentSuite = this.getCurrentSuite();
957
955
  registerTestSuiteListener(currentSuite, 'afterEach', wrapTimeout({
958
956
  name: 'afterEach hook',
@@ -961,7 +959,7 @@ export const __webpack_modules__ = {
961
959
  stackTraceError: new Error('STACK_TRACE_ERROR')
962
960
  }));
963
961
  }
964
- beforeEach(fn, timeout = this.defaultHookTimeout) {
962
+ beforeEach(fn, timeout = this.runtimeConfig.hookTimeout) {
965
963
  const currentSuite = this.getCurrentSuite();
966
964
  registerTestSuiteListener(currentSuite, 'beforeEach', wrapTimeout({
967
965
  name: 'beforeEach hook',
@@ -1053,7 +1051,7 @@ export const __webpack_modules__ = {
1053
1051
  ensureRootSuite() {
1054
1052
  if (0 === this._currentTest.length) this.addTest(this.getDefaultRootSuite());
1055
1053
  }
1056
- it({ name, fn, originalFn = fn, fixtures, timeout = this.defaultTestTimeout, runMode = 'run', fails = false, each = false, concurrent, sequential }) {
1054
+ it({ name, fn, originalFn = fn, fixtures, timeout = this.runtimeConfig.testTimeout, runMode = 'run', fails = false, each = false, concurrent, sequential }) {
1057
1055
  this.addTestCase({
1058
1056
  name,
1059
1057
  originalFn,
@@ -1101,7 +1099,7 @@ export const __webpack_modules__ = {
1101
1099
  };
1102
1100
  }
1103
1101
  each({ cases, ...options }) {
1104
- return (name, fn, timeout = this.defaultTestTimeout)=>{
1102
+ return (name, fn, timeout = this.runtimeConfig.testTimeout)=>{
1105
1103
  for(let i = 0; i < cases.length; i++){
1106
1104
  const param = cases[i];
1107
1105
  const params = (0, src_utils.XQ)(param);
@@ -1117,7 +1115,7 @@ export const __webpack_modules__ = {
1117
1115
  };
1118
1116
  }
1119
1117
  for({ cases, ...options }) {
1120
- return (name, fn, timeout = this.defaultTestTimeout)=>{
1118
+ return (name, fn, timeout = this.runtimeConfig.testTimeout)=>{
1121
1119
  for(let i = 0; i < cases.length; i++){
1122
1120
  const param = cases[i];
1123
1121
  this.it({
@@ -1140,11 +1138,10 @@ export const __webpack_modules__ = {
1140
1138
  throw new Error('Expect to find a suite, but got undefined');
1141
1139
  }
1142
1140
  }
1143
- const createRuntimeAPI = ({ testPath, testTimeout, hookTimeout })=>{
1141
+ const createRuntimeAPI = ({ testPath, runtimeConfig })=>{
1144
1142
  const runtimeInstance = new RunnerRuntime({
1145
1143
  testPath,
1146
- testTimeout,
1147
- hookTimeout
1144
+ runtimeConfig
1148
1145
  });
1149
1146
  const createTestAPI = (options = {})=>{
1150
1147
  const testFn = (name, fn, timeout)=>runtimeInstance.it({
@@ -1292,11 +1289,10 @@ export const __webpack_modules__ = {
1292
1289
  };
1293
1290
  };
1294
1291
  function createRunner({ workerState }) {
1295
- const { testPath, runtimeConfig: { testTimeout, testNamePattern, hookTimeout } } = workerState;
1292
+ const { testPath, runtimeConfig: { testNamePattern } } = workerState;
1296
1293
  const runtime = createRuntimeAPI({
1297
1294
  testPath,
1298
- testTimeout,
1299
- hookTimeout
1295
+ runtimeConfig: workerState.runtimeConfig
1300
1296
  });
1301
1297
  const testRunner = new TestRunner();
1302
1298
  return {
@@ -1570,10 +1566,11 @@ export const __webpack_modules__ = {
1570
1566
  return wrapSpy(obj, method);
1571
1567
  };
1572
1568
  const isMockFunction = (fn)=>'function' == typeof fn && '_isMockFunction' in fn && fn._isMockFunction;
1573
- const createRstestUtilities = ()=>{
1569
+ const createRstestUtilities = (workerState)=>{
1574
1570
  const originalEnvValues = new Map();
1575
1571
  const originalGlobalValues = new Map();
1576
1572
  let _timers;
1573
+ let originalConfig;
1577
1574
  const timers = ()=>{
1578
1575
  if (!_timers) _timers = new FakeTimers({
1579
1576
  global: globalThis
@@ -1607,6 +1604,15 @@ export const __webpack_modules__ = {
1607
1604
  importActual: async ()=>({}),
1608
1605
  requireActual: ()=>({}),
1609
1606
  resetModules: ()=>rstest,
1607
+ setConfig: (config)=>{
1608
+ if (!originalConfig) originalConfig = {
1609
+ ...workerState.runtimeConfig
1610
+ };
1611
+ Object.assign(workerState.runtimeConfig, config);
1612
+ },
1613
+ resetConfig: ()=>{
1614
+ if (originalConfig) Object.assign(workerState.runtimeConfig, originalConfig);
1615
+ },
1610
1616
  stubEnv: (name, value)=>{
1611
1617
  if (!originalEnvValues.has(name)) originalEnvValues.set(name, process.env[name]);
1612
1618
  if (void 0 === value) delete process.env[name];
@@ -1712,7 +1718,7 @@ export const __webpack_modules__ = {
1712
1718
  writable: true,
1713
1719
  configurable: true
1714
1720
  });
1715
- const rstest = createRstestUtilities();
1721
+ const rstest = createRstestUtilities(workerState);
1716
1722
  return {
1717
1723
  runner,
1718
1724
  api: {
@@ -1737,7 +1743,7 @@ export const __webpack_modules__ = {
1737
1743
  var constants = __webpack_require__("./src/utils/constants.ts");
1738
1744
  var helper = __webpack_require__("./src/utils/helper.ts");
1739
1745
  __webpack_require__("./src/utils/logger.ts");
1740
- __webpack_require__("node:fs");
1746
+ __webpack_require__("fs");
1741
1747
  __webpack_require__("node:fs/promises");
1742
1748
  __webpack_require__("node:module");
1743
1749
  __webpack_require__("pathe");
package/dist/cli.js CHANGED
@@ -1,19 +1,17 @@
1
1
  import node_process from "node:process";
2
- import node_tty from "node:tty";
3
2
  import * as __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__ from "@rsbuild/core";
4
3
  import * as __WEBPACK_EXTERNAL_MODULE__vitest_snapshot_manager_ed2bcef6__ from "@vitest/snapshot/manager";
5
4
  import * as __WEBPACK_EXTERNAL_MODULE_birpc__ from "birpc";
6
- import * as __WEBPACK_EXTERNAL_MODULE_fs__ from "fs";
7
5
  import * as __WEBPACK_EXTERNAL_MODULE_node_events_0a6aefe7__ from "node:events";
8
6
  import * as __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__ from "node:fs";
9
7
  import * as __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__ from "node:fs/promises";
10
8
  import * as __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__ from "node:module";
11
9
  import * as __WEBPACK_EXTERNAL_MODULE_node_os_74b4b876__ from "node:os";
12
10
  import * as __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__ from "node:path";
11
+ import * as __WEBPACK_EXTERNAL_MODULE_node_tty_c64aab7e__ from "node:tty";
13
12
  import * as __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__ from "node:url";
14
13
  import * as __WEBPACK_EXTERNAL_MODULE_node_util_1b29d436__ from "node:util";
15
14
  import * as __WEBPACK_EXTERNAL_MODULE_node_v8_d0df5498__ from "node:v8";
16
- import * as __WEBPACK_EXTERNAL_MODULE_path__ from "path";
17
15
  import * as __WEBPACK_EXTERNAL_MODULE_pathe__ from "pathe";
18
16
  import * as __WEBPACK_EXTERNAL_MODULE_std_env_1c7b8267__ from "std-env";
19
17
  import * as __WEBPACK_EXTERNAL_MODULE_tinypool__ from "tinypool";
@@ -140,7 +138,7 @@ var __webpack_modules__ = {
140
138
  value: true
141
139
  });
142
140
  exports.build = exports.joinDirectoryPath = exports.joinPathWithBasePath = void 0;
143
- const path_1 = __webpack_require__("path");
141
+ const path_1 = __webpack_require__("node:path");
144
142
  const utils_1 = __webpack_require__("../../node_modules/.pnpm/fdir@6.4.4_picomatch@4.0.2/node_modules/fdir/dist/utils.js");
145
143
  function joinPathWithBasePath(filename, directoryPath) {
146
144
  return directoryPath + filename;
@@ -236,7 +234,7 @@ var __webpack_modules__ = {
236
234
  });
237
235
  exports.build = void 0;
238
236
  const fs_1 = __importDefault(__webpack_require__("fs"));
239
- const path_1 = __webpack_require__("path");
237
+ const path_1 = __webpack_require__("node:path");
240
238
  const resolveSymlinksAsync = function(path, state, callback) {
241
239
  const { queue, options: { suppressErrors } } = state;
242
240
  queue.enqueue();
@@ -393,7 +391,7 @@ var __webpack_modules__ = {
393
391
  value: true
394
392
  });
395
393
  exports.Walker = void 0;
396
- const path_1 = __webpack_require__("path");
394
+ const path_1 = __webpack_require__("node:path");
397
395
  const utils_1 = __webpack_require__("../../node_modules/.pnpm/fdir@6.4.4_picomatch@4.0.2/node_modules/fdir/dist/utils.js");
398
396
  const joinPath = __importStar(__webpack_require__("../../node_modules/.pnpm/fdir@6.4.4_picomatch@4.0.2/node_modules/fdir/dist/api/functions/join-path.js"));
399
397
  const pushDirectory = __importStar(__webpack_require__("../../node_modules/.pnpm/fdir@6.4.4_picomatch@4.0.2/node_modules/fdir/dist/api/functions/push-directory.js"));
@@ -514,7 +512,7 @@ var __webpack_modules__ = {
514
512
  value: true
515
513
  });
516
514
  exports.Builder = void 0;
517
- const path_1 = __webpack_require__("path");
515
+ const path_1 = __webpack_require__("node:path");
518
516
  const api_builder_1 = __webpack_require__("../../node_modules/.pnpm/fdir@6.4.4_picomatch@4.0.2/node_modules/fdir/dist/builder/api-builder.js");
519
517
  var pm = null;
520
518
  try {
@@ -679,7 +677,7 @@ var __webpack_modules__ = {
679
677
  value: true
680
678
  });
681
679
  exports.normalizePath = exports.isRootDirectory = exports.convertSlashes = exports.cleanPath = void 0;
682
- const path_1 = __webpack_require__("path");
680
+ const path_1 = __webpack_require__("node:path");
683
681
  function cleanPath(path) {
684
682
  let normalized = (0, path_1.normalize)(path);
685
683
  if (normalized.length > 1 && normalized[normalized.length - 1] === path_1.sep) normalized = normalized.substring(0, normalized.length - 1);
@@ -2182,7 +2180,7 @@ var __webpack_modules__ = {
2182
2180
  ME: ()=>loadConfig,
2183
2181
  hY: ()=>withDefaultConfig
2184
2182
  });
2185
- var node_fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("node:fs");
2183
+ var node_fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("fs");
2186
2184
  var _rsbuild_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("@rsbuild/core");
2187
2185
  var pathe__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("pathe");
2188
2186
  var _utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./src/utils/index.ts");
@@ -2300,7 +2298,6 @@ var __webpack_modules__ = {
2300
2298
  Yz: ()=>getTaskNameWithPrefix,
2301
2299
  Z: ()=>formatError,
2302
2300
  ZY: ()=>getAbsolutePath,
2303
- mP: ()=>getNodeVersion,
2304
2301
  v8: ()=>serializableConfig
2305
2302
  });
2306
2303
  var pathe__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("pathe");
@@ -2451,7 +2448,6 @@ var __webpack_modules__ = {
2451
2448
  aA: ()=>getSetupFiles,
2452
2449
  kg: ()=>logger.k,
2453
2450
  Io: ()=>constants.Io,
2454
- mP: ()=>helper.mP,
2455
2451
  Ps: ()=>formatTestPath,
2456
2452
  XQ: ()=>helper.XQ,
2457
2453
  Nk: ()=>constants.Nk,
@@ -2468,7 +2464,7 @@ var __webpack_modules__ = {
2468
2464
  var constants = __webpack_require__("./src/utils/constants.ts");
2469
2465
  var helper = __webpack_require__("./src/utils/helper.ts");
2470
2466
  var logger = __webpack_require__("./src/utils/logger.ts");
2471
- var external_node_fs_ = __webpack_require__("node:fs");
2467
+ var external_node_fs_ = __webpack_require__("fs");
2472
2468
  var promises_ = __webpack_require__("node:fs/promises");
2473
2469
  var external_node_module_ = __webpack_require__("node:module");
2474
2470
  var external_pathe_ = __webpack_require__("pathe");
@@ -2569,6 +2565,7 @@ var __webpack_modules__ = {
2569
2565
  k: ()=>src_logger
2570
2566
  });
2571
2567
  var external_node_os_ = __webpack_require__("node:os");
2568
+ var external_node_tty_ = __webpack_require__("node:tty");
2572
2569
  function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : node_process.argv) {
2573
2570
  const prefix = flag.startsWith('-') ? '' : 1 === flag.length ? '-' : '--';
2574
2571
  const position = argv.indexOf(prefix + flag);
@@ -2661,10 +2658,10 @@ var __webpack_modules__ = {
2661
2658
  }
2662
2659
  const supportsColor = {
2663
2660
  stdout: createSupportsColor({
2664
- isTTY: node_tty.isatty(1)
2661
+ isTTY: external_node_tty_["default"].isatty(1)
2665
2662
  }),
2666
2663
  stderr: createSupportsColor({
2667
- isTTY: node_tty.isatty(2)
2664
+ isTTY: external_node_tty_["default"].isatty(2)
2668
2665
  })
2669
2666
  };
2670
2667
  const supports_color = supportsColor;
@@ -2849,13 +2846,10 @@ var __webpack_modules__ = {
2849
2846
  birpc: function(module) {
2850
2847
  module.exports = __WEBPACK_EXTERNAL_MODULE_birpc__;
2851
2848
  },
2852
- fs: function(module) {
2853
- module.exports = __WEBPACK_EXTERNAL_MODULE_fs__;
2854
- },
2855
2849
  "node:events": function(module) {
2856
2850
  module.exports = __WEBPACK_EXTERNAL_MODULE_node_events_0a6aefe7__;
2857
2851
  },
2858
- "node:fs": function(module) {
2852
+ fs: function(module) {
2859
2853
  module.exports = __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__;
2860
2854
  },
2861
2855
  "node:fs/promises": function(module) {
@@ -2870,6 +2864,9 @@ var __webpack_modules__ = {
2870
2864
  "node:path": function(module) {
2871
2865
  module.exports = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__;
2872
2866
  },
2867
+ "node:tty": function(module) {
2868
+ module.exports = __WEBPACK_EXTERNAL_MODULE_node_tty_c64aab7e__;
2869
+ },
2873
2870
  "node:url": function(module) {
2874
2871
  module.exports = __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__;
2875
2872
  },
@@ -2879,9 +2876,6 @@ var __webpack_modules__ = {
2879
2876
  "node:v8": function(module) {
2880
2877
  module.exports = __WEBPACK_EXTERNAL_MODULE_node_v8_d0df5498__;
2881
2878
  },
2882
- path: function(module) {
2883
- module.exports = __WEBPACK_EXTERNAL_MODULE_path__;
2884
- },
2885
2879
  pathe: function(module) {
2886
2880
  module.exports = __WEBPACK_EXTERNAL_MODULE_pathe__;
2887
2881
  },
@@ -2895,7 +2889,7 @@ var __webpack_modules__ = {
2895
2889
  __webpack_require__.d(__webpack_exports__, {
2896
2890
  zA: ()=>glob
2897
2891
  });
2898
- var path__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("path");
2892
+ var path__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("node:path");
2899
2893
  var fdir__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("../../node_modules/.pnpm/fdir@6.4.4_picomatch@4.0.2/node_modules/fdir/dist/index.js");
2900
2894
  var picomatch__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.2/node_modules/picomatch/index.js");
2901
2895
  const ONLY_PARENT_DIRECTORIES = /^(\/?\.\.)+$/;
@@ -3696,13 +3690,13 @@ function prepareCli() {
3696
3690
  if (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) console.log();
3697
3691
  }
3698
3692
  function showRstest() {
3699
- logger.k.greet(" Rstest v0.0.7");
3693
+ logger.k.greet(" Rstest v0.0.9");
3700
3694
  logger.k.log('');
3701
3695
  }
3702
3696
  const applyCommonOptions = (cli)=>{
3703
3697
  cli.option('-c, --config <config>', 'Specify the configuration file, can be a relative or absolute path').option('--config-loader <loader>', 'Specify the loader to load the config file, can be `jiti` or `native`', {
3704
3698
  default: 'jiti'
3705
- }).option('-r, --root <root>', 'Specify the project root directory, can be an absolute path or a path relative to cwd').option('--globals', 'Provide global APIs').option('--isolate', 'Run tests in an isolated environment').option('--exclude <exclude>', 'Exclude files from test').option('-u, --update', 'Update snapshot files').option('--passWithNoTests', 'Allows the test suite to pass when no files are found').option('--printConsoleTrace', 'Print console traces when calling any console method').option('--disableConsoleIntercept', 'Disable console intercept').option('--slowTestThreshold <value>', 'The number of milliseconds after which a test or suite is considered slow').option('-t, --testNamePattern <value>', 'Run only tests with a name that matches the regex').option('--testEnvironment <name>', 'The environment that will be used for testing').option('--testTimeout <value>', 'Timeout of a test in milliseconds').option('--hookTimeout <value>', 'Timeout of hook in milliseconds').option('--retry <retry>', 'Number of times to retry a test if it fails').option('--maxConcurrency <value>', 'Maximum number of concurrent tests').option('--clearMocks', 'Automatically clear mock calls, instances, contexts and results before every test').option('--resetMocks', 'Automatically reset mock state before every test').option('--restoreMocks', 'Automatically restore mock state and implementation before every test').option('--unstubGlobals', 'Restores all global variables that were changed with `rstest.stubGlobal` before every test').option('--unstubEnvs', 'Restores all `process.env` values that were changed with `rstest.stubEnv` before every test');
3699
+ }).option('-r, --root <root>', 'Specify the project root directory, can be an absolute path or a path relative to cwd').option('--globals', 'Provide global APIs').option('--isolate', 'Run tests in an isolated environment').option('--include <include>', 'Match test files').option('--exclude <exclude>', 'Exclude files from test').option('-u, --update', 'Update snapshot files').option('--passWithNoTests', 'Allows the test suite to pass when no files are found').option('--printConsoleTrace', 'Print console traces when calling any console method').option('--disableConsoleIntercept', 'Disable console intercept').option('--slowTestThreshold <value>', 'The number of milliseconds after which a test or suite is considered slow').option('-t, --testNamePattern <value>', 'Run only tests with a name that matches the regex').option('--testEnvironment <name>', 'The environment that will be used for testing').option('--testTimeout <value>', 'Timeout of a test in milliseconds').option('--hookTimeout <value>', 'Timeout of hook in milliseconds').option('--retry <retry>', 'Number of times to retry a test if it fails').option('--maxConcurrency <value>', 'Maximum number of concurrent tests').option('--clearMocks', 'Automatically clear mock calls, instances, contexts and results before every test').option('--resetMocks', 'Automatically reset mock state before every test').option('--restoreMocks', 'Automatically restore mock state and implementation before every test').option('--unstubGlobals', 'Restores all global variables that were changed with `rstest.stubGlobal` before every test').option('--unstubEnvs', 'Restores all `process.env` values that were changed with `rstest.stubEnv` before every test');
3706
3700
  };
3707
3701
  async function initCli(options) {
3708
3702
  const cwd = process.cwd();
@@ -3735,6 +3729,7 @@ async function initCli(options) {
3735
3729
  ];
3736
3730
  for (const key of keys)if (void 0 !== options[key]) config[key] = options[key];
3737
3731
  if (options.exclude) config.exclude = (0, helper.XQ)(options.exclude);
3732
+ if (options.include) config.include = (0, helper.XQ)(options.include);
3738
3733
  return {
3739
3734
  config,
3740
3735
  configFilePath
@@ -3743,7 +3738,7 @@ async function initCli(options) {
3743
3738
  function setupCommands() {
3744
3739
  const cli = dist('rstest');
3745
3740
  cli.help();
3746
- cli.version("0.0.7");
3741
+ cli.version("0.0.9");
3747
3742
  applyCommonOptions(cli);
3748
3743
  cli.command('[...filters]', 'run tests').action(async (filters, options)=>{
3749
3744
  showRstest();
package/dist/worker.js CHANGED
@@ -1,24 +1,19 @@
1
1
  /*! For license information please see worker.js.LICENSE.txt */
2
2
  import node_process from "node:process";
3
- import node_tty from "node:tty";
4
3
  import * as __WEBPACK_EXTERNAL_MODULE__vitest_expect_97b57ccd__ from "@vitest/expect";
5
4
  import * as __WEBPACK_EXTERNAL_MODULE__vitest_snapshot_692a7094__ from "@vitest/snapshot";
6
5
  import * as __WEBPACK_EXTERNAL_MODULE_chai__ from "chai";
7
- import * as __WEBPACK_EXTERNAL_MODULE_fs__ from "fs";
8
6
  import * as __WEBPACK_EXTERNAL_MODULE_node_assert_3e74d44e__ from "node:assert";
9
7
  import * as __WEBPACK_EXTERNAL_MODULE_node_console_8631dfae__ from "node:console";
10
8
  import * as __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__ from "node:fs";
11
9
  import * as __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__ from "node:fs/promises";
12
10
  import * as __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__ from "node:module";
13
11
  import * as __WEBPACK_EXTERNAL_MODULE_node_os_74b4b876__ from "node:os";
12
+ import * as __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__ from "node:path";
14
13
  import * as __WEBPACK_EXTERNAL_MODULE_node_timers_7045d530__ from "node:timers";
14
+ import * as __WEBPACK_EXTERNAL_MODULE_node_tty_c64aab7e__ from "node:tty";
15
15
  import * as __WEBPACK_EXTERNAL_MODULE_node_util_1b29d436__ from "node:util";
16
- import * as __WEBPACK_EXTERNAL_MODULE_os__ from "os";
17
- import * as __WEBPACK_EXTERNAL_MODULE_path__ from "path";
18
16
  import * as __WEBPACK_EXTERNAL_MODULE_pathe__ from "pathe";
19
- import * as __WEBPACK_EXTERNAL_MODULE_tty__ from "tty";
20
- import * as __WEBPACK_EXTERNAL_MODULE_util__ from "util";
21
- import { isAbsolute } from "node:path";
22
17
  import { pathToFileURL } from "node:url";
23
18
  import node_vm from "node:vm";
24
19
  import node_v8 from "node:v8";
@@ -4906,8 +4901,8 @@ var __webpack_modules__ = {
4906
4901
  else module.exports = __webpack_require__("../../node_modules/.pnpm/react-is@18.3.1/node_modules/react-is/cjs/react-is.development.js");
4907
4902
  },
4908
4903
  "../../node_modules/.pnpm/supports-color@7.2.0/node_modules/supports-color/index.js": function(module, __unused_webpack_exports, __webpack_require__) {
4909
- const os = __webpack_require__("os");
4910
- const tty = __webpack_require__("tty");
4904
+ const os = __webpack_require__("node:os");
4905
+ const tty = __webpack_require__("node:tty");
4911
4906
  const hasFlag = __webpack_require__("../../node_modules/.pnpm/has-flag@4.0.0/node_modules/has-flag/index.js");
4912
4907
  const { env } = process;
4913
4908
  let forceColor;
@@ -5126,6 +5121,7 @@ var __webpack_modules__ = {
5126
5121
  k: ()=>src_logger
5127
5122
  });
5128
5123
  var external_node_os_ = __webpack_require__("node:os");
5124
+ var external_node_tty_ = __webpack_require__("node:tty");
5129
5125
  function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : node_process.argv) {
5130
5126
  const prefix = flag.startsWith('-') ? '' : 1 === flag.length ? '-' : '--';
5131
5127
  const position = argv.indexOf(prefix + flag);
@@ -5218,10 +5214,10 @@ var __webpack_modules__ = {
5218
5214
  }
5219
5215
  const supportsColor = {
5220
5216
  stdout: createSupportsColor({
5221
- isTTY: node_tty.isatty(1)
5217
+ isTTY: external_node_tty_["default"].isatty(1)
5222
5218
  }),
5223
5219
  stderr: createSupportsColor({
5224
- isTTY: node_tty.isatty(2)
5220
+ isTTY: external_node_tty_["default"].isatty(2)
5225
5221
  })
5226
5222
  };
5227
5223
  const supports_color = supportsColor;
@@ -5412,16 +5408,13 @@ var __webpack_modules__ = {
5412
5408
  chai: function(module) {
5413
5409
  module.exports = __WEBPACK_EXTERNAL_MODULE_chai__;
5414
5410
  },
5415
- fs: function(module) {
5416
- module.exports = __WEBPACK_EXTERNAL_MODULE_fs__;
5417
- },
5418
5411
  "node:assert": function(module) {
5419
5412
  module.exports = __WEBPACK_EXTERNAL_MODULE_node_assert_3e74d44e__;
5420
5413
  },
5421
5414
  "node:console": function(module) {
5422
5415
  module.exports = __WEBPACK_EXTERNAL_MODULE_node_console_8631dfae__;
5423
5416
  },
5424
- "node:fs": function(module) {
5417
+ fs: function(module) {
5425
5418
  module.exports = __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__;
5426
5419
  },
5427
5420
  "node:fs/promises": function(module) {
@@ -5433,26 +5426,20 @@ var __webpack_modules__ = {
5433
5426
  "node:os": function(module) {
5434
5427
  module.exports = __WEBPACK_EXTERNAL_MODULE_node_os_74b4b876__;
5435
5428
  },
5429
+ "node:path": function(module) {
5430
+ module.exports = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__;
5431
+ },
5436
5432
  "node:timers": function(module) {
5437
5433
  module.exports = __WEBPACK_EXTERNAL_MODULE_node_timers_7045d530__;
5438
5434
  },
5435
+ "node:tty": function(module) {
5436
+ module.exports = __WEBPACK_EXTERNAL_MODULE_node_tty_c64aab7e__;
5437
+ },
5439
5438
  "node:util": function(module) {
5440
5439
  module.exports = __WEBPACK_EXTERNAL_MODULE_node_util_1b29d436__;
5441
5440
  },
5442
- os: function(module) {
5443
- module.exports = __WEBPACK_EXTERNAL_MODULE_os__;
5444
- },
5445
- path: function(module) {
5446
- module.exports = __WEBPACK_EXTERNAL_MODULE_path__;
5447
- },
5448
5441
  pathe: function(module) {
5449
5442
  module.exports = __WEBPACK_EXTERNAL_MODULE_pathe__;
5450
- },
5451
- tty: function(module) {
5452
- module.exports = __WEBPACK_EXTERNAL_MODULE_tty__;
5453
- },
5454
- util: function(module) {
5455
- module.exports = __WEBPACK_EXTERNAL_MODULE_util__;
5456
5443
  }
5457
5444
  };
5458
5445
  var __webpack_module_cache__ = {};
@@ -5585,6 +5572,7 @@ var constants = __webpack_require__("./src/utils/constants.ts");
5585
5572
  var helper = __webpack_require__("./src/utils/helper.ts");
5586
5573
  var util = __webpack_require__("./src/runtime/util.ts");
5587
5574
  var external_node_module_ = __webpack_require__("node:module");
5575
+ var external_node_path_ = __webpack_require__("node:path");
5588
5576
  var external_pathe_ = __webpack_require__("pathe");
5589
5577
  var logger = __webpack_require__("./src/utils/logger.ts");
5590
5578
  const shouldInterop = ({ interopDefault = true, modulePath, mod })=>{
@@ -5662,7 +5650,7 @@ const createRequire = (filename, distPath, rstestContext, assetFiles, interopDef
5662
5650
  return require1;
5663
5651
  };
5664
5652
  const defineRstestDynamicImport = ({ testPath, interopDefault, returnModule = false })=>async (specifier, importAttributes)=>{
5665
- const resolvedPath = isAbsolute(specifier) ? pathToFileURL(specifier) : await import.meta.resolve(specifier, pathToFileURL(testPath));
5653
+ const resolvedPath = (0, external_node_path_.isAbsolute)(specifier) ? pathToFileURL(specifier) : await import.meta.resolve(specifier, pathToFileURL(testPath));
5666
5654
  const modulePath = 'string' == typeof resolvedPath ? resolvedPath : resolvedPath.pathname;
5667
5655
  if (importAttributes?.with?.rstest) delete importAttributes.with.rstest;
5668
5656
  const importedModule = await import(modulePath, importAttributes);
@@ -5904,6 +5892,9 @@ const loadFiles = async ({ setupEntries, assetFiles, rstestContext, distPath, te
5904
5892
  interopDefault
5905
5893
  });
5906
5894
  };
5895
+ const onExit = ()=>{
5896
+ process.exit();
5897
+ };
5907
5898
  const runInPool = async (options)=>{
5908
5899
  isTeardown = false;
5909
5900
  const { entryInfo: { distPath, testPath }, setupEntries, assetFiles, type, context: { runtimeConfig: { isolate } } } = options;
@@ -5915,6 +5906,12 @@ const runInPool = async (options)=>{
5915
5906
  cleanups.push(()=>{
5916
5907
  process.exit = exit;
5917
5908
  });
5909
+ process.off('SIGTERM', onExit);
5910
+ const teardown = async ()=>{
5911
+ await Promise.all(cleanups.map((fn)=>fn()));
5912
+ isTeardown = true;
5913
+ process.once('SIGTERM', onExit);
5914
+ };
5918
5915
  if ('collect' === type) try {
5919
5916
  const { rstestContext, runner, cleanup, unhandledErrors, interopDefault } = await preparePool(options);
5920
5917
  cleanups.push(cleanup);
@@ -5940,8 +5937,7 @@ const runInPool = async (options)=>{
5940
5937
  errors: (0, util.o)(err)
5941
5938
  };
5942
5939
  } finally{
5943
- await Promise.all(cleanups.map((fn)=>fn()));
5944
- isTeardown = true;
5940
+ await teardown();
5945
5941
  }
5946
5942
  try {
5947
5943
  const { rstestContext, runner, rpc, api, cleanup, unhandledErrors, interopDefault } = await preparePool(options);
@@ -5980,8 +5976,7 @@ const runInPool = async (options)=>{
5980
5976
  errors: (0, util.o)(err)
5981
5977
  };
5982
5978
  } finally{
5983
- await Promise.all(cleanups.map((fn)=>fn()));
5984
- isTeardown = true;
5979
+ await teardown();
5985
5980
  }
5986
5981
  };
5987
5982
  const worker = runInPool;
@@ -59,6 +59,7 @@ declare interface EncodedSourceMap extends SourceMapV3 {
59
59
  declare type EncodedSourceMapXInput = EncodedSourceMap & XInput;
60
60
 
61
61
  declare type FormattedError = {
62
+ fullStack?: boolean;
62
63
  message: string;
63
64
  name?: string;
64
65
  stack?: string;
@@ -4,6 +4,7 @@ import type { Assertion as Assertion_2 } from '@vitest/expect';
4
4
  import type { ExpectStatic as ExpectStatic_2 } from '@vitest/expect';
5
5
  import type { MatcherState as MatcherState_2 } from '@vitest/expect';
6
6
  import type { RsbuildConfig } from '@rsbuild/core';
7
+ import type { SnapshotManager } from '@vitest/snapshot/manager';
7
8
  import type { SnapshotResult } from '@vitest/snapshot';
8
9
  import type { SnapshotState } from '@vitest/snapshot';
9
10
  import type { SnapshotSummary } from '@vitest/snapshot';
@@ -269,6 +270,7 @@ declare type Fixtures<T extends Record<string, any> = object, ExtraContext = obj
269
270
  };
270
271
 
271
272
  declare type FormattedError = {
273
+ fullStack?: boolean;
272
274
  message: string;
273
275
  name?: string;
274
276
  stack?: string;
@@ -520,6 +522,8 @@ declare type Rstest = RunnerAPI & {
520
522
 
521
523
  export declare const rstest: RstestUtilities;
522
524
 
525
+ declare type RstestCommand = 'watch' | 'run' | 'list';
526
+
523
527
  export declare interface RstestConfig {
524
528
  /**
525
529
  * Project root
@@ -679,6 +683,26 @@ export declare type RstestConfigExport = RstestConfig | RstestConfigSyncFn | Rst
679
683
 
680
684
  export declare type RstestConfigSyncFn = () => RstestConfig;
681
685
 
686
+ declare type RstestContext = {
687
+ /** The Rstest core version. */
688
+ version: string;
689
+ /** The root path of current project. */
690
+ rootPath: string;
691
+ /** The original Rstest config passed from the createRstest method. */
692
+ originalConfig: Readonly<RstestConfig>;
693
+ /** The normalized Rstest config. */
694
+ normalizedConfig: NormalizedConfig;
695
+ /**
696
+ * The command type.
697
+ *
698
+ * - dev: `rstest dev`
699
+ * - run: `rstest run`
700
+ */
701
+ command: RstestCommand;
702
+ reporters: Reporter[];
703
+ snapshotManager: SnapshotManager;
704
+ };
705
+
682
706
  declare type RstestExpect = ExpectStatic;
683
707
 
684
708
  declare type RstestPoolOptions = {
@@ -722,7 +746,7 @@ declare type RstestUtilities = {
722
746
  /**
723
747
  * Mock a module
724
748
  */
725
- mock: <T = unknown>(moduleName: string, moduleFactory?: () => T) => void;
749
+ mock: <T = unknown>(moduleName: string, moduleFactory?: () => T | Promise<T>) => void;
726
750
  /**
727
751
  * Mock a module
728
752
  */
@@ -730,7 +754,7 @@ declare type RstestUtilities = {
730
754
  /**
731
755
  * Mock a module, not hoisted.
732
756
  */
733
- doMock: <T = unknown>(moduleName: string, moduleFactory?: () => T) => void;
757
+ doMock: <T = unknown>(moduleName: string, moduleFactory?: () => T | Promise<T>) => void;
734
758
  /**
735
759
  * Mock a module, not hoisted.
736
760
  */
@@ -779,6 +803,14 @@ declare type RstestUtilities = {
779
803
  * Restores all global variables that were changed with `rstest.stubGlobal`.
780
804
  */
781
805
  unstubAllGlobals: () => RstestUtilities;
806
+ /**
807
+ * Update runtime config for the current test.
808
+ */
809
+ setConfig: (config: RuntimeOptions) => void;
810
+ /**
811
+ * Reset runtime config that were changed with `rstest.setConfig`.
812
+ */
813
+ resetConfig: () => void;
782
814
  /**
783
815
  * Mocks timers using `@sinonjs/fake-timers`.
784
816
  */
@@ -820,6 +852,10 @@ declare type RunnerAPI = {
820
852
  afterEach: (fn: AfterEachListener, timeout?: number) => MaybePromise<void>;
821
853
  };
822
854
 
855
+ declare type RuntimeConfig = Pick<RstestContext['normalizedConfig'], 'testTimeout' | 'testNamePattern' | 'globals' | 'passWithNoTests' | 'retry' | 'clearMocks' | 'resetMocks' | 'restoreMocks' | 'unstubEnvs' | 'unstubGlobals' | 'maxConcurrency' | 'printConsoleTrace' | 'disableConsoleIntercept' | 'testEnvironment' | 'isolate' | 'hookTimeout'>;
856
+
857
+ declare type RuntimeOptions = Partial<Pick<RuntimeConfig, 'testTimeout' | 'hookTimeout' | 'clearMocks' | 'resetMocks' | 'restoreMocks' | 'maxConcurrency' | 'retry'>>;
858
+
823
859
  declare interface SnapshotMatcher<T> {
824
860
  <U extends {
825
861
  [P in keyof T]: any;
@@ -170,6 +170,7 @@ declare interface FixtureOptions {
170
170
  }
171
171
 
172
172
  declare type FormattedError = {
173
+ fullStack?: boolean;
173
174
  message: string;
174
175
  name?: string;
175
176
  stack?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rstest/core",
3
- "version": "0.0.7",
3
+ "version": "0.0.9",
4
4
  "description": "The Rsbuild-based test tool.",
5
5
  "bugs": {
6
6
  "url": "https://github.com/web-infra-dev/rstest/issues"
@@ -48,11 +48,11 @@
48
48
  "importMeta.d.ts"
49
49
  ],
50
50
  "dependencies": {
51
- "@rsbuild/core": "1.4.6",
51
+ "@rsbuild/core": "1.4.8",
52
52
  "@types/chai": "^5.2.2",
53
53
  "@vitest/expect": "^3.2.4",
54
54
  "@vitest/snapshot": "^3.2.4",
55
- "birpc": "2.4.0",
55
+ "birpc": "2.5.0",
56
56
  "chai": "^5.2.1",
57
57
  "pathe": "^2.0.3",
58
58
  "std-env": "^3.9.0",
@@ -62,7 +62,7 @@
62
62
  "@babel/code-frame": "^7.27.1",
63
63
  "@jridgewell/trace-mapping": "0.3.29",
64
64
  "@microsoft/api-extractor": "^7.52.8",
65
- "@rslib/core": "0.10.5",
65
+ "@rslib/core": "0.10.6",
66
66
  "@sinonjs/fake-timers": "^14.0.0",
67
67
  "@types/babel__code-frame": "^7.0.6",
68
68
  "@types/jsdom": "^21.1.7",