@rstest/core 0.5.3 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -2076,7 +2076,7 @@ ${section.body}` : section.body).join("\n\n"));
2076
2076
  const applyCommonOptions = (cli)=>{
2077
2077
  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`', {
2078
2078
  default: 'jiti'
2079
- }).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('--coverage', 'Enable code coverage collection').option('--project <name>', 'Run only projects that match the name, can be a full name or wildcards pattern').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('--reporter <reporter>', 'Specify the reporter to use').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');
2079
+ }).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('--coverage', 'Enable code coverage collection').option('--project <name>', 'Run only projects that match the name, can be a full name or wildcards pattern').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('--reporter <reporter>', 'Specify the reporter to use').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('--hideSkippedTests', 'Hide skipped tests from the output').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');
2080
2080
  };
2081
2081
  const runRest = async ({ options, filters, command })=>{
2082
2082
  let rstest;
@@ -2108,7 +2108,7 @@ ${section.body}` : section.body).join("\n\n"));
2108
2108
  function setupCommands() {
2109
2109
  const cli = dist('rstest');
2110
2110
  cli.help();
2111
- cli.version("0.5.3");
2111
+ cli.version("0.6.0");
2112
2112
  applyCommonOptions(cli);
2113
2113
  cli.command('[...filters]', 'run tests').option('-w, --watch', 'Run tests in watch mode').action(async (filters, options)=>{
2114
2114
  (0, prepare.N)();
@@ -2215,7 +2215,8 @@ ${section.body}` : section.body).join("\n\n"));
2215
2215
  'maxConcurrency',
2216
2216
  'printConsoleTrace',
2217
2217
  'disableConsoleIntercept',
2218
- 'testEnvironment'
2218
+ 'testEnvironment',
2219
+ 'hideSkippedTests'
2219
2220
  ];
2220
2221
  for (const key of keys)if (void 0 !== options[key]) config[key] = options[key];
2221
2222
  if (options.reporter) config.reporters = (0, utils.bg)(options.reporter);
@@ -2347,7 +2348,7 @@ ${conflictProjects.map((p)=>`- ${p.configFilePath || p.config.root}`).join('\n')
2347
2348
  if (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) console.log();
2348
2349
  }
2349
2350
  function showRstest() {
2350
- _utils_logger__WEBPACK_IMPORTED_MODULE_0__.vF.greet(" Rstest v0.5.3");
2351
+ _utils_logger__WEBPACK_IMPORTED_MODULE_0__.vF.greet(" Rstest v0.6.0");
2351
2352
  _utils_logger__WEBPACK_IMPORTED_MODULE_0__.vF.log('');
2352
2353
  }
2353
2354
  },
@@ -2452,6 +2453,7 @@ ${conflictProjects.map((p)=>`- ${p.configFilePath || p.config.root}`).join('\n')
2452
2453
  disableConsoleIntercept: false,
2453
2454
  snapshotFormat: {},
2454
2455
  env: {},
2456
+ hideSkippedTests: false,
2455
2457
  coverage: {
2456
2458
  exclude: [
2457
2459
  '**/node_modules/**',
@@ -3144,8 +3146,9 @@ ${conflictProjects.map((p)=>`- ${p.configFilePath || p.config.root}`).join('\n')
3144
3146
  todo: utils.yW.gray(statusStr.todo),
3145
3147
  skip: utils.yW.gray(statusStr.skip)
3146
3148
  };
3147
- const logCase = (result, slowTestThreshold)=>{
3148
- const isSlowCase = (result.duration || 0) > slowTestThreshold;
3149
+ const logCase = (result, options)=>{
3150
+ const isSlowCase = (result.duration || 0) > options.slowTestThreshold;
3151
+ if (options.hideSkippedTests && 'skip' === result.status) return;
3149
3152
  const icon = isSlowCase && 'pass' === result.status ? utils.yW.yellow(statusStr[result.status]) : statusColorfulStr[result.status];
3150
3153
  const nameStr = (0, utils.fN)(result);
3151
3154
  const duration = void 0 !== result.duration ? ` (${(0, utils.kV)(result.duration)})` : '';
@@ -3181,7 +3184,10 @@ ${conflictProjects.map((p)=>`- ${p.configFilePath || p.config.root}`).join('\n')
3181
3184
  logFileTitle(test, relativePath);
3182
3185
  for (const result of test.results){
3183
3186
  const isDisplayed = 'fail' === result.status || (result.duration ?? 0) > slowTestThreshold || (result.retryCount ?? 0) > 0;
3184
- isDisplayed && logCase(result, slowTestThreshold);
3187
+ isDisplayed && logCase(result, {
3188
+ slowTestThreshold,
3189
+ hideSkippedTests: this.config.hideSkippedTests
3190
+ });
3185
3191
  }
3186
3192
  }
3187
3193
  onTestCaseResult(result) {
@@ -3190,17 +3196,16 @@ ${conflictProjects.map((p)=>`- ${p.configFilePath || p.config.root}`).join('\n')
3190
3196
  onUserConsoleLog(log) {
3191
3197
  const shouldLog = this.config.onConsoleLog?.(log.content) ?? true;
3192
3198
  if (!shouldLog) return;
3193
- const titles = [
3194
- log.name
3195
- ];
3199
+ const titles = [];
3196
3200
  const testPath = (0, pathe_M_eThtNZ.b)(this.rootPath, log.testPath);
3197
3201
  if (log.trace) {
3198
3202
  const [frame] = (0, stack_trace_parser_esm.q)(log.trace);
3199
3203
  const filePath = (0, pathe_M_eThtNZ.b)(this.rootPath, frame.file || '');
3200
- if (filePath !== testPath) titles.push((0, utils.EQ)(testPath));
3201
- titles.push((0, utils.EQ)(filePath) + utils.yW.gray(`:${frame.lineNumber}:${frame.column}`));
3202
- } else titles.push((0, utils.EQ)(testPath));
3203
- utils.vF.log(titles.join(utils.yW.gray(' | ')));
3204
+ if (filePath !== testPath) titles.push(testPath);
3205
+ titles.push(`${filePath}:${frame.lineNumber}:${frame.column}`);
3206
+ } else titles.push(testPath);
3207
+ utils.vF.log('');
3208
+ utils.vF.log(`${log.name}${utils.yW.gray(utils.yW.dim(` | ${titles.join(utils.yW.gray(utils.yW.dim(' | ')))}`))}`);
3204
3209
  utils.vF.log(log.content);
3205
3210
  utils.vF.log('');
3206
3211
  }
@@ -3270,7 +3275,7 @@ ${conflictProjects.map((p)=>`- ${p.configFilePath || p.config.root}`).join('\n')
3270
3275
  logs.push(`::${type} file=${this.onWritePath?.(file) || file},line=${line},col=${column},title=${escapeData(title)}::${escapeData(message)}`);
3271
3276
  }
3272
3277
  }
3273
- this.log('::group::error for github actions');
3278
+ this.log('::group::Error for GitHub Actions');
3274
3279
  for (const log of logs)this.log(log);
3275
3280
  this.log('::endgroup::');
3276
3281
  }
@@ -3418,7 +3423,10 @@ ${conflictProjects.map((p)=>`- ${p.configFilePath || p.config.root}`).join('\n')
3418
3423
  const relativePath = (0, pathe_M_eThtNZ.b)(this.rootPath, test.testPath);
3419
3424
  const { slowTestThreshold } = this.config;
3420
3425
  logFileTitle(test, relativePath, true);
3421
- for (const result of test.results)logCase(result, slowTestThreshold);
3426
+ for (const result of test.results)logCase(result, {
3427
+ slowTestThreshold,
3428
+ hideSkippedTests: this.config.hideSkippedTests
3429
+ });
3422
3430
  }
3423
3431
  }
3424
3432
  function formatEnvironmentName(name) {
@@ -3460,11 +3468,12 @@ ${conflictProjects.map((p)=>`- ${p.configFilePath || p.config.root}`).join('\n')
3460
3468
  });
3461
3469
  this.reporters = reporters;
3462
3470
  this.snapshotManager = snapshotManager;
3463
- this.version = "0.5.3";
3471
+ this.version = "0.6.0";
3464
3472
  this.rootPath = rootPath;
3465
3473
  this.originalConfig = userConfig;
3466
3474
  this.normalizedConfig = rstestConfig;
3467
3475
  this.projects = projects.length ? projects.map((project)=>{
3476
+ project.config.root = (0, utils.FI)(rootPath, project.config.root);
3468
3477
  const config = (0, src_config.wX)(project.config);
3469
3478
  config.isolate = rstestConfig.isolate;
3470
3479
  config.source ??= {};
@@ -3543,14 +3552,14 @@ ${conflictProjects.map((p)=>`- ${p.configFilePath || p.config.root}`).join('\n')
3543
3552
  }, config);
3544
3553
  const runTests = async ()=>{
3545
3554
  const { runTests } = await Promise.all([
3546
- __webpack_require__.e("816"),
3555
+ __webpack_require__.e("628"),
3547
3556
  __webpack_require__.e("33")
3548
3557
  ]).then(__webpack_require__.bind(__webpack_require__, "./src/core/runTests.ts"));
3549
3558
  await runTests(context);
3550
3559
  };
3551
3560
  const listTests = async (options)=>{
3552
3561
  const { listTests } = await Promise.all([
3553
- __webpack_require__.e("816"),
3562
+ __webpack_require__.e("628"),
3554
3563
  __webpack_require__.e("971")
3555
3564
  ]).then(__webpack_require__.bind(__webpack_require__, "./src/core/listTests.ts"));
3556
3565
  await listTests(context, options);
@@ -3569,11 +3578,9 @@ ${conflictProjects.map((p)=>`- ${p.configFilePath || p.config.root}`).join('\n')
3569
3578
  WB: ()=>TS_CONFIG_FILE,
3570
3579
  kv: ()=>DEFAULT_CONFIG_EXTENSIONS,
3571
3580
  t: ()=>DEFAULT_CONFIG_NAME,
3572
- vO: ()=>TEST_DELIMITER,
3573
3581
  zZ: ()=>TEMP_RSTEST_OUTPUT_DIR
3574
3582
  });
3575
3583
  const DEFAULT_CONFIG_NAME = 'rstest.config';
3576
- const TEST_DELIMITER = '>';
3577
3584
  const TEMP_RSTEST_OUTPUT_DIR = 'dist/.rstest-temp';
3578
3585
  const TEMP_RSTEST_OUTPUT_DIR_GLOB = '**/dist/.rstest-temp';
3579
3586
  const DEFAULT_CONFIG_EXTENSIONS = [
@@ -4014,6 +4021,18 @@ ${conflictProjects.map((p)=>`- ${p.configFilePath || p.config.root}`).join('\n')
4014
4021
  }
4015
4022
  var stack_trace_parser_esm = __webpack_require__("../../node_modules/.pnpm/stacktrace-parser@0.1.11/node_modules/stacktrace-parser/dist/stack-trace-parser.esm.js");
4016
4023
  var utils = __webpack_require__("./src/utils/index.ts");
4024
+ const hintNotDefinedError = (message)=>{
4025
+ const [, varName] = message.match(/(\w+) is not defined/) || [];
4026
+ if (varName) {
4027
+ if (utils.TE.includes(varName)) return message.replace(`${varName} is not defined`, `${varName} is not defined. Did you forget to enable "globals" configuration?`);
4028
+ if ([
4029
+ 'jest',
4030
+ 'vitest'
4031
+ ].includes(varName)) return message.replace(`${varName} is not defined`, `${varName} is not defined. Did you mean rstest?`);
4032
+ if ('React' === varName) return message.replace(`${varName} is not defined`, `${varName} is not defined. Did you forget to install "${utils.yW.yellow('@rsbuild/plugin-react')}" plugin?`);
4033
+ }
4034
+ return message;
4035
+ };
4017
4036
  async function printError(error, getSourcemap, rootPath) {
4018
4037
  const errorName = error.name || 'Unknown Error';
4019
4038
  if (error.message.includes('Vitest failed to access its internal state')) {
@@ -4026,16 +4045,7 @@ ${conflictProjects.map((p)=>`- ${p.configFilePath || p.config.root}`).join('\n')
4026
4045
  utils.vF.log(`${utils.yW.red(tips.join('\n'))}\n`);
4027
4046
  return;
4028
4047
  }
4029
- if (error.message.includes('is not defined')) {
4030
- const [, varName] = error.message.match(/(.*) is not defined/) || [];
4031
- if (varName) {
4032
- if (utils.TE.includes(varName)) error.message = error.message.replace(`${varName} is not defined`, `${varName} is not defined. Did you forget to enable "globals" configuration?`);
4033
- else if ([
4034
- 'jest',
4035
- 'vitest'
4036
- ].includes(varName)) error.message = error.message.replace(`${varName} is not defined`, `${varName} is not defined. Did you mean rstest?`);
4037
- }
4038
- }
4048
+ if (error.message.includes('is not defined')) error.message = hintNotDefinedError(error.message);
4039
4049
  utils.vF.log(`${utils.yW.red(utils.yW.bold(errorName))}${utils.yW.red(`: ${error.message}`)}\n`);
4040
4050
  if (error.diff) {
4041
4051
  utils.vF.log(error.diff);
@@ -4130,15 +4140,15 @@ ${conflictProjects.map((p)=>`- ${p.configFilePath || p.config.root}`).join('\n')
4130
4140
  var pathe__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs");
4131
4141
  var picocolors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
4132
4142
  var picocolors__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/ __webpack_require__.n(picocolors__WEBPACK_IMPORTED_MODULE_1__);
4133
- var _constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./src/utils/constants.ts");
4134
- const formatRootStr = (rootStr, root)=>rootStr.replace('<rootDir>', root);
4143
+ __webpack_require__("./src/utils/constants.ts");
4144
+ const formatRootStr = (rootStr, root)=>rootStr.replace('<rootDir>', (0, pathe__WEBPACK_IMPORTED_MODULE_2__.n)(root));
4135
4145
  function getAbsolutePath(base, filepath) {
4136
4146
  return (0, pathe__WEBPACK_IMPORTED_MODULE_2__.i)(filepath) ? filepath : (0, pathe__WEBPACK_IMPORTED_MODULE_2__.j)(base, filepath);
4137
4147
  }
4138
4148
  const parsePosix = (filePath)=>{
4139
4149
  const { dir, base } = (0, pathe__WEBPACK_IMPORTED_MODULE_2__.p)(filePath);
4140
4150
  return {
4141
- dir: dir.split(pathe__WEBPACK_IMPORTED_MODULE_2__.s).join('/'),
4151
+ dir: dir.split("/").join('/'),
4142
4152
  base
4143
4153
  };
4144
4154
  };
@@ -4178,7 +4188,7 @@ ${conflictProjects.map((p)=>`- ${p.configFilePath || p.config.root}`).join('\n')
4178
4188
  return time;
4179
4189
  };
4180
4190
  const getTaskNames = (test)=>(test.parentNames || []).concat(test.name).filter(Boolean);
4181
- const getTaskNameWithPrefix = (test, delimiter = _constants__WEBPACK_IMPORTED_MODULE_0__.vO)=>getTaskNames(test).join(` ${delimiter} `);
4191
+ const getTaskNameWithPrefix = (test, delimiter = ">")=>getTaskNames(test).join(` ${delimiter} `);
4182
4192
  const REGEXP_FLAG_PREFIX = 'RSTEST_REGEXP:';
4183
4193
  const wrapRegex = (value)=>`${REGEXP_FLAG_PREFIX}${value.toString()}`;
4184
4194
  const serializableConfig = (normalizedConfig)=>{
@@ -4224,7 +4234,7 @@ ${conflictProjects.map((p)=>`- ${p.configFilePath || p.config.root}`).join('\n')
4224
4234
  fN: ()=>helper.fN,
4225
4235
  vF: ()=>logger.vF,
4226
4236
  Ok: ()=>helper.Ok,
4227
- vO: ()=>constants.vO,
4237
+ vO: ()=>">",
4228
4238
  tG: ()=>getTestEntries,
4229
4239
  FI: ()=>helper.FI,
4230
4240
  Uq: ()=>helper.Uq,
@@ -4434,6 +4444,7 @@ ${conflictProjects.map((p)=>`- ${p.configFilePath || p.config.root}`).join('\n')
4434
4444
  if ('truecolor' === env.COLORTERM) return 3;
4435
4445
  if ('xterm-kitty' === env.TERM) return 3;
4436
4446
  if ('xterm-ghostty' === env.TERM) return 3;
4447
+ if ('wezterm' === env.TERM) return 3;
4437
4448
  if ('TERM_PROGRAM' in env) {
4438
4449
  const version = Number.parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
4439
4450
  switch(env.TERM_PROGRAM){
@@ -4568,6 +4579,14 @@ ${conflictProjects.map((p)=>`- ${p.configFilePath || p.config.root}`).join('\n')
4568
4579
  color: magenta
4569
4580
  }
4570
4581
  };
4582
+ const normalizeErrorMessage = (err)=>{
4583
+ if (err.stack) {
4584
+ let [name, ...rest] = err.stack.split('\n');
4585
+ if (name.startsWith('Error: ')) name = name.slice(7);
4586
+ return `${name}\n${gray(rest.join('\n'))}`;
4587
+ }
4588
+ return err.message;
4589
+ };
4571
4590
  let createLogger = (options = {})=>{
4572
4591
  let maxLevel = options.level || 'info';
4573
4592
  let log = (type, message, ...args)=>{
@@ -4580,12 +4599,14 @@ ${conflictProjects.map((p)=>`- ${p.configFilePath || p.config.root}`).join('\n')
4580
4599
  label = (logType.label || '').padEnd(7);
4581
4600
  label = bold(logType.color ? logType.color(label) : label);
4582
4601
  }
4583
- if (message instanceof Error) if (message.stack) {
4584
- let [name, ...rest] = message.stack.split('\n');
4585
- if (name.startsWith('Error: ')) name = name.slice(7);
4586
- text = `${name}\n${gray(rest.join('\n'))}`;
4587
- } else text = message.message;
4588
- else if ('error' === logType.level && 'string' == typeof message) {
4602
+ if (message instanceof Error) {
4603
+ text += normalizeErrorMessage(message);
4604
+ const { cause } = message;
4605
+ if (cause) {
4606
+ text += yellow('\n [cause]: ');
4607
+ text += cause instanceof Error ? normalizeErrorMessage(cause) : String(cause);
4608
+ }
4609
+ } else if ('error' === logType.level && 'string' == typeof message) {
4589
4610
  let lines = message.split('\n');
4590
4611
  text = lines.map((line)=>isErrorStackMessage(line) ? gray(line) : line).join('\n');
4591
4612
  } else text = `${message}`;
@@ -4697,8 +4718,7 @@ ${conflictProjects.map((p)=>`- ${p.configFilePath || p.config.root}`).join('\n')
4697
4718
  j: ()=>join,
4698
4719
  n: ()=>normalize,
4699
4720
  p: ()=>parse,
4700
- r: ()=>resolve,
4701
- s: ()=>sep
4721
+ r: ()=>resolve
4702
4722
  });
4703
4723
  let _lazyMatch = ()=>{
4704
4724
  var __lib__ = (()=>{
@@ -0,0 +1,118 @@
1
+ const originalWebpackRequire = __webpack_require__;
2
+ __webpack_require__ = function(...args) {
3
+ try {
4
+ return originalWebpackRequire(...args);
5
+ } catch (e) {
6
+ const errMsg = e.message ?? e.toString();
7
+ if (errMsg.includes('__webpack_modules__[moduleId] is not a function')) throw new Error(`[Rstest] Cannot find module "${args[0]}"`);
8
+ throw e;
9
+ }
10
+ };
11
+ Object.keys(originalWebpackRequire).forEach((key)=>{
12
+ __webpack_require__[key] = originalWebpackRequire[key];
13
+ });
14
+ __webpack_require__.rstest_original_modules = {};
15
+ __webpack_require__.rstest_original_module_factories = {};
16
+ __webpack_require__.rstest_unmock = (id)=>{
17
+ const originalModuleFactory = __webpack_require__.rstest_original_module_factories[id];
18
+ if (originalModuleFactory) __webpack_modules__[id] = originalModuleFactory;
19
+ delete __webpack_module_cache__[id];
20
+ };
21
+ __webpack_require__.rstest_do_unmock = __webpack_require__.rstest_unmock;
22
+ __webpack_require__.rstest_require_actual = __webpack_require__.rstest_import_actual = (id)=>{
23
+ const originalModule = __webpack_require__.rstest_original_modules[id];
24
+ const fallbackMod = __webpack_require__(id);
25
+ return originalModule ? originalModule : fallbackMod;
26
+ };
27
+ __webpack_require__.rstest_mock = (id, modFactory)=>{
28
+ let requiredModule;
29
+ try {
30
+ requiredModule = __webpack_require__(id);
31
+ } catch {} finally{
32
+ __webpack_require__.rstest_original_modules[id] = requiredModule;
33
+ __webpack_require__.rstest_original_module_factories[id] = __webpack_modules__[id];
34
+ }
35
+ if ('string' == typeof modFactory || 'number' == typeof modFactory) __webpack_module_cache__[id] = {
36
+ exports: __webpack_require__(modFactory)
37
+ };
38
+ else if ('function' == typeof modFactory) {
39
+ const finalModFactory = function(__unused_webpack_module, __webpack_exports__, __webpack_require__1) {
40
+ __webpack_require__1.r(__webpack_exports__);
41
+ const res = modFactory();
42
+ for(const key in res)__webpack_require__1.d(__webpack_exports__, {
43
+ [key]: ()=>res[key]
44
+ });
45
+ };
46
+ __webpack_modules__[id] = finalModFactory;
47
+ delete __webpack_module_cache__[id];
48
+ }
49
+ };
50
+ __webpack_require__.rstest_mock_require = (id, modFactory)=>{
51
+ let requiredModule;
52
+ try {
53
+ requiredModule = __webpack_require__(id);
54
+ } catch {} finally{
55
+ __webpack_require__.rstest_original_modules[id] = requiredModule;
56
+ __webpack_require__.rstest_original_module_factories[id] = __webpack_modules__[id];
57
+ }
58
+ if ('string' == typeof modFactory || 'number' == typeof modFactory) __webpack_module_cache__[id] = {
59
+ exports: __webpack_require__(modFactory)
60
+ };
61
+ else if ('function' == typeof modFactory) {
62
+ const exports = modFactory();
63
+ __webpack_require__.r(exports);
64
+ __webpack_module_cache__[id] = {
65
+ exports,
66
+ id,
67
+ loaded: true
68
+ };
69
+ }
70
+ };
71
+ __webpack_require__.rstest_do_mock = (id, modFactory)=>{
72
+ let requiredModule;
73
+ try {
74
+ requiredModule = __webpack_require__(id);
75
+ } catch {} finally{
76
+ __webpack_require__.rstest_original_modules[id] = requiredModule;
77
+ __webpack_require__.rstest_original_module_factories[id] = __webpack_modules__[id];
78
+ }
79
+ if ('string' == typeof modFactory || 'number' == typeof modFactory) __webpack_module_cache__[id] = {
80
+ exports: __webpack_require__(modFactory)
81
+ };
82
+ else if ('function' == typeof modFactory) {
83
+ const exports = modFactory();
84
+ __webpack_require__.r(exports);
85
+ __webpack_module_cache__[id] = {
86
+ exports,
87
+ id,
88
+ loaded: true
89
+ };
90
+ }
91
+ };
92
+ __webpack_require__.rstest_do_mock_require = (id, modFactory)=>{
93
+ let requiredModule;
94
+ try {
95
+ requiredModule = __webpack_require__(id);
96
+ } catch {} finally{
97
+ __webpack_require__.rstest_original_modules[id] = requiredModule;
98
+ __webpack_require__.rstest_original_module_factories[id] = __webpack_modules__[id];
99
+ }
100
+ if ('string' == typeof modFactory || 'number' == typeof modFactory) __webpack_module_cache__[id] = {
101
+ exports: __webpack_require__(modFactory)
102
+ };
103
+ else if ('function' == typeof modFactory) {
104
+ const exports = modFactory();
105
+ __webpack_require__.r(exports);
106
+ __webpack_module_cache__[id] = {
107
+ exports,
108
+ id,
109
+ loaded: true
110
+ };
111
+ }
112
+ };
113
+ __webpack_require__.rstest_reset_modules = ()=>{
114
+ const mockedIds = Object.keys(__webpack_require__.rstest_original_modules);
115
+ Object.keys(__webpack_module_cache__).forEach((id)=>{
116
+ if (!mockedIds.includes(id)) delete __webpack_module_cache__[id];
117
+ });
118
+ };
package/dist/worker.js CHANGED
@@ -2905,7 +2905,7 @@ var __webpack_modules__ = {
2905
2905
  return -1 !== position && (-1 === terminatorPosition || position < terminatorPosition);
2906
2906
  };
2907
2907
  },
2908
- "../../node_modules/.pnpm/jest-diff@30.1.2/node_modules/jest-diff/build/index.js": function(module, __unused_webpack_exports, __webpack_require__) {
2908
+ "../../node_modules/.pnpm/jest-diff@30.2.0/node_modules/jest-diff/build/index.js": function(module, __unused_webpack_exports, __webpack_require__) {
2909
2909
  /*!
2910
2910
  * /**
2911
2911
  * * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -3770,7 +3770,7 @@ var __webpack_modules__ = {
3770
3770
  });
3771
3771
  var _chalk = _interopRequireDefault(__webpack_require__("../../node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/source/index.js"));
3772
3772
  var _getType = __webpack_require__("../../node_modules/.pnpm/@jest+get-type@30.1.0/node_modules/@jest/get-type/build/index.js");
3773
- var _prettyFormat = __webpack_require__("../../node_modules/.pnpm/pretty-format@30.0.5/node_modules/pretty-format/build/index.js");
3773
+ var _prettyFormat = __webpack_require__("../../node_modules/.pnpm/pretty-format@30.2.0/node_modules/pretty-format/build/index.js");
3774
3774
  var _cleanupSemantic = __nested_webpack_require_48295__("./src/cleanupSemantic.ts");
3775
3775
  var _constants = __nested_webpack_require_48295__("./src/constants.ts");
3776
3776
  var _diffLines = __nested_webpack_require_48295__("./src/diffLines.ts");
@@ -3954,7 +3954,7 @@ var __webpack_modules__ = {
3954
3954
  module.exports = createColors();
3955
3955
  module.exports.createColors = createColors;
3956
3956
  },
3957
- "../../node_modules/.pnpm/pretty-format@30.0.5/node_modules/pretty-format/build/index.js": function(module, __unused_webpack_exports, __webpack_require__) {
3957
+ "../../node_modules/.pnpm/pretty-format@30.2.0/node_modules/pretty-format/build/index.js": function(module, __unused_webpack_exports, __webpack_require__) {
3958
3958
  /*!
3959
3959
  * /**
3960
3960
  * * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -4494,6 +4494,7 @@ var __webpack_modules__ = {
4494
4494
  if ('function' === typeOf) return printFunction(val, printFunctionName);
4495
4495
  if ('symbol' === typeOf) return printSymbol(val);
4496
4496
  const toStringed = src_toString.call(val);
4497
+ if ('[object Promise]' === toStringed) return 'Promise {}';
4497
4498
  if ('[object WeakMap]' === toStringed) return 'WeakMap {}';
4498
4499
  if ('[object WeakSet]' === toStringed) return 'WeakSet {}';
4499
4500
  if ('[object Function]' === toStringed || '[object GeneratorFunction]' === toStringed) return printFunction(val, printFunctionName);
@@ -6417,7 +6418,6 @@ var __webpack_modules__ = {
6417
6418
  map: map
6418
6419
  };
6419
6420
  };
6420
- exports.SourceNode = SourceNode;
6421
6421
  },
6422
6422
  "../../node_modules/.pnpm/source-map@0.6.1/node_modules/source-map/lib/util.js": function(__unused_webpack_module, exports) {
6423
6423
  function getArg(aArgs, aName, aDefaultValue) {
@@ -6621,7 +6621,7 @@ var __webpack_modules__ = {
6621
6621
  "../../node_modules/.pnpm/source-map@0.6.1/node_modules/source-map/source-map.js": function(__unused_webpack_module, exports, __webpack_require__) {
6622
6622
  __webpack_require__("../../node_modules/.pnpm/source-map@0.6.1/node_modules/source-map/lib/source-map-generator.js").SourceMapGenerator;
6623
6623
  exports.SourceMapConsumer = __webpack_require__("../../node_modules/.pnpm/source-map@0.6.1/node_modules/source-map/lib/source-map-consumer.js").SourceMapConsumer;
6624
- __webpack_require__("../../node_modules/.pnpm/source-map@0.6.1/node_modules/source-map/lib/source-node.js").SourceNode;
6624
+ __webpack_require__("../../node_modules/.pnpm/source-map@0.6.1/node_modules/source-map/lib/source-node.js");
6625
6625
  },
6626
6626
  "../../node_modules/.pnpm/supports-color@7.2.0/node_modules/supports-color/index.js": function(module, __unused_webpack_exports, __webpack_require__) {
6627
6627
  const os = __webpack_require__("node:os");
@@ -6701,7 +6701,7 @@ var __webpack_modules__ = {
6701
6701
  });
6702
6702
  var external_node_module_ = __webpack_require__("node:module");
6703
6703
  var external_node_util_ = __webpack_require__("node:util");
6704
- var build = __webpack_require__("../../node_modules/.pnpm/jest-diff@30.1.2/node_modules/jest-diff/build/index.js");
6704
+ var build = __webpack_require__("../../node_modules/.pnpm/jest-diff@30.2.0/node_modules/jest-diff/build/index.js");
6705
6705
  build.DIFF_DELETE;
6706
6706
  build.DIFF_EQUAL;
6707
6707
  build.DIFF_INSERT;
@@ -6794,10 +6794,8 @@ var __webpack_modules__ = {
6794
6794
  "./src/utils/constants.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
6795
6795
  __webpack_require__.d(__webpack_exports__, {
6796
6796
  TE: ()=>globalApis,
6797
- q_: ()=>ROOT_SUITE_NAME,
6798
- vO: ()=>TEST_DELIMITER
6797
+ q_: ()=>ROOT_SUITE_NAME
6799
6798
  });
6800
- const TEST_DELIMITER = '>';
6801
6799
  const ROOT_SUITE_NAME = 'Rstest:_internal_root_suite';
6802
6800
  const globalApis = [
6803
6801
  'test',
@@ -6826,7 +6824,7 @@ var __webpack_modules__ = {
6826
6824
  });
6827
6825
  var picocolors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
6828
6826
  var picocolors__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/ __webpack_require__.n(picocolors__WEBPACK_IMPORTED_MODULE_1__);
6829
- var _constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./src/utils/constants.ts");
6827
+ __webpack_require__("./src/utils/constants.ts");
6830
6828
  const isObject = (obj)=>'[object Object]' === Object.prototype.toString.call(obj);
6831
6829
  const castArray = (arr)=>{
6832
6830
  if (void 0 === arr) return [];
@@ -6853,7 +6851,7 @@ var __webpack_modules__ = {
6853
6851
  return time;
6854
6852
  };
6855
6853
  const getTaskNames = (test)=>(test.parentNames || []).concat(test.name).filter(Boolean);
6856
- const getTaskNameWithPrefix = (test, delimiter = _constants__WEBPACK_IMPORTED_MODULE_0__.vO)=>getTaskNames(test).join(` ${delimiter} `);
6854
+ const getTaskNameWithPrefix = (test, delimiter = ">")=>getTaskNames(test).join(` ${delimiter} `);
6857
6855
  const REGEXP_FLAG_PREFIX = 'RSTEST_REGEXP:';
6858
6856
  const unwrapRegex = (value)=>{
6859
6857
  if (value.startsWith(REGEXP_FLAG_PREFIX)) {
@@ -6967,6 +6965,7 @@ var __webpack_modules__ = {
6967
6965
  if ('truecolor' === env.COLORTERM) return 3;
6968
6966
  if ('xterm-kitty' === env.TERM) return 3;
6969
6967
  if ('xterm-ghostty' === env.TERM) return 3;
6968
+ if ('wezterm' === env.TERM) return 3;
6970
6969
  if ('TERM_PROGRAM' in env) {
6971
6970
  const version = Number.parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
6972
6971
  switch(env.TERM_PROGRAM){
@@ -7101,6 +7100,14 @@ var __webpack_modules__ = {
7101
7100
  color: magenta
7102
7101
  }
7103
7102
  };
7103
+ const normalizeErrorMessage = (err)=>{
7104
+ if (err.stack) {
7105
+ let [name, ...rest] = err.stack.split('\n');
7106
+ if (name.startsWith('Error: ')) name = name.slice(7);
7107
+ return `${name}\n${gray(rest.join('\n'))}`;
7108
+ }
7109
+ return err.message;
7110
+ };
7104
7111
  let createLogger = (options = {})=>{
7105
7112
  let maxLevel = options.level || 'info';
7106
7113
  let log = (type, message, ...args)=>{
@@ -7113,12 +7120,14 @@ var __webpack_modules__ = {
7113
7120
  label = (logType.label || '').padEnd(7);
7114
7121
  label = bold(logType.color ? logType.color(label) : label);
7115
7122
  }
7116
- if (message instanceof Error) if (message.stack) {
7117
- let [name, ...rest] = message.stack.split('\n');
7118
- if (name.startsWith('Error: ')) name = name.slice(7);
7119
- text = `${name}\n${gray(rest.join('\n'))}`;
7120
- } else text = message.message;
7121
- else if ('error' === logType.level && 'string' == typeof message) {
7123
+ if (message instanceof Error) {
7124
+ text += normalizeErrorMessage(message);
7125
+ const { cause } = message;
7126
+ if (cause) {
7127
+ text += yellow('\n [cause]: ');
7128
+ text += cause instanceof Error ? normalizeErrorMessage(cause) : String(cause);
7129
+ }
7130
+ } else if ('error' === logType.level && 'string' == typeof message) {
7122
7131
  let lines = message.split('\n');
7123
7132
  text = lines.map((line)=>isErrorStackMessage(line) ? gray(line) : line).join('\n');
7124
7133
  } else text = `${message}`;
@@ -8081,7 +8090,7 @@ function createBirpc(functions, options) {
8081
8090
  if (msg.t === TYPE_REQUEST) {
8082
8091
  const { m: method, a: args } = msg;
8083
8092
  let result, error;
8084
- const fn = resolver ? resolver(method, functions[method]) : functions[method];
8093
+ const fn = await (resolver ? resolver(method, functions[method]) : functions[method]);
8085
8094
  if (fn) try {
8086
8095
  result = await fn.apply("rpc" === bind ? rpc : functions, args);
8087
8096
  } catch (e) {
@@ -8199,9 +8208,17 @@ class NodeSnapshotEnvironment {
8199
8208
  }
8200
8209
  }
8201
8210
  class RstestSnapshotEnvironment extends NodeSnapshotEnvironment {
8211
+ resolveSnapshotPath;
8212
+ constructor(options){
8213
+ super();
8214
+ this.resolveSnapshotPath = options.resolveSnapshotPath;
8215
+ }
8202
8216
  getHeader() {
8203
8217
  return `// Rstest Snapshot v${this.getVersion()}`;
8204
8218
  }
8219
+ resolvePath(filepath) {
8220
+ return this.resolveSnapshotPath(filepath);
8221
+ }
8205
8222
  }
8206
8223
  let sourceMaps = {};
8207
8224
  (0, source_map_support.install)({
@@ -8225,6 +8242,7 @@ const setupEnv = (env)=>{
8225
8242
  const preparePool = async ({ entryInfo: { distPath, testPath }, updateSnapshot, context })=>{
8226
8243
  (0, util.zH)();
8227
8244
  context.runtimeConfig = (0, helper.gy)(context.runtimeConfig);
8245
+ process.env.RSTEST_WORKER_ID = String(process.__tinypool_state__.workerId || context.taskId);
8228
8246
  const cleanupFns = [];
8229
8247
  const { rpc } = createRuntimeRpc(createForksRpcOptions());
8230
8248
  const { runtimeConfig: { globals, printConsoleTrace, disableConsoleIntercept, testEnvironment, snapshotFormat, env } } = context;
@@ -8242,7 +8260,9 @@ const preparePool = async ({ entryInfo: { distPath, testPath }, updateSnapshot,
8242
8260
  ...context,
8243
8261
  snapshotOptions: {
8244
8262
  updateSnapshot,
8245
- snapshotEnvironment: new RstestSnapshotEnvironment(),
8263
+ snapshotEnvironment: new RstestSnapshotEnvironment({
8264
+ resolveSnapshotPath: (filepath)=>rpc.resolveSnapshotPath(filepath)
8265
+ }),
8246
8266
  snapshotFormat
8247
8267
  },
8248
8268
  distPath,
@@ -332,6 +332,7 @@ declare type CommonOptions = {
332
332
  retry?: number;
333
333
  maxConcurrency?: number;
334
334
  slowTestThreshold?: number;
335
+ hideSkippedTests?: boolean;
335
336
  };
336
337
 
337
338
  declare type CompareKeys = ((a: string, b: string) => number) | null | undefined;
@@ -1938,7 +1939,7 @@ declare type OnTestFinishedHandler = (params: {
1938
1939
  };
1939
1940
  }) => MaybePromise<void>;
1940
1941
 
1941
- declare type OptionalKeys = 'testNamePattern' | 'plugins' | 'source' | 'resolve' | 'output' | 'performance' | 'tools' | 'dev' | 'onConsoleLog';
1942
+ declare type OptionalKeys = 'testNamePattern' | 'plugins' | 'source' | 'resolve' | 'output' | 'performance' | 'tools' | 'dev' | 'onConsoleLog' | 'resolveSnapshotPath';
1942
1943
 
1943
1944
  declare type OptionsReceived = PrettyFormatOptions;
1944
1945
 
@@ -2226,6 +2227,12 @@ export declare interface RstestConfig {
2226
2227
  * @default ['default']
2227
2228
  */
2228
2229
  reporters?: Reporter | BuiltInReporterNames | (Reporter | BuiltInReporterNames | [BuiltInReporterNames] | ReporterWithOptions)[];
2230
+ /**
2231
+ * Hide skipped tests logs.
2232
+ *
2233
+ * @default false
2234
+ */
2235
+ hideSkippedTests?: boolean;
2229
2236
  /**
2230
2237
  * Run only tests with a name that matches the regex.
2231
2238
  */
@@ -2281,6 +2288,10 @@ export declare interface RstestConfig {
2281
2288
  onConsoleLog?: (content: string) => boolean | void;
2282
2289
  /** Format snapshot output */
2283
2290
  snapshotFormat?: SnapshotFormat;
2291
+ /**
2292
+ * Resolve custom snapshot path
2293
+ */
2294
+ resolveSnapshotPath?: (testPath: string, snapExtension: string) => string;
2284
2295
  /**
2285
2296
  * Custom environment variables available on `process.env` during tests.
2286
2297
  */