@rstest/core 0.7.2 → 0.7.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/131.js CHANGED
@@ -3,7 +3,10 @@ import 'module';
3
3
  import { __webpack_require__ } from "./rslib-runtime.js";
4
4
  import { EventEmitter } from "events";
5
5
  import { createRsbuild, loadConfig, logger as core_logger, mergeRsbuildConfig } from "@rsbuild/core";
6
- import { DEFAULT_CONFIG_NAME, posix, globalApis, resolve as pathe_M_eThtNZ_resolve, pathe_M_eThtNZ_relative, filterProjects, join, glob, prettyTestPath, prettyTime, isAbsolute, TEMP_RSTEST_OUTPUT_DIR_GLOB, formatTestPath, TS_CONFIG_FILE, basename, isTTY, dirname, getAbsolutePath, bgColor, formatRootStr, isDynamicPattern, writeFile, castArray, src_logger, isDebug, getTaskNameWithPrefix, DEFAULT_CONFIG_EXTENSIONS, formatError, normalize } from "./946.js";
6
+ import "./664.js";
7
+ import { basename, logger_logger, dirname, posix, resolve as pathe_M_eThtNZ_resolve, isDebug, isAbsolute, relative, join, normalize } from "./278.js";
8
+ import { isTTY, DEFAULT_CONFIG_NAME, globalApis, filterProjects, getAbsolutePath, bgColor, formatRootStr, isDynamicPattern, glob, writeFile, castArray, prettyTestPath, prettyTime, TEMP_RSTEST_OUTPUT_DIR_GLOB, getTaskNameWithPrefix, formatTestPath, formatError, DEFAULT_CONFIG_EXTENSIONS, TS_CONFIG_FILE } from "./157.js";
9
+ import { parse as stack_trace_parser_esm_parse } from "./672.js";
7
10
  import { decode } from "./397.js";
8
11
  function toArr(any) {
9
12
  return null == any ? [] : Array.isArray(any) ? any : [
@@ -497,16 +500,16 @@ function prepareCli() {
497
500
  initNodeEnv();
498
501
  process.env.RSTEST = 'true';
499
502
  const { npm_execpath } = process.env;
500
- if (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) console.log();
503
+ if (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) logger_logger.log();
501
504
  }
502
505
  function showRstest() {
503
- src_logger.greet(" Rstest v0.7.2");
504
- src_logger.log('');
506
+ logger_logger.greet(" Rstest v0.7.4");
507
+ logger_logger.log('');
505
508
  }
506
509
  const applyCommonOptions = (cli)=>{
507
510
  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`', {
508
511
  default: 'jiti'
509
- }).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('--logHeapUsage', 'Log heap usage after each test').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('--bail [number]', 'Stop running tests after n failures. Set to 0 to run all tests regardless of failures').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');
512
+ }).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('--logHeapUsage', 'Log heap usage after each test').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('--bail [number]', 'Stop running tests after n failures. Set to 0 to run all tests regardless of failures').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').option('--includeTaskLocation', 'Collect test and suite locations. This might increase the running time.');
510
513
  };
511
514
  const runRest = async ({ options, filters, command })=>{
512
515
  let rstest;
@@ -536,15 +539,15 @@ const runRest = async ({ options, filters, command })=>{
536
539
  await rstest.runTests();
537
540
  } catch (err) {
538
541
  for (const reporter of rstest?.context.reporters || [])reporter.onExit?.();
539
- src_logger.error('Failed to run Rstest.');
540
- src_logger.error(formatError(err));
542
+ logger_logger.error('Failed to run Rstest.');
543
+ logger_logger.error(formatError(err));
541
544
  process.exit(1);
542
545
  }
543
546
  };
544
547
  function setupCommands() {
545
548
  const cli = dist('rstest');
546
549
  cli.help();
547
- cli.version("0.7.2");
550
+ cli.version("0.7.4");
548
551
  applyCommonOptions(cli);
549
552
  cli.command('[...filters]', 'run tests').option('-w, --watch', 'Run tests in watch mode').action(async (filters, options)=>{
550
553
  showRstest();
@@ -575,12 +578,13 @@ function setupCommands() {
575
578
  command: 'watch'
576
579
  });
577
580
  });
578
- cli.command('list [...filters]', 'lists all test files that Rstest will run').option('--filesOnly', 'only list the test files').option('--json [boolean/path]', 'print tests as JSON or write to a file').action(async (filters, options)=>{
581
+ cli.command('list [...filters]', 'lists all test files that Rstest will run').option('--filesOnly', 'only list the test files').option('--json [boolean/path]', 'print tests as JSON or write to a file').option('--includeSuites', 'include suites in output').option('--printLocation', 'print test case location').action(async (filters, options)=>{
579
582
  try {
580
583
  const { initCli } = await Promise.resolve().then(()=>({
581
584
  initCli: init_initCli
582
585
  }));
583
586
  const { config, configFilePath, projects } = await initCli(options);
587
+ if (options.printLocation) config.includeTaskLocation = true;
584
588
  const { createRstest } = await Promise.resolve().then(()=>({
585
589
  createRstest: core_createRstest
586
590
  }));
@@ -591,17 +595,19 @@ function setupCommands() {
591
595
  }, 'list', filters.map(normalize));
592
596
  await rstest.listTests({
593
597
  filesOnly: options.filesOnly,
594
- json: options.json
598
+ json: options.json,
599
+ includeSuites: options.includeSuites,
600
+ printLocation: options.printLocation
595
601
  });
596
602
  } catch (err) {
597
- src_logger.error('Failed to run Rstest list.');
598
- src_logger.error(formatError(err));
603
+ logger_logger.error('Failed to run Rstest list.');
604
+ logger_logger.error(formatError(err));
599
605
  process.exit(1);
600
606
  }
601
607
  });
602
608
  cli.parse();
603
609
  }
604
- const external_node_fs_ = __webpack_require__("node:fs");
610
+ const external_node_fs_ = __webpack_require__("fs");
605
611
  const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
606
612
  var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
607
613
  const findConfig = (basePath)=>DEFAULT_CONFIG_EXTENSIONS.map((ext)=>basePath + ext).find(external_node_fs_["default"].existsSync);
@@ -618,7 +624,7 @@ const resolveConfigPath = (root, customConfig)=>{
618
624
  async function config_loadConfig({ cwd = process.cwd(), path, envMode, configLoader }) {
619
625
  const configFilePath = resolveConfigPath(cwd, path);
620
626
  if (!configFilePath) {
621
- src_logger.debug('no rstest config file found');
627
+ logger_logger.debug('no rstest config file found');
622
628
  return {
623
629
  content: {},
624
630
  filePath: configFilePath
@@ -635,6 +641,7 @@ async function config_loadConfig({ cwd = process.cwd(), path, envMode, configLoa
635
641
  filePath: configFilePath
636
642
  };
637
643
  }
644
+ const mergeProjectConfig = (...configs)=>mergeRstestConfig(...configs);
638
645
  const mergeRstestConfig = (...configs)=>configs.reduce((result, config)=>{
639
646
  const merged = mergeRsbuildConfig(result, {
640
647
  ...config,
@@ -666,6 +673,7 @@ const createDefaultConfig = ()=>({
666
673
  override: false
667
674
  },
668
675
  setupFiles: [],
676
+ globalSetup: [],
669
677
  includeSource: [],
670
678
  pool: {
671
679
  type: 'forks'
@@ -698,6 +706,7 @@ const createDefaultConfig = ()=>({
698
706
  hideSkippedTests: false,
699
707
  logHeapUsage: false,
700
708
  bail: 0,
709
+ includeTaskLocation: false,
701
710
  coverage: {
702
711
  exclude: [
703
712
  '**/node_modules/**',
@@ -728,6 +737,7 @@ const createDefaultConfig = ()=>({
728
737
  const withDefaultConfig = (config)=>{
729
738
  const merged = mergeRstestConfig(createDefaultConfig(), config);
730
739
  merged.setupFiles = castArray(merged.setupFiles);
740
+ merged.globalSetup = castArray(merged.globalSetup);
731
741
  merged.exclude.patterns.push(TEMP_RSTEST_OUTPUT_DIR_GLOB);
732
742
  const reportsDirectory = formatRootStr(merged.coverage.reportsDirectory, merged.root);
733
743
  merged.coverage.reportsDirectory = isAbsolute(reportsDirectory) ? reportsDirectory : pathe_M_eThtNZ_resolve(merged.root, reportsDirectory);
@@ -742,6 +752,7 @@ const withDefaultConfig = (config)=>{
742
752
  patterns: merged.exclude.patterns.map((p)=>formatRootStr(p, merged.root))
743
753
  },
744
754
  setupFiles: merged.setupFiles.map((p)=>formatRootStr(p, merged.root)),
755
+ globalSetup: merged.globalSetup.map((p)=>formatRootStr(p, merged.root)),
745
756
  includeSource: merged.includeSource.map((p)=>formatRootStr(p, merged.root))
746
757
  };
747
758
  };
@@ -909,8 +920,8 @@ async function runCLI() {
909
920
  try {
910
921
  setupCommands();
911
922
  } catch (err) {
912
- src_logger.error('Failed to start Rstest CLI.');
913
- src_logger.error(err);
923
+ logger_logger.error('Failed to start Rstest CLI.');
924
+ logger_logger.error(err);
914
925
  }
915
926
  }
916
927
  class SnapshotManager {
@@ -1293,94 +1304,6 @@ function G() {
1293
1304
  }
1294
1305
  const P = G();
1295
1306
  P?.name;
1296
- var UNKNOWN_FUNCTION = '<unknown>';
1297
- function stack_trace_parser_esm_parse(stackString) {
1298
- var lines = stackString.split('\n');
1299
- return lines.reduce(function(stack, line) {
1300
- var parseResult = parseChrome(line) || parseWinjs(line) || parseGecko(line) || parseNode(line) || parseJSC(line);
1301
- if (parseResult) stack.push(parseResult);
1302
- return stack;
1303
- }, []);
1304
- }
1305
- var chromeRe = /^\s*at (.*?) ?\(((?:file|https?|blob|chrome-extension|native|eval|webpack|rsc|<anonymous>|\/|[a-z]:\\|\\\\).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i;
1306
- var chromeEvalRe = /\((\S*)(?::(\d+))(?::(\d+))\)/;
1307
- function parseChrome(line) {
1308
- var parts = chromeRe.exec(line);
1309
- if (!parts) return null;
1310
- var isNative = parts[2] && 0 === parts[2].indexOf('native');
1311
- var isEval = parts[2] && 0 === parts[2].indexOf('eval');
1312
- var submatch = chromeEvalRe.exec(parts[2]);
1313
- if (isEval && null != submatch) {
1314
- parts[2] = submatch[1];
1315
- parts[3] = submatch[2];
1316
- parts[4] = submatch[3];
1317
- }
1318
- return {
1319
- file: isNative ? null : parts[2],
1320
- methodName: parts[1] || UNKNOWN_FUNCTION,
1321
- arguments: isNative ? [
1322
- parts[2]
1323
- ] : [],
1324
- lineNumber: parts[3] ? +parts[3] : null,
1325
- column: parts[4] ? +parts[4] : null
1326
- };
1327
- }
1328
- var winjsRe = /^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|rsc|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i;
1329
- function parseWinjs(line) {
1330
- var parts = winjsRe.exec(line);
1331
- if (!parts) return null;
1332
- return {
1333
- file: parts[2],
1334
- methodName: parts[1] || UNKNOWN_FUNCTION,
1335
- arguments: [],
1336
- lineNumber: +parts[3],
1337
- column: parts[4] ? +parts[4] : null
1338
- };
1339
- }
1340
- var geckoRe = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|webpack|rsc|resource|\[native).*?|[^@]*bundle)(?::(\d+))?(?::(\d+))?\s*$/i;
1341
- var geckoEvalRe = /(\S+) line (\d+)(?: > eval line \d+)* > eval/i;
1342
- function parseGecko(line) {
1343
- var parts = geckoRe.exec(line);
1344
- if (!parts) return null;
1345
- var isEval = parts[3] && parts[3].indexOf(' > eval') > -1;
1346
- var submatch = geckoEvalRe.exec(parts[3]);
1347
- if (isEval && null != submatch) {
1348
- parts[3] = submatch[1];
1349
- parts[4] = submatch[2];
1350
- parts[5] = null;
1351
- }
1352
- return {
1353
- file: parts[3],
1354
- methodName: parts[1] || UNKNOWN_FUNCTION,
1355
- arguments: parts[2] ? parts[2].split(',') : [],
1356
- lineNumber: parts[4] ? +parts[4] : null,
1357
- column: parts[5] ? +parts[5] : null
1358
- };
1359
- }
1360
- var javaScriptCoreRe = /^\s*(?:([^@]*)(?:\((.*?)\))?@)?(\S.*?):(\d+)(?::(\d+))?\s*$/i;
1361
- function parseJSC(line) {
1362
- var parts = javaScriptCoreRe.exec(line);
1363
- if (!parts) return null;
1364
- return {
1365
- file: parts[3],
1366
- methodName: parts[1] || UNKNOWN_FUNCTION,
1367
- arguments: [],
1368
- lineNumber: +parts[4],
1369
- column: parts[5] ? +parts[5] : null
1370
- };
1371
- }
1372
- var nodeRe = /^\s*at (?:((?:\[object object\])?[^\\/]+(?: \[as \S+\])?) )?\(?(.*?):(\d+)(?::(\d+))?\)?\s*$/i;
1373
- function parseNode(line) {
1374
- var parts = nodeRe.exec(line);
1375
- if (!parts) return null;
1376
- return {
1377
- file: parts[2],
1378
- methodName: parts[1] || UNKNOWN_FUNCTION,
1379
- arguments: [],
1380
- lineNumber: +parts[3],
1381
- column: parts[4] ? +parts[4] : null
1382
- };
1383
- }
1384
1307
  const getSummaryStatusString = (tasks, name = 'tests', showTotal = true)=>{
1385
1308
  if (0 === tasks.length) return picocolors_default().dim(`no ${name}`);
1386
1309
  const passed = tasks.filter((result)=>'pass' === result.status);
@@ -1417,33 +1340,40 @@ const printSnapshotSummaryLog = (snapshots, rootDir)=>{
1417
1340
  }
1418
1341
  for (const [index, snapshot] of summary.entries()){
1419
1342
  const title = 0 === index ? 'Snapshots' : '';
1420
- src_logger.log(`${picocolors_default().gray(title.padStart(12))} ${snapshot}`);
1343
+ logger_logger.log(`${picocolors_default().gray(title.padStart(12))} ${snapshot}`);
1421
1344
  }
1422
1345
  };
1423
1346
  const TestFileSummaryLabel = picocolors_default().gray('Test Files'.padStart(11));
1424
1347
  const TestSummaryLabel = picocolors_default().gray('Tests'.padStart(11));
1425
1348
  const DurationLabel = picocolors_default().gray('Duration'.padStart(11));
1426
1349
  const printSummaryLog = ({ results, testResults, snapshotSummary, duration, rootPath })=>{
1427
- src_logger.log('');
1350
+ logger_logger.log('');
1428
1351
  printSnapshotSummaryLog(snapshotSummary, rootPath);
1429
- src_logger.log(`${TestFileSummaryLabel} ${getSummaryStatusString(results)}`);
1430
- src_logger.log(`${TestSummaryLabel} ${getSummaryStatusString(testResults)}`);
1431
- src_logger.log(`${DurationLabel} ${prettyTime(duration.totalTime)} ${picocolors_default().gray(`(build ${prettyTime(duration.buildTime)}, tests ${prettyTime(duration.testTime)})`)}`);
1432
- src_logger.log('');
1352
+ logger_logger.log(`${TestFileSummaryLabel} ${getSummaryStatusString(results)}`);
1353
+ logger_logger.log(`${TestSummaryLabel} ${getSummaryStatusString(testResults)}`);
1354
+ logger_logger.log(`${DurationLabel} ${prettyTime(duration.totalTime)} ${picocolors_default().gray(`(build ${prettyTime(duration.buildTime)}, tests ${prettyTime(duration.testTime)})`)}`);
1355
+ logger_logger.log('');
1433
1356
  };
1434
- const printSummaryErrorLogs = async ({ testResults, results, rootPath, getSourcemap, filterRerunTestPaths })=>{
1357
+ const printSummaryErrorLogs = async ({ testResults, results, rootPath, unhandledErrors, getSourcemap, filterRerunTestPaths })=>{
1435
1358
  const failedTests = [
1436
1359
  ...results.filter((i)=>'fail' === i.status && i.errors?.length && (filterRerunTestPaths ? filterRerunTestPaths.includes(i.testPath) : true)),
1437
1360
  ...testResults.filter((i)=>'fail' === i.status && (filterRerunTestPaths ? filterRerunTestPaths.includes(i.testPath) : true))
1438
1361
  ];
1439
- if (0 === failedTests.length) return;
1440
- src_logger.log('');
1441
- src_logger.log(picocolors_default().bold('Summary of all failing tests:'));
1442
- src_logger.log('');
1362
+ if (0 === failedTests.length && !unhandledErrors?.length) return;
1363
+ logger_logger.stderr('');
1364
+ logger_logger.stderr(picocolors_default().bold('Summary of all failing tests:'));
1365
+ logger_logger.stderr('');
1366
+ const { printError } = await Promise.resolve().then(()=>({
1367
+ printError: error_printError
1368
+ }));
1369
+ for (const error of unhandledErrors || []){
1370
+ logger_logger.stderr(bgColor('bgRed', ' Unhandled Error '));
1371
+ await printError(error, getSourcemap, rootPath);
1372
+ }
1443
1373
  for (const test of failedTests){
1444
1374
  const relativePath = posix.relative(rootPath, test.testPath);
1445
1375
  const nameStr = getTaskNameWithPrefix(test);
1446
- src_logger.log(`${bgColor('bgRed', ' FAIL ')} ${prettyTestPath(relativePath)} ${nameStr.length ? `${picocolors_default().dim(">")} ${nameStr}` : ''}`);
1376
+ logger_logger.stderr(`${bgColor('bgRed', ' FAIL ')} ${prettyTestPath(relativePath)} ${nameStr.length ? `${picocolors_default().dim(">")} ${nameStr}` : ''}`);
1447
1377
  if (test.errors) {
1448
1378
  const { printError } = await Promise.resolve().then(()=>({
1449
1379
  printError: error_printError
@@ -1595,7 +1525,7 @@ class StatusRenderer {
1595
1525
  const testModules = this.testState.getTestModules();
1596
1526
  const shouldDisplayRunningTests = (runningTests)=>runningTests[0]?.startTime && now - runningTests[0].startTime > 2000;
1597
1527
  for (const [module, { runningTests }] of runningModules.entries()){
1598
- const relativePath = pathe_M_eThtNZ_relative(this.rootPath, module);
1528
+ const relativePath = relative(this.rootPath, module);
1599
1529
  summary.push(`${bgColor('bgYellow', ' RUNS ')} ${prettyTestPath(relativePath)}`);
1600
1530
  if (runningTests.length && shouldDisplayRunningTests(runningTests)) {
1601
1531
  let caseLog = ` ${picocolors_default().gray("➜")} ${getTaskNameWithPrefix(runningTests[0])} ${picocolors_default().magenta(prettyTime(now - runningTests[0].startTime))}`;
@@ -1646,8 +1576,8 @@ const logCase = (result, options)=>{
1646
1576
  const duration = void 0 !== result.duration ? ` (${prettyTime(result.duration)})` : '';
1647
1577
  const retry = result.retryCount ? picocolors_default().yellow(` (retry x${result.retryCount})`) : '';
1648
1578
  const heap = result.heap ? ` ${picocolors_default().magenta(formatHeapUsed(result.heap))}` : '';
1649
- src_logger.log(` ${icon} ${nameStr}${picocolors_default().gray(duration)}${retry}${heap}`);
1650
- if (result.errors) for (const error of result.errors)console.error(picocolors_default().red(` ${error.message}`));
1579
+ logger_logger.log(` ${icon} ${nameStr}${picocolors_default().gray(duration)}${retry}${heap}`);
1580
+ if (result.errors) for (const error of result.errors)logger_logger.log(picocolors_default().red(` ${error.message}`));
1651
1581
  };
1652
1582
  const formatHeapUsed = (heap)=>`${Math.floor(heap / 1024 / 1024)} MB heap used`;
1653
1583
  const logFileTitle = (test, relativePath, alwaysShowTime = false)=>{
@@ -1656,7 +1586,7 @@ const logFileTitle = (test, relativePath, alwaysShowTime = false)=>{
1656
1586
  title += ` ${picocolors_default().gray(`(${test.results.length})`)}`;
1657
1587
  if (alwaysShowTime) title += ` ${formatDuration(test.duration)}`;
1658
1588
  if (test.heap) title += ` ${picocolors_default().magenta(formatHeapUsed(test.heap))}`;
1659
- src_logger.log(title);
1589
+ logger_logger.log(title);
1660
1590
  };
1661
1591
  class DefaultReporter {
1662
1592
  rootPath;
@@ -1674,7 +1604,7 @@ class DefaultReporter {
1674
1604
  }
1675
1605
  onTestFileResult(test) {
1676
1606
  this.statusRenderer?.onTestFileResult();
1677
- const relativePath = pathe_M_eThtNZ_relative(this.rootPath, test.testPath);
1607
+ const relativePath = relative(this.rootPath, test.testPath);
1678
1608
  const { slowTestThreshold } = this.config;
1679
1609
  logFileTitle(test, relativePath);
1680
1610
  for (const result of test.results){
@@ -1692,27 +1622,29 @@ class DefaultReporter {
1692
1622
  const shouldLog = this.config.onConsoleLog?.(log.content) ?? true;
1693
1623
  if (!shouldLog) return;
1694
1624
  const titles = [];
1695
- const testPath = pathe_M_eThtNZ_relative(this.rootPath, log.testPath);
1625
+ const testPath = relative(this.rootPath, log.testPath);
1696
1626
  if (log.trace) {
1697
1627
  const [frame] = stack_trace_parser_esm_parse(log.trace);
1698
- const filePath = pathe_M_eThtNZ_relative(this.rootPath, frame.file || '');
1628
+ const filePath = relative(this.rootPath, frame.file || '');
1699
1629
  if (filePath !== testPath) titles.push(testPath);
1700
1630
  titles.push(`${filePath}:${frame.lineNumber}:${frame.column}`);
1701
1631
  } else titles.push(testPath);
1702
- src_logger.log('');
1703
- src_logger.log(`${log.name}${picocolors_default().gray(picocolors_default().dim(` | ${titles.join(picocolors_default().gray(picocolors_default().dim(' | ')))}`))}`);
1704
- src_logger.log(log.content);
1705
- src_logger.log('');
1632
+ const logOutput = 'stdout' === log.type ? logger_logger.log : logger_logger.stderr;
1633
+ logOutput('');
1634
+ logOutput(`${log.name}${picocolors_default().gray(picocolors_default().dim(` | ${titles.join(picocolors_default().gray(picocolors_default().dim(' | ')))}`))}`);
1635
+ logOutput(log.content);
1636
+ logOutput('');
1706
1637
  }
1707
1638
  async onExit() {
1708
1639
  this.statusRenderer?.clear();
1709
1640
  }
1710
- async onTestRunEnd({ results, testResults, duration, getSourcemap, snapshotSummary, filterRerunTestPaths }) {
1641
+ async onTestRunEnd({ results, testResults, duration, getSourcemap, snapshotSummary, filterRerunTestPaths, unhandledErrors }) {
1711
1642
  this.statusRenderer?.clear();
1712
1643
  if (false === this.options.summary) return;
1713
1644
  await printSummaryErrorLogs({
1714
1645
  testResults,
1715
1646
  results,
1647
+ unhandledErrors,
1716
1648
  rootPath: this.rootPath,
1717
1649
  getSourcemap,
1718
1650
  filterRerunTestPaths
@@ -1734,7 +1666,7 @@ class GithubActionsReporter {
1734
1666
  this.rootPath = rootPath;
1735
1667
  }
1736
1668
  log(message) {
1737
- console.log(`${message}\n`);
1669
+ logger_logger.log(`${message}\n`);
1738
1670
  }
1739
1671
  async onTestRunEnd({ results, testResults, getSourcemap }) {
1740
1672
  const failedTests = [
@@ -1749,7 +1681,7 @@ class GithubActionsReporter {
1749
1681
  for (const test of failedTests){
1750
1682
  const { testPath } = test;
1751
1683
  const nameStr = getTaskNameWithPrefix(test);
1752
- const shortPath = pathe_M_eThtNZ_relative(this.rootPath, testPath);
1684
+ const shortPath = relative(this.rootPath, testPath);
1753
1685
  const title = `${shortPath} > ${nameStr}`;
1754
1686
  for (const error of test.errors || []){
1755
1687
  let file = testPath;
@@ -2094,6 +2026,8 @@ function traceSegmentInternal(segments, memo, line, column, bias) {
2094
2026
  if (-1 === index || index === segments.length) return -1;
2095
2027
  return index;
2096
2028
  }
2029
+ const external_node_path_ = __webpack_require__("node:path");
2030
+ const isRelativePath = (p)=>/^\.\.?\//.test(p);
2097
2031
  const hintNotDefinedError = (message)=>{
2098
2032
  const [, varName] = message.match(/(\w+) is not defined/) || [];
2099
2033
  if (varName) {
@@ -2115,14 +2049,14 @@ async function error_printError(error, getSourcemap, rootPath) {
2115
2049
  ` - Update your code to use imports from "${picocolors_default().yellow('@rstest/core')}" instead of "${picocolors_default().yellow('vitest')}".`,
2116
2050
  ' - Enable `globals` configuration and use global API.'
2117
2051
  ];
2118
- src_logger.log(`${picocolors_default().red(tips.join('\n'))}\n`);
2052
+ logger_logger.stderr(`${picocolors_default().red(tips.join('\n'))}\n`);
2119
2053
  return;
2120
2054
  }
2121
2055
  if (error.message.includes('is not defined')) error.message = hintNotDefinedError(error.message);
2122
- src_logger.log(`${picocolors_default().red(picocolors_default().bold(errorName))}${picocolors_default().red(`: ${error.message}`)}\n`);
2056
+ logger_logger.stderr(`${picocolors_default().red(picocolors_default().bold(errorName))}${picocolors_default().red(`: ${error.message}`)}\n`);
2123
2057
  if (error.diff) {
2124
- src_logger.log(error.diff);
2125
- src_logger.log();
2058
+ logger_logger.stderr(error.diff);
2059
+ logger_logger.stderr('');
2126
2060
  }
2127
2061
  if (error.stack) {
2128
2062
  const stackFrames = await error_parseErrorStacktrace({
@@ -2130,7 +2064,7 @@ async function error_printError(error, getSourcemap, rootPath) {
2130
2064
  fullStack: error.fullStack,
2131
2065
  getSourcemap
2132
2066
  });
2133
- if (!stackFrames.length && !(error.fullStack || isDebug()) && !error.stack.endsWith(error.message)) src_logger.log(picocolors_default().gray("No error stack found, set 'DEBUG=rstest' to show fullStack."));
2067
+ if (!stackFrames.length && !(error.fullStack || isDebug()) && !error.stack.endsWith(error.message)) logger_logger.stderr(picocolors_default().gray("No error stack found, set 'DEBUG=rstest' to show fullStack."));
2134
2068
  if (stackFrames[0]) await printCodeFrame(stackFrames[0]);
2135
2069
  printStack(stackFrames, rootPath);
2136
2070
  }
@@ -2150,15 +2084,15 @@ async function printCodeFrame(frame) {
2150
2084
  highlightCode: true,
2151
2085
  linesBelow: 2
2152
2086
  });
2153
- src_logger.log(result);
2154
- src_logger.log('');
2087
+ logger_logger.stderr(result);
2088
+ logger_logger.stderr('');
2155
2089
  }
2156
2090
  function formatStack(frame, rootPath) {
2157
2091
  return '<unknown>' !== frame.methodName ? `at ${frame.methodName} (${formatTestPath(rootPath, frame.file)}:${frame.lineNumber}:${frame.column})` : `at ${formatTestPath(rootPath, frame.file)}:${frame.lineNumber}:${frame.column}`;
2158
2092
  }
2159
2093
  function printStack(stackFrames, rootPath) {
2160
- for (const frame of stackFrames)src_logger.log(picocolors_default().gray(` ${formatStack(frame, rootPath)}`));
2161
- stackFrames.length && src_logger.log();
2094
+ for (const frame of stackFrames)logger_logger.stderr(picocolors_default().gray(` ${formatStack(frame, rootPath)}`));
2095
+ stackFrames.length && logger_logger.stderr('');
2162
2096
  }
2163
2097
  const stackIgnores = [
2164
2098
  /\/@rstest\/core/,
@@ -2185,7 +2119,7 @@ async function error_parseErrorStacktrace({ stack, getSourcemap, fullStack = isD
2185
2119
  if (!source) return null;
2186
2120
  return {
2187
2121
  ...frame,
2188
- file: source,
2122
+ file: isRelativePath(source) ? (0, external_node_path_.resolve)(frame.file, '../', source) : new URL(source).pathname,
2189
2123
  lineNumber: line,
2190
2124
  name,
2191
2125
  column
@@ -2218,7 +2152,7 @@ class JUnitReporter {
2218
2152
  async createJUnitTestCase(test, getSourcemap) {
2219
2153
  const testCase = {
2220
2154
  name: getTaskNameWithPrefix(test),
2221
- classname: pathe_M_eThtNZ_relative(this.rootPath, test.testPath),
2155
+ classname: relative(this.rootPath, test.testPath),
2222
2156
  time: (test.duration || 0) / 1000,
2223
2157
  status: test.status
2224
2158
  };
@@ -2245,7 +2179,7 @@ class JUnitReporter {
2245
2179
  const skipped = testCases.filter((test)=>'skip' === test.status || 'todo' === test.status).length;
2246
2180
  const totalTime = testCases.reduce((sum, test)=>sum + test.time, 0);
2247
2181
  return {
2248
- name: pathe_M_eThtNZ_relative(this.rootPath, fileResult.testPath),
2182
+ name: relative(this.rootPath, fileResult.testPath),
2249
2183
  tests: testCases.length,
2250
2184
  failures,
2251
2185
  errors,
@@ -2305,19 +2239,19 @@ class JUnitReporter {
2305
2239
  const xmlContent = this.generateJUnitXml(report);
2306
2240
  if (this.outputPath) try {
2307
2241
  await writeFile(this.outputPath, xmlContent, 'utf-8');
2308
- console.log(`JUnit XML report written to: ${this.outputPath}`);
2242
+ logger_logger.log(`JUnit XML report written to: ${this.outputPath}`);
2309
2243
  } catch (error) {
2310
- console.error(`Failed to write JUnit XML report to ${this.outputPath}:`, error);
2311
- console.log('JUnit XML Report:');
2312
- console.log(xmlContent);
2244
+ logger_logger.stderr(`Failed to write JUnit XML report to ${this.outputPath}:`, error);
2245
+ logger_logger.log('JUnit XML Report:');
2246
+ logger_logger.log(xmlContent);
2313
2247
  }
2314
- else console.log(xmlContent);
2248
+ else logger_logger.log(xmlContent);
2315
2249
  }
2316
2250
  }
2317
2251
  class VerboseReporter extends DefaultReporter {
2318
2252
  onTestFileResult(test) {
2319
2253
  this.statusRenderer?.onTestFileResult();
2320
- const relativePath = pathe_M_eThtNZ_relative(this.rootPath, test.testPath);
2254
+ const relativePath = relative(this.rootPath, test.testPath);
2321
2255
  const { slowTestThreshold } = this.config;
2322
2256
  logFileTitle(test, relativePath, true);
2323
2257
  for (const result of test.results)logCase(result, {
@@ -2428,7 +2362,7 @@ class Rstest {
2428
2362
  });
2429
2363
  this.reporters = reporters;
2430
2364
  this.snapshotManager = snapshotManager;
2431
- this.version = "0.7.2";
2365
+ this.version = "0.7.4";
2432
2366
  this.rootPath = rootPath;
2433
2367
  this.originalConfig = userConfig;
2434
2368
  this.normalizedConfig = rstestConfig;
@@ -2448,6 +2382,7 @@ class Rstest {
2448
2382
  configFilePath: project.configFilePath,
2449
2383
  rootPath: config.root,
2450
2384
  name: config.name,
2385
+ _globalSetups: false,
2451
2386
  outputModule: config.output?.module ?? 'true' === process.env.RSTEST_OUTPUT_MODULE,
2452
2387
  environmentName: formatEnvironmentName(config.name),
2453
2388
  normalizedConfig: config
@@ -2456,6 +2391,7 @@ class Rstest {
2456
2391
  {
2457
2392
  configFilePath,
2458
2393
  rootPath,
2394
+ _globalSetups: false,
2459
2395
  name: rstestConfig.name,
2460
2396
  outputModule: rstestConfig.output?.module ?? 'true' === process.env.RSTEST_OUTPUT_MODULE,
2461
2397
  environmentName: formatEnvironmentName(rstestConfig.name),
@@ -2523,7 +2459,7 @@ function core_createRstest({ config, projects, configFilePath }, command, fileFi
2523
2459
  const { listTests } = await import("./0~634.js").then((mod)=>({
2524
2460
  listTests: mod.listTests
2525
2461
  }));
2526
- await listTests(context, options);
2462
+ return listTests(context, options);
2527
2463
  };
2528
2464
  return {
2529
2465
  context,
@@ -2571,4 +2507,4 @@ function defineConfig(config) {
2571
2507
  function defineProject(config) {
2572
2508
  return config;
2573
2509
  }
2574
- export { EventEmitter, afterAll, afterEach, assert, beforeAll, beforeEach, config_loadConfig as loadConfig, core_createRstest as createRstest, core_logger, createRsbuild, defineConfig, defineProject, describe, error_printError, expect, init_initCli as initCli, it, mergeRstestConfig, onTestFailed, onTestFinished, public_rstest as rstest, public_test as test, rs, runCLI, runRest };
2510
+ export { EventEmitter, afterAll, afterEach, assert, beforeAll, beforeEach, config_loadConfig as loadConfig, core_createRstest as createRstest, core_logger, createRsbuild, defineConfig, defineProject, describe, error_printError, expect, init_initCli as initCli, it, mergeProjectConfig, mergeRstestConfig, onTestFailed, onTestFinished, public_rstest as rstest, public_test as test, rs, runCLI, runRest };