@rstest/core 0.7.7 → 0.7.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.
Files changed (57) hide show
  1. package/LICENSE.md +294 -0
  2. package/dist/0~130.js +2 -2
  3. package/dist/0~1472.js +48 -0
  4. package/dist/0~1981.js +3 -0
  5. package/dist/0~2173.js +25 -10
  6. package/dist/0~2255.js +2 -2
  7. package/dist/0~3062.js +0 -5
  8. package/dist/0~3919.js +1 -1
  9. package/dist/0~4403.js +6 -5
  10. package/dist/0~4809.js +4 -4
  11. package/dist/0~5835.js +2 -2
  12. package/dist/0~62.js +3 -3
  13. package/dist/0~6588.js +3 -3
  14. package/dist/0~6923.js +2 -2
  15. package/dist/0~7583.js +9 -8
  16. package/dist/0~7882.js +1144 -0
  17. package/dist/0~8426.js +1 -2
  18. package/dist/0~89.js +33 -24
  19. package/dist/0~9348.js +953 -0
  20. package/dist/0~9634.js +58 -10
  21. package/dist/1157.js +13 -118
  22. package/dist/{7913.js → 1294.js} +51 -1745
  23. package/dist/2672.js +647 -0
  24. package/dist/3278.js +3 -450
  25. package/dist/4484.js +38 -0
  26. package/dist/487.js +1739 -0
  27. package/dist/4899.js +11 -0
  28. package/dist/5734.js +1 -1
  29. package/dist/{0~6151.js → 6151.js} +169 -21
  30. package/dist/{0~6973.js → 6973.js} +5 -5
  31. package/dist/721.js +9 -0
  32. package/dist/9131.js +559 -502
  33. package/dist/browser-runtime/2~907.js +1211 -0
  34. package/dist/browser-runtime/2~907.js.map +1 -0
  35. package/dist/browser-runtime/389.js +22071 -0
  36. package/dist/browser-runtime/389.js.LICENSE.txt +329 -0
  37. package/dist/browser-runtime/389.js.map +1 -0
  38. package/dist/browser-runtime/index.d.ts +2806 -0
  39. package/dist/browser-runtime/index.js +1 -0
  40. package/dist/browser-runtime/rslib-runtime.js +50 -0
  41. package/dist/browser-runtime/rslib-runtime.js.map +1 -0
  42. package/dist/browser.d.ts +3329 -0
  43. package/dist/browser.js +14 -0
  44. package/dist/cssFilterLoader.mjs +1 -1
  45. package/dist/globalSetupWorker.js +3 -2
  46. package/dist/index.d.ts +67 -2
  47. package/dist/index.js +2 -1
  48. package/dist/rslib-runtime.js +27 -0
  49. package/dist/rstestSuppressWarnings.cjs +9 -0
  50. package/dist/worker.d.ts +66 -2
  51. package/dist/worker.js +415 -1
  52. package/package.json +29 -14
  53. package/dist/0~8957.js +0 -149
  54. package/dist/554.js +0 -417
  55. package/dist/5693.js +0 -91
  56. /package/dist/{7913.js.LICENSE.txt → 1294.js.LICENSE.txt} +0 -0
  57. /package/dist/{0~6151.js.LICENSE.txt → 6151.js.LICENSE.txt} +0 -0
package/dist/9131.js CHANGED
@@ -2,10 +2,11 @@ import 'module';
2
2
  /*#__PURE__*/ import.meta.url;
3
3
  import { __webpack_require__ } from "./rslib-runtime.js";
4
4
  import { EventEmitter } from "events";
5
- import { createRsbuild, loadConfig, logger as core_logger, mergeRsbuildConfig, rspack } from "@rsbuild/core";
6
- import "./5693.js";
7
- import { basename, logger_logger, dirname, posix, resolve as pathe_M_eThtNZ_resolve, isDebug, isAbsolute, relative, join, normalize } from "./3278.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 "./1157.js";
5
+ import { basename, isTTY, dirname, resolve as pathe_M_eThtNZ_resolve, relative, getAbsolutePath, join, bgColor, formatRootStr, castArray, prettyTime, getTaskNameWithPrefix, isAbsolute, formatError, normalize } from "./2672.js";
6
+ import "./721.js";
7
+ import { isDynamicPattern, glob, DEFAULT_CONFIG_NAME, prettyTestPath, globalApis, TEMP_RSTEST_OUTPUT_DIR_GLOB, formatTestPath, filterProjects, DEFAULT_CONFIG_EXTENSIONS, TS_CONFIG_FILE } from "./1157.js";
8
+ import { posix, logger as logger_logger, isDebug } from "./3278.js";
9
+ import { rsbuild as __rspack_external__rsbuild_core_1b356efc } from "./4484.js";
9
10
  import { parse as stack_trace_parser_esm_parse } from "./1672.js";
10
11
  import { decode } from "./4397.js";
11
12
  function toArr(any) {
@@ -503,16 +504,25 @@ function prepareCli() {
503
504
  if (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) logger_logger.log();
504
505
  }
505
506
  function showRstest() {
506
- logger_logger.greet(" Rstest v0.7.7");
507
+ logger_logger.greet(" Rstest v0.7.9");
507
508
  logger_logger.log('');
508
509
  }
509
510
  const applyCommonOptions = (cli)=>{
510
511
  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`', {
511
512
  default: 'jiti'
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.');
513
+ }).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('--browser', 'Run tests in browser mode (Chromium)').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.');
514
+ };
515
+ const handleUnexpectedExit = (rstest, err)=>{
516
+ for (const reporter of rstest?.context.reporters || [])reporter.onExit?.();
517
+ logger_logger.error('Failed to run Rstest.');
518
+ logger_logger.error(formatError(err));
519
+ process.exit(1);
513
520
  };
514
521
  const runRest = async ({ options, filters, command })=>{
515
522
  let rstest;
523
+ const unexpectedlyExitHandler = (err)=>{
524
+ handleUnexpectedExit(rstest, err);
525
+ };
516
526
  try {
517
527
  const { initCli } = await Promise.resolve().then(()=>({
518
528
  initCli: init_initCli
@@ -526,10 +536,17 @@ const runRest = async ({ options, filters, command })=>{
526
536
  configFilePath,
527
537
  projects
528
538
  }, command, filters.map(normalize));
529
- if ('watch' === command && configFilePath) {
530
- const { watchFilesForRestart } = await import("./0~6588.js").then((mod)=>({
531
- watchFilesForRestart: mod.watchFilesForRestart
539
+ process.on('uncaughtException', unexpectedlyExitHandler);
540
+ process.on('unhandledRejection', unexpectedlyExitHandler);
541
+ if ('watch' === command) {
542
+ const { watchFilesForRestart, onBeforeRestart } = await import("./0~6588.js").then((mod)=>({
543
+ watchFilesForRestart: mod.watchFilesForRestart,
544
+ onBeforeRestart: mod.onBeforeRestart
532
545
  }));
546
+ onBeforeRestart(()=>{
547
+ process.off('uncaughtException', unexpectedlyExitHandler);
548
+ process.off('unhandledRejection', unexpectedlyExitHandler);
549
+ });
533
550
  watchFilesForRestart({
534
551
  rstest,
535
552
  options,
@@ -538,16 +555,13 @@ const runRest = async ({ options, filters, command })=>{
538
555
  }
539
556
  await rstest.runTests();
540
557
  } catch (err) {
541
- for (const reporter of rstest?.context.reporters || [])reporter.onExit?.();
542
- logger_logger.error('Failed to run Rstest.');
543
- logger_logger.error(formatError(err));
544
- process.exit(1);
558
+ handleUnexpectedExit(rstest, err);
545
559
  }
546
560
  };
547
561
  function setupCommands() {
548
562
  const cli = dist('rstest');
549
563
  cli.help();
550
- cli.version("0.7.7");
564
+ cli.version("0.7.9");
551
565
  applyCommonOptions(cli);
552
566
  cli.command('[...filters]', 'run tests').option('-w, --watch', 'Run tests in watch mode').action(async (filters, options)=>{
553
567
  showRstest();
@@ -593,403 +607,62 @@ function setupCommands() {
593
607
  configFilePath,
594
608
  projects
595
609
  }, 'list', filters.map(normalize));
596
- await rstest.listTests({
597
- filesOnly: options.filesOnly,
598
- json: options.json,
599
- includeSuites: options.includeSuites,
600
- printLocation: options.printLocation
601
- });
602
- } catch (err) {
603
- logger_logger.error('Failed to run Rstest list.');
604
- logger_logger.error(formatError(err));
605
- process.exit(1);
606
- }
607
- });
608
- cli.parse();
609
- }
610
- const external_node_fs_ = __webpack_require__("node:fs");
611
- const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
612
- var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
613
- const findConfig = (basePath)=>DEFAULT_CONFIG_EXTENSIONS.map((ext)=>basePath + ext).find(external_node_fs_["default"].existsSync);
614
- const resolveConfigPath = (root, customConfig)=>{
615
- if (customConfig) {
616
- const customConfigPath = isAbsolute(customConfig) ? customConfig : join(root, customConfig);
617
- if (external_node_fs_["default"].existsSync(customConfigPath)) return customConfigPath;
618
- throw `Cannot find config file: ${picocolors_default().dim(customConfigPath)}`;
619
- }
620
- const configFilePath = findConfig(join(root, DEFAULT_CONFIG_NAME));
621
- if (configFilePath) return configFilePath;
622
- return null;
623
- };
624
- async function config_loadConfig({ cwd = process.cwd(), path, envMode, configLoader }) {
625
- const configFilePath = resolveConfigPath(cwd, path);
626
- if (!configFilePath) {
627
- logger_logger.debug('no rstest config file found');
628
- return {
629
- content: {},
630
- filePath: configFilePath
631
- };
632
- }
633
- const { content } = await loadConfig({
634
- cwd: dirname(configFilePath),
635
- path: configFilePath,
636
- envMode,
637
- loader: configLoader
638
- });
639
- let config = content;
640
- if (config.extends) {
641
- const extendsConfig = 'function' == typeof config.extends ? await config.extends(Object.freeze({
642
- ...config
643
- })) : config.extends;
644
- delete extendsConfig.projects;
645
- config = mergeRstestConfig(extendsConfig, config);
646
- }
647
- return {
648
- content: config,
649
- filePath: configFilePath
650
- };
651
- }
652
- const mergeProjectConfig = (...configs)=>mergeRstestConfig(...configs);
653
- const mergeRstestConfig = (...configs)=>configs.reduce((result, config)=>{
654
- const merged = mergeRsbuildConfig(result, {
655
- ...config,
656
- exclude: Array.isArray(config.exclude) ? {
657
- patterns: config.exclude,
658
- override: false
659
- } : config.exclude
660
- });
661
- if (!Array.isArray(config.exclude) && config.exclude?.override) merged.exclude = {
662
- patterns: config.exclude.patterns
663
- };
664
- merged.include = config.include ?? merged.include;
665
- merged.reporters = config.reporters ?? merged.reporters;
666
- if (merged.coverage) merged.coverage.reporters = config.coverage?.reporters ?? merged.coverage?.reporters;
667
- return merged;
668
- }, {});
669
- const createDefaultConfig = ()=>({
670
- root: process.cwd(),
671
- name: 'rstest',
672
- include: [
673
- '**/*.{test,spec}.?(c|m)[jt]s?(x)'
674
- ],
675
- exclude: {
676
- patterns: [
677
- '**/node_modules/**',
678
- '**/dist/**',
679
- '**/.{idea,git,cache,output,temp}/**'
680
- ],
681
- override: false
682
- },
683
- setupFiles: [],
684
- globalSetup: [],
685
- includeSource: [],
686
- pool: {
687
- type: 'forks'
688
- },
689
- isolate: true,
690
- globals: false,
691
- passWithNoTests: false,
692
- update: false,
693
- testTimeout: 5000,
694
- hookTimeout: 10000,
695
- testEnvironment: 'node',
696
- retry: 0,
697
- reporters: 'true' === process.env.GITHUB_ACTIONS ? [
698
- 'default',
699
- 'github-actions'
700
- ] : [
701
- 'default'
702
- ],
703
- clearMocks: false,
704
- resetMocks: false,
705
- restoreMocks: false,
706
- slowTestThreshold: 300,
707
- unstubGlobals: false,
708
- unstubEnvs: false,
709
- maxConcurrency: 5,
710
- printConsoleTrace: false,
711
- disableConsoleIntercept: false,
712
- snapshotFormat: {},
713
- env: {},
714
- hideSkippedTests: false,
715
- logHeapUsage: false,
716
- bail: 0,
717
- includeTaskLocation: false,
718
- coverage: {
719
- exclude: [
720
- '**/node_modules/**',
721
- '**/[.]*',
722
- '**/dist/**',
723
- '**/test/**',
724
- '**/__tests__/**',
725
- '**/__mocks__/**',
726
- '**/*.d.ts',
727
- '**/*.{test,spec}.[jt]s',
728
- '**/*.{test,spec}.[cm][jt]s',
729
- '**/*.{test,spec}.[jt]sx',
730
- '**/*.{test,spec}.[cm][jt]sx'
731
- ],
732
- enabled: false,
733
- provider: 'istanbul',
734
- reporters: [
735
- 'text',
736
- 'html',
737
- 'clover',
738
- 'json'
739
- ],
740
- reportsDirectory: './coverage',
741
- clean: true,
742
- reportOnFailure: false
743
- }
744
- });
745
- const withDefaultConfig = (config)=>{
746
- const merged = mergeRstestConfig(createDefaultConfig(), config);
747
- merged.setupFiles = castArray(merged.setupFiles);
748
- merged.globalSetup = castArray(merged.globalSetup);
749
- merged.exclude.patterns.push(TEMP_RSTEST_OUTPUT_DIR_GLOB);
750
- const reportsDirectory = formatRootStr(merged.coverage.reportsDirectory, merged.root);
751
- merged.coverage.reportsDirectory = isAbsolute(reportsDirectory) ? reportsDirectory : pathe_M_eThtNZ_resolve(merged.root, reportsDirectory);
752
- merged.pool = 'string' == typeof config.pool ? {
753
- type: config.pool
754
- } : merged.pool;
755
- return {
756
- ...merged,
757
- include: merged.include.map((p)=>formatRootStr(p, merged.root)),
758
- exclude: {
759
- ...merged.exclude,
760
- patterns: merged.exclude.patterns.map((p)=>formatRootStr(p, merged.root))
761
- },
762
- setupFiles: merged.setupFiles.map((p)=>formatRootStr(p, merged.root)),
763
- globalSetup: merged.globalSetup.map((p)=>formatRootStr(p, merged.root)),
764
- includeSource: merged.includeSource.map((p)=>formatRootStr(p, merged.root))
765
- };
766
- };
767
- function mergeWithCLIOptions(config, options) {
768
- const keys = [
769
- 'root',
770
- 'globals',
771
- 'isolate',
772
- 'passWithNoTests',
773
- 'update',
774
- 'testNamePattern',
775
- 'testTimeout',
776
- 'hookTimeout',
777
- 'clearMocks',
778
- 'resetMocks',
779
- 'restoreMocks',
780
- 'unstubEnvs',
781
- 'unstubGlobals',
782
- 'retry',
783
- 'slowTestThreshold',
784
- 'maxConcurrency',
785
- 'printConsoleTrace',
786
- 'disableConsoleIntercept',
787
- 'testEnvironment',
788
- 'hideSkippedTests',
789
- 'logHeapUsage'
790
- ];
791
- for (const key of keys)if (void 0 !== options[key]) config[key] = options[key];
792
- if (options.reporter) config.reporters = castArray(options.reporter);
793
- if (void 0 !== options.bail && ('number' == typeof options.bail || 'boolean' == typeof options.bail)) config.bail = Number(options.bail);
794
- if (void 0 !== options.coverage) {
795
- config.coverage ??= {};
796
- config.coverage.enabled = options.coverage;
797
- }
798
- if (options.exclude) config.exclude = castArray(options.exclude);
799
- if (options.include) config.include = castArray(options.include);
800
- return config;
801
- }
802
- async function resolveConfig(options) {
803
- const { content: config, filePath: configFilePath } = await config_loadConfig({
804
- cwd: options.cwd,
805
- path: options.config,
806
- configLoader: options.configLoader
807
- });
808
- const mergedConfig = mergeWithCLIOptions(config, options);
809
- if (!mergedConfig.root) mergedConfig.root = options.cwd;
810
- return {
811
- config: mergedConfig,
812
- configFilePath: configFilePath ?? void 0
813
- };
814
- }
815
- async function resolveProjects({ config, root, options }) {
816
- if (!config.projects) return [];
817
- const getDefaultProjectName = (dir)=>{
818
- const pkgJsonPath = pathe_M_eThtNZ_resolve(dir, 'package.json');
819
- const name = (0, external_node_fs_.existsSync)(pkgJsonPath) ? JSON.parse((0, external_node_fs_.readFileSync)(pkgJsonPath, 'utf-8')).name : '';
820
- if ('string' != typeof name || !name) return basename(dir);
821
- return name;
822
- };
823
- const globProjects = async (patterns, root)=>{
824
- const globOptions = {
825
- absolute: true,
826
- dot: true,
827
- onlyFiles: false,
828
- cwd: root,
829
- expandDirectories: false,
830
- ignore: [
831
- '**/node_modules/**',
832
- '**/.DS_Store'
833
- ]
834
- };
835
- return glob(patterns, globOptions);
836
- };
837
- const resolvedProjectPaths = new Set();
838
- const getProjects = async (rstestConfig, root)=>{
839
- const { projectPaths, projectPatterns, projectConfigs } = (rstestConfig.projects || []).reduce((total, p)=>{
840
- if ('object' == typeof p) {
841
- const projectRoot = p.root ? formatRootStr(p.root, root) : root;
842
- total.projectConfigs.push({
843
- config: mergeWithCLIOptions({
844
- root: projectRoot,
845
- ...p,
846
- name: p.name ? p.name : getDefaultProjectName(projectRoot)
847
- }, options),
848
- configFilePath: void 0
849
- });
850
- return total;
851
- }
852
- const projectStr = formatRootStr(p, root);
853
- if (isDynamicPattern(projectStr)) total.projectPatterns.push(projectStr);
854
- else {
855
- const absolutePath = getAbsolutePath(root, projectStr);
856
- if (!(0, external_node_fs_.existsSync)(absolutePath)) throw `Can't resolve project "${p}", please make sure "${p}" is a existing file or a directory.`;
857
- total.projectPaths.push(absolutePath);
858
- }
859
- return total;
860
- }, {
861
- projectPaths: [],
862
- projectPatterns: [],
863
- projectConfigs: []
864
- });
865
- projectPaths.push(...await globProjects(projectPatterns, root));
866
- const projects = [];
867
- await Promise.all(projectPaths.map(async (project)=>{
868
- const isDirectory = (0, external_node_fs_.statSync)(project).isDirectory();
869
- const projectRoot = isDirectory ? project : dirname(project);
870
- const { config, configFilePath } = await resolveConfig({
871
- ...options,
872
- config: isDirectory ? void 0 : project,
873
- cwd: projectRoot
874
- });
875
- if (configFilePath) {
876
- if (resolvedProjectPaths.has(configFilePath)) return;
877
- resolvedProjectPaths.add(configFilePath);
878
- }
879
- config.name ??= getDefaultProjectName(projectRoot);
880
- if (config.projects?.length) {
881
- const childProjects = await getProjects(config, projectRoot);
882
- projects.push(...childProjects);
883
- } else projects.push({
884
- config,
885
- configFilePath
886
- });
887
- }));
888
- return projects.concat(projectConfigs);
889
- };
890
- const projects = await getProjects(config, root).then((p)=>filterProjects(p, options));
891
- if (!projects.length) {
892
- let errorMsg = `No projects found, please make sure you have at least one valid project.
893
- ${picocolors_default().gray('projects:')} ${JSON.stringify(config.projects, null, 2)}`;
894
- if (options.project) errorMsg += `\n${picocolors_default().gray('projectName filter:')} ${JSON.stringify(options.project, null, 2)}`;
895
- throw errorMsg;
896
- }
897
- const names = new Set();
898
- projects.forEach((project)=>{
899
- if (names.has(project.config.name)) {
900
- const conflictProjects = projects.filter((p)=>p.config.name === project.config.name);
901
- throw `Project name "${project.config.name}" is already used. Please ensure all projects have unique names.
902
- Conflicting projects:
903
- ${conflictProjects.map((p)=>`- ${p.configFilePath || p.config.root}`).join('\n')}
904
- `;
905
- }
906
- names.add(project.config.name);
907
- });
908
- return projects;
909
- }
910
- async function init_initCli(options) {
911
- const cwd = process.cwd();
912
- const root = options.root ? getAbsolutePath(cwd, options.root) : cwd;
913
- const { config, configFilePath } = await resolveConfig({
914
- ...options,
915
- cwd: options.root ? getAbsolutePath(cwd, options.root) : cwd
916
- });
917
- const projects = await resolveProjects({
918
- config,
919
- root,
920
- options
921
- });
922
- return {
923
- config,
924
- configFilePath,
925
- projects
926
- };
927
- }
928
- async function runCLI() {
929
- prepareCli();
930
- try {
931
- setupCommands();
932
- } catch (err) {
933
- logger_logger.error('Failed to start Rstest CLI.');
934
- logger_logger.error(err);
935
- }
936
- }
937
- class SnapshotManager {
938
- summary;
939
- extension = ".snap";
940
- constructor(options){
941
- this.options = options;
942
- this.clear();
943
- }
944
- clear() {
945
- this.summary = emptySummary(this.options);
946
- }
947
- add(result) {
948
- addSnapshotResult(this.summary, result);
949
- }
950
- resolvePath(testPath, context) {
951
- const resolver = this.options.resolveSnapshotPath || (()=>join(join(dirname(testPath), "__snapshots__"), `${basename(testPath)}${this.extension}`));
952
- const path = resolver(testPath, this.extension, context);
953
- return path;
954
- }
955
- resolveRawPath(testPath, rawPath) {
956
- return isAbsolute(rawPath) ? rawPath : pathe_M_eThtNZ_resolve(dirname(testPath), rawPath);
957
- }
958
- }
959
- function emptySummary(options) {
960
- const summary = {
961
- added: 0,
962
- failure: false,
963
- filesAdded: 0,
964
- filesRemoved: 0,
965
- filesRemovedList: [],
966
- filesUnmatched: 0,
967
- filesUpdated: 0,
968
- matched: 0,
969
- total: 0,
970
- unchecked: 0,
971
- uncheckedKeysByFile: [],
972
- unmatched: 0,
973
- updated: 0,
974
- didUpdate: "all" === options.updateSnapshot
975
- };
976
- return summary;
977
- }
978
- function addSnapshotResult(summary, result) {
979
- if (result.added) summary.filesAdded++;
980
- if (result.fileDeleted) summary.filesRemoved++;
981
- if (result.unmatched) summary.filesUnmatched++;
982
- if (result.updated) summary.filesUpdated++;
983
- summary.added += result.added;
984
- summary.matched += result.matched;
985
- summary.unchecked += result.unchecked;
986
- if (result.uncheckedKeys && result.uncheckedKeys.length > 0) summary.uncheckedKeysByFile.push({
987
- filePath: result.filepath,
988
- keys: result.uncheckedKeys
610
+ await rstest.listTests({
611
+ filesOnly: options.filesOnly,
612
+ json: options.json,
613
+ includeSuites: options.includeSuites,
614
+ printLocation: options.printLocation
615
+ });
616
+ } catch (err) {
617
+ logger_logger.error('Failed to run Rstest list.');
618
+ logger_logger.error(formatError(err));
619
+ process.exit(1);
620
+ }
989
621
  });
990
- summary.unmatched += result.unmatched;
991
- summary.updated += result.updated;
992
- summary.total += result.added + result.matched + result.unmatched + result.updated;
622
+ cli.command('init [project]', 'Initialize rstest configuration').option('--yes', 'Use default options (non-interactive)').action(async (project, options)=>{
623
+ try {
624
+ let selectedProject = project;
625
+ if (!selectedProject) {
626
+ const { select, isCancel } = await import("./0~9348.js").then((mod)=>({
627
+ select: mod.ve,
628
+ isCancel: mod.pD
629
+ }));
630
+ const color = (await import("./2672.js").then(__webpack_require__.t.bind(__webpack_require__, "../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js", 23))).default;
631
+ console.log();
632
+ const selected = await select({
633
+ message: 'What would you like to initialize?',
634
+ options: [
635
+ {
636
+ value: 'browser',
637
+ label: 'browser',
638
+ hint: 'Browser mode for component testing'
639
+ }
640
+ ]
641
+ });
642
+ if (isCancel(selected)) {
643
+ console.log(color.yellow('Operation cancelled.'));
644
+ process.exit(0);
645
+ }
646
+ selectedProject = selected;
647
+ }
648
+ if ('browser' === selectedProject) {
649
+ const { create } = await import("./0~7882.js").then((mod)=>({
650
+ create: mod.create
651
+ }));
652
+ await create({
653
+ yes: options.yes
654
+ });
655
+ } else {
656
+ logger_logger.error(`Unknown project type: "${selectedProject}". Available: browser`);
657
+ process.exit(1);
658
+ }
659
+ } catch (err) {
660
+ logger_logger.error('Failed to initialize rstest.');
661
+ logger_logger.error(formatError(err));
662
+ process.exit(1);
663
+ }
664
+ });
665
+ cli.parse();
993
666
  }
994
667
  const dist_r = Object.create(null), dist_i = (e)=>globalThis.process?.env || {
995
668
  MODE: "production",
@@ -1255,65 +928,482 @@ function dist_b() {
1255
928
  ...e[2]
1256
929
  };
1257
930
  }
1258
- return globalThis.process?.env?.SHELL === "/bin/jsh" && globalThis.process?.versions?.webcontainer ? {
1259
- name: "stackblitz",
1260
- ci: !1
1261
- } : {
1262
- name: "",
1263
- ci: !1
931
+ return globalThis.process?.env?.SHELL === "/bin/jsh" && globalThis.process?.versions?.webcontainer ? {
932
+ name: "stackblitz",
933
+ ci: !1
934
+ } : {
935
+ name: "",
936
+ ci: !1
937
+ };
938
+ }
939
+ const l = dist_b();
940
+ l.name;
941
+ function n(e) {
942
+ return e ? "false" !== e : !1;
943
+ }
944
+ const I = globalThis.process?.platform || "", T = n(dist_o.CI) || !1 !== l.ci, R = n(globalThis.process?.stdout && globalThis.process?.stdout.isTTY), A = (n(dist_o.DEBUG), "test" === dist_t || n(dist_o.TEST), n(dist_o.MINIMAL), /^win/i.test(I)), C = (/^linux/i.test(I), /^darwin/i.test(I), !n(dist_o.NO_COLOR) && (n(dist_o.FORCE_COLOR) || (R || A) && dist_o.TERM), (globalThis.process?.versions?.node || "").replace(/^v/, "") || null), W = (Number(C?.split(".")[0]), globalThis.process || Object.create(null)), dist_ = {
945
+ versions: {}
946
+ }, O = (new Proxy(W, {
947
+ get (e, s) {
948
+ if ("env" === s) return dist_o;
949
+ if (s in e) return e[s];
950
+ if (s in dist_) return dist_[s];
951
+ }
952
+ }), globalThis.process?.release?.name === "node"), c = !!globalThis.Bun || !!globalThis.process?.versions?.bun, D = !!globalThis.Deno, L = !!globalThis.fastly, S = !!globalThis.Netlify, u = !!globalThis.EdgeRuntime, N = globalThis.navigator?.userAgent === "Cloudflare-Workers", F = [
953
+ [
954
+ S,
955
+ "netlify"
956
+ ],
957
+ [
958
+ u,
959
+ "edge-light"
960
+ ],
961
+ [
962
+ N,
963
+ "workerd"
964
+ ],
965
+ [
966
+ L,
967
+ "fastly"
968
+ ],
969
+ [
970
+ D,
971
+ "deno"
972
+ ],
973
+ [
974
+ c,
975
+ "bun"
976
+ ],
977
+ [
978
+ O,
979
+ "node"
980
+ ]
981
+ ];
982
+ function G() {
983
+ const e = F.find((s)=>s[0]);
984
+ if (e) return {
985
+ name: e[1]
986
+ };
987
+ }
988
+ const P = G();
989
+ P?.name;
990
+ const external_node_fs_ = __webpack_require__("fs");
991
+ const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
992
+ var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
993
+ const findConfig = (basePath)=>DEFAULT_CONFIG_EXTENSIONS.map((ext)=>basePath + ext).find(external_node_fs_["default"].existsSync);
994
+ const resolveConfigPath = (root, customConfig)=>{
995
+ if (customConfig) {
996
+ const customConfigPath = isAbsolute(customConfig) ? customConfig : join(root, customConfig);
997
+ if (external_node_fs_["default"].existsSync(customConfigPath)) return customConfigPath;
998
+ throw `Cannot find config file: ${picocolors_default().dim(customConfigPath)}`;
999
+ }
1000
+ const configFilePath = findConfig(join(root, DEFAULT_CONFIG_NAME));
1001
+ if (configFilePath) return configFilePath;
1002
+ return null;
1003
+ };
1004
+ async function loadConfig({ cwd = process.cwd(), path, envMode, configLoader }) {
1005
+ const configFilePath = resolveConfigPath(cwd, path);
1006
+ if (!configFilePath) {
1007
+ logger_logger.debug('no rstest config file found');
1008
+ return {
1009
+ content: {},
1010
+ filePath: configFilePath
1011
+ };
1012
+ }
1013
+ const { content } = await (0, __rspack_external__rsbuild_core_1b356efc.loadConfig)({
1014
+ cwd: dirname(configFilePath),
1015
+ path: configFilePath,
1016
+ envMode,
1017
+ loader: configLoader
1018
+ });
1019
+ let config = content;
1020
+ if (config.extends) {
1021
+ const extendsConfig = 'function' == typeof config.extends ? await config.extends(Object.freeze({
1022
+ ...config
1023
+ })) : config.extends;
1024
+ delete extendsConfig.projects;
1025
+ config = mergeRstestConfig(extendsConfig, config);
1026
+ }
1027
+ return {
1028
+ content: config,
1029
+ filePath: configFilePath
1030
+ };
1031
+ }
1032
+ const mergeProjectConfig = (...configs)=>mergeRstestConfig(...configs);
1033
+ const mergeRstestConfig = (...configs)=>configs.reduce((result, config)=>{
1034
+ const merged = (0, __rspack_external__rsbuild_core_1b356efc.mergeRsbuildConfig)(result, {
1035
+ ...config,
1036
+ exclude: Array.isArray(config.exclude) ? {
1037
+ patterns: config.exclude,
1038
+ override: false
1039
+ } : config.exclude
1040
+ });
1041
+ if (!Array.isArray(config.exclude) && config.exclude?.override) merged.exclude = {
1042
+ patterns: config.exclude.patterns
1043
+ };
1044
+ if (config.browser) merged.browser = {
1045
+ ...merged.browser || {},
1046
+ ...config.browser
1047
+ };
1048
+ merged.include = config.include ?? merged.include;
1049
+ merged.reporters = config.reporters ?? merged.reporters;
1050
+ if (merged.coverage) merged.coverage.reporters = config.coverage?.reporters ?? merged.coverage?.reporters;
1051
+ return merged;
1052
+ }, {});
1053
+ const createDefaultConfig = ()=>({
1054
+ root: process.cwd(),
1055
+ name: 'rstest',
1056
+ include: [
1057
+ '**/*.{test,spec}.?(c|m)[jt]s?(x)'
1058
+ ],
1059
+ exclude: {
1060
+ patterns: [
1061
+ '**/node_modules/**',
1062
+ '**/dist/**',
1063
+ '**/.{idea,git,cache,output,temp}/**'
1064
+ ],
1065
+ override: false
1066
+ },
1067
+ setupFiles: [],
1068
+ globalSetup: [],
1069
+ includeSource: [],
1070
+ pool: {
1071
+ type: 'forks'
1072
+ },
1073
+ isolate: true,
1074
+ globals: false,
1075
+ passWithNoTests: false,
1076
+ update: false,
1077
+ testTimeout: 5000,
1078
+ hookTimeout: 10000,
1079
+ testEnvironment: {
1080
+ name: 'node'
1081
+ },
1082
+ retry: 0,
1083
+ reporters: 'true' === process.env.GITHUB_ACTIONS ? [
1084
+ 'default',
1085
+ 'github-actions'
1086
+ ] : [
1087
+ 'default'
1088
+ ],
1089
+ clearMocks: false,
1090
+ resetMocks: false,
1091
+ restoreMocks: false,
1092
+ slowTestThreshold: 300,
1093
+ unstubGlobals: false,
1094
+ unstubEnvs: false,
1095
+ maxConcurrency: 5,
1096
+ printConsoleTrace: false,
1097
+ disableConsoleIntercept: false,
1098
+ snapshotFormat: {},
1099
+ env: {},
1100
+ hideSkippedTests: false,
1101
+ logHeapUsage: false,
1102
+ bail: 0,
1103
+ includeTaskLocation: false,
1104
+ browser: {
1105
+ enabled: false,
1106
+ provider: 'playwright',
1107
+ browser: 'chromium',
1108
+ headless: T
1109
+ },
1110
+ coverage: {
1111
+ exclude: [
1112
+ '**/node_modules/**',
1113
+ '**/dist/**',
1114
+ '**/test/**',
1115
+ '**/__tests__/**',
1116
+ '**/__mocks__/**',
1117
+ '**/*.d.ts',
1118
+ '**/*.{test,spec}.[jt]s',
1119
+ '**/*.{test,spec}.[cm][jt]s',
1120
+ '**/*.{test,spec}.[jt]sx',
1121
+ '**/*.{test,spec}.[cm][jt]sx'
1122
+ ],
1123
+ enabled: false,
1124
+ provider: 'istanbul',
1125
+ reporters: [
1126
+ 'text',
1127
+ 'html',
1128
+ 'clover',
1129
+ 'json'
1130
+ ],
1131
+ reportsDirectory: './coverage',
1132
+ clean: true,
1133
+ reportOnFailure: false
1134
+ }
1135
+ });
1136
+ const withDefaultConfig = (config)=>{
1137
+ const merged = mergeRstestConfig(createDefaultConfig(), config);
1138
+ merged.setupFiles = castArray(merged.setupFiles);
1139
+ merged.globalSetup = castArray(merged.globalSetup);
1140
+ merged.exclude.patterns.push(TEMP_RSTEST_OUTPUT_DIR_GLOB);
1141
+ const reportsDirectory = formatRootStr(merged.coverage.reportsDirectory, merged.root);
1142
+ merged.coverage.reportsDirectory = isAbsolute(reportsDirectory) ? reportsDirectory : pathe_M_eThtNZ_resolve(merged.root, reportsDirectory);
1143
+ merged.pool = 'string' == typeof config.pool ? {
1144
+ type: config.pool
1145
+ } : merged.pool;
1146
+ merged.testEnvironment = 'string' == typeof config.testEnvironment ? {
1147
+ name: config.testEnvironment
1148
+ } : merged.testEnvironment;
1149
+ merged.browser = {
1150
+ enabled: merged.browser?.enabled ?? false,
1151
+ provider: merged.browser?.provider ?? 'playwright',
1152
+ browser: merged.browser?.browser ?? 'chromium',
1153
+ headless: merged.browser?.headless ?? T,
1154
+ port: merged.browser?.port
1155
+ };
1156
+ return {
1157
+ ...merged,
1158
+ include: merged.include.map((p)=>formatRootStr(p, merged.root)),
1159
+ exclude: {
1160
+ ...merged.exclude,
1161
+ patterns: merged.exclude.patterns.map((p)=>formatRootStr(p, merged.root))
1162
+ },
1163
+ setupFiles: merged.setupFiles.map((p)=>formatRootStr(p, merged.root)),
1164
+ globalSetup: merged.globalSetup.map((p)=>formatRootStr(p, merged.root)),
1165
+ includeSource: merged.includeSource.map((p)=>formatRootStr(p, merged.root))
1166
+ };
1167
+ };
1168
+ function mergeWithCLIOptions(config, options) {
1169
+ const keys = [
1170
+ 'root',
1171
+ 'globals',
1172
+ 'isolate',
1173
+ 'passWithNoTests',
1174
+ 'update',
1175
+ 'testNamePattern',
1176
+ 'testTimeout',
1177
+ 'hookTimeout',
1178
+ 'clearMocks',
1179
+ 'resetMocks',
1180
+ 'restoreMocks',
1181
+ 'unstubEnvs',
1182
+ 'unstubGlobals',
1183
+ 'retry',
1184
+ 'slowTestThreshold',
1185
+ 'maxConcurrency',
1186
+ 'printConsoleTrace',
1187
+ 'disableConsoleIntercept',
1188
+ 'testEnvironment',
1189
+ 'hideSkippedTests',
1190
+ 'logHeapUsage'
1191
+ ];
1192
+ for (const key of keys)if (void 0 !== options[key]) config[key] = options[key];
1193
+ if (options.reporter) config.reporters = castArray(options.reporter);
1194
+ if (void 0 !== options.bail && ('number' == typeof options.bail || 'boolean' == typeof options.bail)) config.bail = Number(options.bail);
1195
+ if (void 0 !== options.coverage) {
1196
+ config.coverage ??= {};
1197
+ config.coverage.enabled = options.coverage;
1198
+ }
1199
+ if (options.exclude) config.exclude = castArray(options.exclude);
1200
+ if (options.include) config.include = castArray(options.include);
1201
+ return config;
1202
+ }
1203
+ async function resolveConfig(options) {
1204
+ const { content: config, filePath: configFilePath } = await loadConfig({
1205
+ cwd: options.cwd,
1206
+ path: options.config,
1207
+ configLoader: options.configLoader
1208
+ });
1209
+ const mergedConfig = mergeWithCLIOptions(config, options);
1210
+ if (!mergedConfig.root) mergedConfig.root = options.cwd;
1211
+ if (void 0 !== options.browser) {
1212
+ config.browser ??= {};
1213
+ config.browser.enabled = options.browser;
1214
+ }
1215
+ return {
1216
+ config: mergedConfig,
1217
+ configFilePath: configFilePath ?? void 0
1218
+ };
1219
+ }
1220
+ async function resolveProjects({ config, root, options }) {
1221
+ if (!config.projects) return [];
1222
+ const getDefaultProjectName = (dir)=>{
1223
+ const pkgJsonPath = pathe_M_eThtNZ_resolve(dir, 'package.json');
1224
+ const name = (0, external_node_fs_.existsSync)(pkgJsonPath) ? JSON.parse((0, external_node_fs_.readFileSync)(pkgJsonPath, 'utf-8')).name : '';
1225
+ if ('string' != typeof name || !name) return basename(dir);
1226
+ return name;
1227
+ };
1228
+ const globProjects = async (patterns, root)=>{
1229
+ const globOptions = {
1230
+ absolute: true,
1231
+ dot: true,
1232
+ onlyFiles: false,
1233
+ cwd: root,
1234
+ expandDirectories: false,
1235
+ ignore: [
1236
+ '**/node_modules/**',
1237
+ '**/.DS_Store'
1238
+ ]
1239
+ };
1240
+ return glob(patterns, globOptions);
1241
+ };
1242
+ const resolvedProjectPaths = new Set();
1243
+ const getProjects = async (rstestConfig, root)=>{
1244
+ const projectPaths = [];
1245
+ const projectPatterns = [];
1246
+ const projectConfigs = [];
1247
+ await Promise.all((rstestConfig.projects || []).map(async (p)=>{
1248
+ if ('object' == typeof p) {
1249
+ const projectRoot = p.root ? formatRootStr(p.root, root) : root;
1250
+ let projectConfig = {
1251
+ ...p
1252
+ };
1253
+ if (projectConfig.extends) {
1254
+ const extendsConfig = 'function' == typeof projectConfig.extends ? await projectConfig.extends(Object.freeze({
1255
+ ...projectConfig
1256
+ })) : projectConfig.extends;
1257
+ delete extendsConfig.projects;
1258
+ projectConfig = mergeRstestConfig(extendsConfig, projectConfig);
1259
+ }
1260
+ projectConfigs.push({
1261
+ config: mergeWithCLIOptions({
1262
+ root: projectRoot,
1263
+ ...projectConfig,
1264
+ name: p.name ? p.name : getDefaultProjectName(projectRoot)
1265
+ }, options),
1266
+ configFilePath: void 0
1267
+ });
1268
+ return;
1269
+ }
1270
+ const projectStr = formatRootStr(p, root);
1271
+ if (isDynamicPattern(projectStr)) projectPatterns.push(projectStr);
1272
+ else {
1273
+ const absolutePath = getAbsolutePath(root, projectStr);
1274
+ if (!(0, external_node_fs_.existsSync)(absolutePath)) throw `Can't resolve project "${p}", please make sure "${p}" is a existing file or a directory.`;
1275
+ projectPaths.push(absolutePath);
1276
+ }
1277
+ }));
1278
+ projectPaths.push(...await globProjects(projectPatterns, root));
1279
+ const projects = [];
1280
+ await Promise.all(projectPaths.map(async (project)=>{
1281
+ const isDirectory = (0, external_node_fs_.statSync)(project).isDirectory();
1282
+ const projectRoot = isDirectory ? project : dirname(project);
1283
+ const { config, configFilePath } = await resolveConfig({
1284
+ ...options,
1285
+ config: isDirectory ? void 0 : project,
1286
+ cwd: projectRoot
1287
+ });
1288
+ if (configFilePath) {
1289
+ if (resolvedProjectPaths.has(configFilePath)) return;
1290
+ resolvedProjectPaths.add(configFilePath);
1291
+ }
1292
+ config.name ??= getDefaultProjectName(projectRoot);
1293
+ if (config.projects?.length) {
1294
+ const childProjects = await getProjects(config, projectRoot);
1295
+ projects.push(...childProjects);
1296
+ } else projects.push({
1297
+ config,
1298
+ configFilePath
1299
+ });
1300
+ }));
1301
+ return projects.concat(projectConfigs);
1302
+ };
1303
+ const projects = await getProjects(config, root).then((p)=>filterProjects(p, options));
1304
+ if (!projects.length) {
1305
+ let errorMsg = `No projects found, please make sure you have at least one valid project.
1306
+ ${picocolors_default().gray('projects:')} ${JSON.stringify(config.projects, null, 2)}`;
1307
+ if (options.project) errorMsg += `\n${picocolors_default().gray('projectName filter:')} ${JSON.stringify(options.project, null, 2)}`;
1308
+ throw errorMsg;
1309
+ }
1310
+ const names = new Set();
1311
+ projects.forEach((project)=>{
1312
+ if (names.has(project.config.name)) {
1313
+ const conflictProjects = projects.filter((p)=>p.config.name === project.config.name);
1314
+ throw `Project name "${project.config.name}" is already used. Please ensure all projects have unique names.
1315
+ Conflicting projects:
1316
+ ${conflictProjects.map((p)=>`- ${p.configFilePath || p.config.root}`).join('\n')}
1317
+ `;
1318
+ }
1319
+ names.add(project.config.name);
1320
+ });
1321
+ return projects;
1322
+ }
1323
+ async function init_initCli(options) {
1324
+ const cwd = process.cwd();
1325
+ const root = options.root ? getAbsolutePath(cwd, options.root) : cwd;
1326
+ const { config, configFilePath } = await resolveConfig({
1327
+ ...options,
1328
+ cwd: options.root ? getAbsolutePath(cwd, options.root) : cwd
1329
+ });
1330
+ const projects = await resolveProjects({
1331
+ config,
1332
+ root,
1333
+ options
1334
+ });
1335
+ return {
1336
+ config,
1337
+ configFilePath,
1338
+ projects
1264
1339
  };
1265
1340
  }
1266
- const l = dist_b();
1267
- l.name;
1268
- function n(e) {
1269
- return e ? "false" !== e : !1;
1341
+ async function runCLI() {
1342
+ prepareCli();
1343
+ try {
1344
+ setupCommands();
1345
+ } catch (err) {
1346
+ logger_logger.error('Failed to start Rstest CLI.');
1347
+ logger_logger.error(err);
1348
+ }
1270
1349
  }
1271
- const I = globalThis.process?.platform || "", T = n(dist_o.CI) || !1 !== l.ci, R = n(globalThis.process?.stdout && globalThis.process?.stdout.isTTY), A = (n(dist_o.DEBUG), "test" === dist_t || n(dist_o.TEST), n(dist_o.MINIMAL), /^win/i.test(I)), C = (/^linux/i.test(I), /^darwin/i.test(I), !n(dist_o.NO_COLOR) && (n(dist_o.FORCE_COLOR) || (R || A) && dist_o.TERM), (globalThis.process?.versions?.node || "").replace(/^v/, "") || null), W = (Number(C?.split(".")[0]), globalThis.process || Object.create(null)), dist_ = {
1272
- versions: {}
1273
- }, O = (new Proxy(W, {
1274
- get (e, s) {
1275
- if ("env" === s) return dist_o;
1276
- if (s in e) return e[s];
1277
- if (s in dist_) return dist_[s];
1350
+ class SnapshotManager {
1351
+ summary;
1352
+ extension = ".snap";
1353
+ constructor(options){
1354
+ this.options = options;
1355
+ this.clear();
1278
1356
  }
1279
- }), globalThis.process?.release?.name === "node"), c = !!globalThis.Bun || !!globalThis.process?.versions?.bun, D = !!globalThis.Deno, L = !!globalThis.fastly, S = !!globalThis.Netlify, u = !!globalThis.EdgeRuntime, N = globalThis.navigator?.userAgent === "Cloudflare-Workers", F = [
1280
- [
1281
- S,
1282
- "netlify"
1283
- ],
1284
- [
1285
- u,
1286
- "edge-light"
1287
- ],
1288
- [
1289
- N,
1290
- "workerd"
1291
- ],
1292
- [
1293
- L,
1294
- "fastly"
1295
- ],
1296
- [
1297
- D,
1298
- "deno"
1299
- ],
1300
- [
1301
- c,
1302
- "bun"
1303
- ],
1304
- [
1305
- O,
1306
- "node"
1307
- ]
1308
- ];
1309
- function G() {
1310
- const e = F.find((s)=>s[0]);
1311
- if (e) return {
1312
- name: e[1]
1357
+ clear() {
1358
+ this.summary = emptySummary(this.options);
1359
+ }
1360
+ add(result) {
1361
+ addSnapshotResult(this.summary, result);
1362
+ }
1363
+ resolvePath(testPath, context) {
1364
+ const resolver = this.options.resolveSnapshotPath || (()=>join(join(dirname(testPath), "__snapshots__"), `${basename(testPath)}${this.extension}`));
1365
+ const path = resolver(testPath, this.extension, context);
1366
+ return path;
1367
+ }
1368
+ resolveRawPath(testPath, rawPath) {
1369
+ return isAbsolute(rawPath) ? rawPath : pathe_M_eThtNZ_resolve(dirname(testPath), rawPath);
1370
+ }
1371
+ }
1372
+ function emptySummary(options) {
1373
+ const summary = {
1374
+ added: 0,
1375
+ failure: false,
1376
+ filesAdded: 0,
1377
+ filesRemoved: 0,
1378
+ filesRemovedList: [],
1379
+ filesUnmatched: 0,
1380
+ filesUpdated: 0,
1381
+ matched: 0,
1382
+ total: 0,
1383
+ unchecked: 0,
1384
+ uncheckedKeysByFile: [],
1385
+ unmatched: 0,
1386
+ updated: 0,
1387
+ didUpdate: "all" === options.updateSnapshot
1313
1388
  };
1389
+ return summary;
1390
+ }
1391
+ function addSnapshotResult(summary, result) {
1392
+ if (result.added) summary.filesAdded++;
1393
+ if (result.fileDeleted) summary.filesRemoved++;
1394
+ if (result.unmatched) summary.filesUnmatched++;
1395
+ if (result.updated) summary.filesUpdated++;
1396
+ summary.added += result.added;
1397
+ summary.matched += result.matched;
1398
+ summary.unchecked += result.unchecked;
1399
+ if (result.uncheckedKeys && result.uncheckedKeys.length > 0) summary.uncheckedKeysByFile.push({
1400
+ filePath: result.filepath,
1401
+ keys: result.uncheckedKeys
1402
+ });
1403
+ summary.unmatched += result.unmatched;
1404
+ summary.updated += result.updated;
1405
+ summary.total += result.added + result.matched + result.unmatched + result.updated;
1314
1406
  }
1315
- const P = G();
1316
- P?.name;
1317
1407
  const getSummaryStatusString = (tasks, name = 'tests', showTotal = true)=>{
1318
1408
  if (0 === tasks.length) return picocolors_default().dim(`no ${name}`);
1319
1409
  const passed = tasks.filter((result)=>'pass' === result.status);
@@ -2142,6 +2232,7 @@ async function error_parseErrorStacktrace({ stack, getSourcemap, fullStack = isD
2142
2232
  })).then((frames)=>frames.filter((frame)=>null !== frame));
2143
2233
  return stackFrames;
2144
2234
  }
2235
+ const promises_ = __webpack_require__("node:fs/promises");
2145
2236
  class JUnitReporter {
2146
2237
  rootPath;
2147
2238
  outputPath;
@@ -2251,7 +2342,7 @@ class JUnitReporter {
2251
2342
  };
2252
2343
  const xmlContent = this.generateJUnitXml(report);
2253
2344
  if (this.outputPath) try {
2254
- await writeFile(this.outputPath, xmlContent, 'utf-8');
2345
+ await (0, promises_.writeFile)(this.outputPath, xmlContent, 'utf-8');
2255
2346
  logger_logger.log(`JUnit XML report written to: ${this.outputPath}`);
2256
2347
  } catch (error) {
2257
2348
  logger_logger.stderr(`Failed to write JUnit XML report to ${this.outputPath}:`, error);
@@ -2381,7 +2472,7 @@ class Rstest {
2381
2472
  });
2382
2473
  this.reporters = reporters;
2383
2474
  this.snapshotManager = snapshotManager;
2384
- this.version = "0.7.7";
2475
+ this.version = "0.7.9";
2385
2476
  this.rootPath = rootPath;
2386
2477
  this.originalConfig = userConfig;
2387
2478
  this.normalizedConfig = rstestConfig;
@@ -2402,7 +2493,7 @@ class Rstest {
2402
2493
  rootPath: config.root,
2403
2494
  name: config.name,
2404
2495
  _globalSetups: false,
2405
- outputModule: config.output?.module ?? 'true' === process.env.RSTEST_OUTPUT_MODULE,
2496
+ outputModule: config.output?.module ?? 'false' !== process.env.RSTEST_OUTPUT_MODULE,
2406
2497
  environmentName: formatEnvironmentName(config.name),
2407
2498
  normalizedConfig: config
2408
2499
  };
@@ -2412,7 +2503,7 @@ class Rstest {
2412
2503
  rootPath,
2413
2504
  _globalSetups: false,
2414
2505
  name: rstestConfig.name,
2415
- outputModule: rstestConfig.output?.module ?? 'true' === process.env.RSTEST_OUTPUT_MODULE,
2506
+ outputModule: rstestConfig.output?.module ?? 'false' !== process.env.RSTEST_OUTPUT_MODULE,
2416
2507
  environmentName: formatEnvironmentName(rstestConfig.name),
2417
2508
  normalizedConfig: rstestConfig
2418
2509
  }
@@ -2486,44 +2577,10 @@ function core_createRstest({ config, projects, configFilePath }, command, fileFi
2486
2577
  listTests
2487
2578
  };
2488
2579
  }
2489
- const check = (name)=>{
2490
- if (!globalThis.RSTEST_API?.[name]) throw new Error(`Rstest API '${name}' is not registered yet, please make sure you are running in a rstest environment.`);
2491
- };
2492
- const wrapRstestAPI = (name)=>{
2493
- const fn = (...args)=>{
2494
- check(name);
2495
- return globalThis.RSTEST_API[name].call(globalThis.RSTEST_API[name], ...args);
2496
- };
2497
- return new Proxy(fn, {
2498
- get (_target, key, receiver) {
2499
- check(name);
2500
- return Reflect.get(globalThis.RSTEST_API?.[name] || {}, key, receiver);
2501
- }
2502
- });
2503
- };
2504
- const wrapRstestUtilitiesAPI = (name)=>new Proxy({}, {
2505
- get (_target, key, receiver) {
2506
- check(name);
2507
- return Reflect.get(globalThis.RSTEST_API?.[name] || {}, key, receiver);
2508
- }
2509
- });
2510
- const expect = wrapRstestAPI('expect');
2511
- const assert = wrapRstestAPI('assert');
2512
- const it = wrapRstestAPI('it');
2513
- const public_test = wrapRstestAPI('test');
2514
- const describe = wrapRstestAPI('describe');
2515
- const beforeAll = wrapRstestAPI('beforeAll');
2516
- const afterAll = wrapRstestAPI('afterAll');
2517
- const beforeEach = wrapRstestAPI('beforeEach');
2518
- const afterEach = wrapRstestAPI('afterEach');
2519
- const public_rstest = wrapRstestUtilitiesAPI('rstest');
2520
- const rs = wrapRstestUtilitiesAPI('rs');
2521
- const onTestFinished = wrapRstestAPI('onTestFinished');
2522
- const onTestFailed = wrapRstestAPI('onTestFailed');
2523
2580
  function defineConfig(config) {
2524
2581
  return config;
2525
2582
  }
2526
2583
  function defineProject(config) {
2527
2584
  return config;
2528
2585
  }
2529
- 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, rspack, runCLI, runRest };
2586
+ export { EventEmitter, core_createRstest as createRstest, defineConfig, defineProject, error_printError, init_initCli as initCli, loadConfig, mergeProjectConfig, mergeRstestConfig, runCLI, runRest };