@rstest/core 0.9.4 → 0.9.6
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/LICENSE.md +54 -202
- package/dist/0~8843.js +32 -14
- package/dist/{0~lib.js → 0~@babel/code-frame.js} +2 -2
- package/dist/0~@clack/prompts.js +1044 -0
- package/dist/0~browserLoader.js +1 -1
- package/dist/0~browser~1.js +19 -19
- package/dist/0~checkThresholds.js +2 -2
- package/dist/0~chokidar.js +43 -42
- package/dist/0~console.js +1 -1
- package/dist/0~fake-timers.js +1586 -0
- package/dist/0~generate.js +5 -5
- package/dist/0~happyDom.js +1 -1
- package/dist/0~jsdom.js +1 -1
- package/dist/0~listTests.js +3 -3
- package/dist/0~loadModule.js +1 -1
- package/dist/0~magic-string.es.js +1 -181
- package/dist/0~restart.js +1 -1
- package/dist/0~runTests.js +11 -4
- package/dist/0~snapshot.js +2140 -0
- package/dist/0~snapshot.js.LICENSE.txt +7 -0
- package/dist/0~utils.js +1 -1
- package/dist/1255.js +11 -11
- package/dist/1949.js +2919 -9808
- package/dist/1949.js.LICENSE.txt +1 -49
- package/dist/3145.js +415 -40
- package/dist/4411.js +245 -60
- package/dist/6830.js +62 -10
- package/dist/6887.js +15 -0
- package/dist/7552.js +22 -4918
- package/dist/9743.js +1982 -0
- package/dist/9784.js +1343 -0
- package/dist/{7552.js.LICENSE.txt → 9784.js.LICENSE.txt} +19 -8
- package/dist/browser-runtime/2~fake-timers.js +1760 -0
- package/dist/browser-runtime/2~magic-string.es.js +3 -189
- package/dist/browser-runtime/2~snapshot.js +2138 -0
- package/dist/browser-runtime/2~snapshot.js.LICENSE.txt +7 -0
- package/dist/browser-runtime/723.js +1818 -10300
- package/dist/browser-runtime/723.js.LICENSE.txt +0 -17
- package/dist/browser-runtime/index.d.ts +205 -16
- package/dist/browser.d.ts +55 -10
- package/dist/browser.js +2 -2
- package/dist/globalSetupWorker.js +2 -2
- package/dist/index.d.ts +78 -16
- package/dist/index.js +1 -1
- package/dist/mockRuntimeCode.js +2 -0
- package/dist/worker.d.ts +47 -10
- package/dist/worker.js +12 -10
- package/package.json +27 -28
- package/dist/0~dist.js +0 -1014
- package/dist/4899.js +0 -11
- package/dist/browser-runtime/rslib-runtime.js +0 -56
- /package/dist/{rslib-runtime.js → 0~rslib-runtime.js} +0 -0
package/dist/3145.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import "node:module";
|
|
2
|
-
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
3
2
|
import node_fs, { existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
|
|
4
3
|
import { loadConfig, mergeRsbuildConfig } from "@rsbuild/core";
|
|
5
4
|
import { stripVTControlCharacters } from "node:util";
|
|
@@ -7,8 +6,9 @@ import promises from "node:fs/promises";
|
|
|
7
6
|
import node_path, { dirname as external_node_path_dirname, resolve as external_node_path_resolve } from "node:path";
|
|
8
7
|
import { createRequire } from "node:module";
|
|
9
8
|
import node_process from "node:process";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
9
|
+
import { __webpack_require__ } from "./0~rslib-runtime.js";
|
|
10
|
+
import { POINTER, DEFAULT_CONFIG_NAME, globalApis, resolve as pathe_M_eThtNZ_resolve, relative, join, logger as logger_logger, prettyTime, getTempRstestOutputDirGlob, color as logger_color, isAbsolute, getOutputDistPathRoot, TEMP_RSTEST_OUTPUT_DIR, TS_CONFIG_FILE, basename, isTTY, dirname as pathe_M_eThtNZ_dirname, TEST_DELIMITER, getAbsolutePath, bgColor, formatRootStr, determineAgent, castArray, dist_m, getTaskNameWithPrefix, isDebug, formatError, normalize, DEFAULT_CONFIG_EXTENSIONS } from "./6830.js";
|
|
11
|
+
import { isDynamicPattern, glob, filterProjects, prettyTestPath, formatTestPath } from "./4411.js";
|
|
12
12
|
import { posix } from "./7011.js";
|
|
13
13
|
import { parse as stack_trace_parser_esm_parse } from "./1672.js";
|
|
14
14
|
import { decode } from "./4397.js";
|
|
@@ -22,8 +22,7 @@ __webpack_require__.d(init_namespaceObject, {
|
|
|
22
22
|
var core_namespaceObject = {};
|
|
23
23
|
__webpack_require__.r(core_namespaceObject);
|
|
24
24
|
__webpack_require__.d(core_namespaceObject, {
|
|
25
|
-
createRstest: ()=>core_createRstest
|
|
26
|
-
initCli: ()=>init_initCli
|
|
25
|
+
createRstest: ()=>core_createRstest
|
|
27
26
|
});
|
|
28
27
|
var error_namespaceObject = {};
|
|
29
28
|
__webpack_require__.r(error_namespaceObject);
|
|
@@ -589,15 +588,255 @@ function prepareCli() {
|
|
|
589
588
|
if (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) logger_logger.log();
|
|
590
589
|
}
|
|
591
590
|
function showRstest() {
|
|
592
|
-
logger_logger.greet(" Rstest v0.9.
|
|
591
|
+
logger_logger.greet(" Rstest v0.9.6");
|
|
593
592
|
logger_logger.log('');
|
|
594
593
|
}
|
|
595
|
-
const
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
594
|
+
const runtimeOptionDefinitions = [
|
|
595
|
+
[
|
|
596
|
+
'-c, --config <config>',
|
|
597
|
+
'Specify the configuration file, can be a relative or absolute path'
|
|
598
|
+
],
|
|
599
|
+
[
|
|
600
|
+
'--config-loader <loader>',
|
|
601
|
+
'Specify the loader to load the config file (auto | jiti | native)',
|
|
602
|
+
{
|
|
603
|
+
default: 'auto'
|
|
604
|
+
}
|
|
605
|
+
],
|
|
606
|
+
[
|
|
607
|
+
'-r, --root <root>',
|
|
608
|
+
'Specify the project root directory, can be an absolute path or a path relative to cwd'
|
|
609
|
+
],
|
|
610
|
+
[
|
|
611
|
+
'--globals',
|
|
612
|
+
'Provide global APIs'
|
|
613
|
+
],
|
|
614
|
+
[
|
|
615
|
+
'--isolate',
|
|
616
|
+
'Run tests in an isolated environment'
|
|
617
|
+
],
|
|
618
|
+
[
|
|
619
|
+
'--include <include>',
|
|
620
|
+
'Match test files'
|
|
621
|
+
],
|
|
622
|
+
[
|
|
623
|
+
'--exclude <exclude>',
|
|
624
|
+
'Exclude files from test'
|
|
625
|
+
],
|
|
626
|
+
[
|
|
627
|
+
'-u, --update',
|
|
628
|
+
'Update snapshot files'
|
|
629
|
+
],
|
|
630
|
+
[
|
|
631
|
+
'--coverage',
|
|
632
|
+
'Enable code coverage collection'
|
|
633
|
+
],
|
|
634
|
+
[
|
|
635
|
+
'--project <name>',
|
|
636
|
+
'Run only projects that match the name, can be a full name or wildcards pattern'
|
|
637
|
+
],
|
|
638
|
+
[
|
|
639
|
+
'--passWithNoTests',
|
|
640
|
+
'Allows the test suite to pass when no files are found'
|
|
641
|
+
],
|
|
642
|
+
[
|
|
643
|
+
'--printConsoleTrace',
|
|
644
|
+
'Print console traces when calling any console method'
|
|
645
|
+
],
|
|
646
|
+
[
|
|
647
|
+
'--disableConsoleIntercept',
|
|
648
|
+
'Disable console intercept'
|
|
649
|
+
],
|
|
650
|
+
[
|
|
651
|
+
'--logHeapUsage',
|
|
652
|
+
'Log heap usage after each test'
|
|
653
|
+
],
|
|
654
|
+
[
|
|
655
|
+
'--slowTestThreshold <value>',
|
|
656
|
+
'The number of milliseconds after which a test or suite is considered slow'
|
|
657
|
+
],
|
|
658
|
+
[
|
|
659
|
+
'--reporter <reporter>',
|
|
660
|
+
'Specify the reporter to use'
|
|
661
|
+
],
|
|
662
|
+
[
|
|
663
|
+
'-t, --testNamePattern <value>',
|
|
664
|
+
'Run only tests with a name that matches the regex'
|
|
665
|
+
],
|
|
666
|
+
[
|
|
667
|
+
'--testEnvironment <name>',
|
|
668
|
+
'The environment that will be used for testing'
|
|
669
|
+
],
|
|
670
|
+
[
|
|
671
|
+
'--testTimeout <value>',
|
|
672
|
+
'Timeout of a test in milliseconds'
|
|
673
|
+
],
|
|
674
|
+
[
|
|
675
|
+
'--hookTimeout <value>',
|
|
676
|
+
'Timeout of hook in milliseconds'
|
|
677
|
+
],
|
|
678
|
+
[
|
|
679
|
+
'--hideSkippedTests',
|
|
680
|
+
'Hide skipped tests from the output'
|
|
681
|
+
],
|
|
682
|
+
[
|
|
683
|
+
'--hideSkippedTestFiles',
|
|
684
|
+
'Hide skipped test files from the output'
|
|
685
|
+
],
|
|
686
|
+
[
|
|
687
|
+
'--retry <retry>',
|
|
688
|
+
'Number of times to retry a test if it fails'
|
|
689
|
+
],
|
|
690
|
+
[
|
|
691
|
+
'--bail [number]',
|
|
692
|
+
'Stop running tests after n failures. Set to 0 to run all tests regardless of failures'
|
|
693
|
+
],
|
|
694
|
+
[
|
|
695
|
+
'--shard <index/count>',
|
|
696
|
+
'Split tests into several shards. This is useful for running tests in parallel on multiple machines.'
|
|
697
|
+
],
|
|
698
|
+
[
|
|
699
|
+
'--maxConcurrency <value>',
|
|
700
|
+
'Maximum number of concurrent tests'
|
|
701
|
+
],
|
|
702
|
+
[
|
|
703
|
+
'--clearMocks',
|
|
704
|
+
'Automatically clear mock calls, instances, contexts and results before every test'
|
|
705
|
+
],
|
|
706
|
+
[
|
|
707
|
+
'--resetMocks',
|
|
708
|
+
'Automatically reset mock state before every test'
|
|
709
|
+
],
|
|
710
|
+
[
|
|
711
|
+
'--restoreMocks',
|
|
712
|
+
'Automatically restore mock state and implementation before every test'
|
|
713
|
+
],
|
|
714
|
+
[
|
|
715
|
+
'--browser',
|
|
716
|
+
'Run tests in browser mode'
|
|
717
|
+
],
|
|
718
|
+
[
|
|
719
|
+
'--browser.enabled',
|
|
720
|
+
'Run tests in browser mode'
|
|
721
|
+
],
|
|
722
|
+
[
|
|
723
|
+
'--browser.name <name>',
|
|
724
|
+
'Browser to use: chromium, firefox, webkit (default: chromium)'
|
|
725
|
+
],
|
|
726
|
+
[
|
|
727
|
+
'--browser.headless',
|
|
728
|
+
'Run browser in headless mode (default: true in CI)'
|
|
729
|
+
],
|
|
730
|
+
[
|
|
731
|
+
'--browser.port <port>',
|
|
732
|
+
'Port for the browser mode dev server'
|
|
733
|
+
],
|
|
734
|
+
[
|
|
735
|
+
'--browser.strictPort',
|
|
736
|
+
'Exit if the specified port is already in use'
|
|
737
|
+
],
|
|
738
|
+
[
|
|
739
|
+
'--unstubGlobals',
|
|
740
|
+
'Restores all global variables that were changed with `rstest.stubGlobal` before every test'
|
|
741
|
+
],
|
|
742
|
+
[
|
|
743
|
+
'--unstubEnvs',
|
|
744
|
+
'Restores all runtime env values that were changed with `rstest.stubEnv` before every test'
|
|
745
|
+
],
|
|
746
|
+
[
|
|
747
|
+
'--includeTaskLocation',
|
|
748
|
+
'Collect test and suite locations. This might increase the running time.'
|
|
749
|
+
]
|
|
750
|
+
];
|
|
751
|
+
const poolOptionDefinitions = [
|
|
752
|
+
[
|
|
753
|
+
'--pool <type>',
|
|
754
|
+
'Shorthand for --pool.type'
|
|
755
|
+
],
|
|
756
|
+
[
|
|
757
|
+
'--pool.type <type>',
|
|
758
|
+
'Specify the test pool type (e.g. forks)'
|
|
759
|
+
],
|
|
760
|
+
[
|
|
761
|
+
'--pool.maxWorkers <value>',
|
|
762
|
+
'Maximum number or percentage of workers (e.g. 4 or 50%)'
|
|
763
|
+
],
|
|
764
|
+
[
|
|
765
|
+
'--pool.minWorkers <value>',
|
|
766
|
+
'Minimum number or percentage of workers (e.g. 1 or 25%)'
|
|
767
|
+
],
|
|
768
|
+
[
|
|
769
|
+
'--pool.execArgv <arg>',
|
|
770
|
+
'Additional Node.js execArgv passed to worker processes (can be specified multiple times)'
|
|
771
|
+
]
|
|
772
|
+
];
|
|
773
|
+
const mergeReportsOptionDefinitions = [
|
|
774
|
+
[
|
|
775
|
+
'-c, --config <config>',
|
|
776
|
+
'Specify the configuration file, can be a relative or absolute path'
|
|
777
|
+
],
|
|
778
|
+
[
|
|
779
|
+
'--config-loader <loader>',
|
|
780
|
+
'Specify the loader to load the config file (auto | jiti | native)',
|
|
781
|
+
{
|
|
782
|
+
default: 'auto'
|
|
783
|
+
}
|
|
784
|
+
],
|
|
785
|
+
[
|
|
786
|
+
'-r, --root <root>',
|
|
787
|
+
'Specify the project root directory, can be an absolute path or a path relative to cwd'
|
|
788
|
+
],
|
|
789
|
+
[
|
|
790
|
+
'--coverage',
|
|
791
|
+
'Enable code coverage collection'
|
|
792
|
+
],
|
|
793
|
+
[
|
|
794
|
+
'--reporter <reporter>',
|
|
795
|
+
'Specify the reporter to use'
|
|
796
|
+
],
|
|
797
|
+
[
|
|
798
|
+
'--cleanup',
|
|
799
|
+
'Remove blob reports directory after merging'
|
|
800
|
+
]
|
|
801
|
+
];
|
|
802
|
+
const hiddenPassthroughOptionDefinitions = [
|
|
803
|
+
[
|
|
804
|
+
'--isolate',
|
|
805
|
+
'Run tests in an isolated environment'
|
|
806
|
+
]
|
|
807
|
+
];
|
|
808
|
+
const listCommandOptionDefinitions = [
|
|
809
|
+
[
|
|
810
|
+
'--filesOnly',
|
|
811
|
+
'only list the test files'
|
|
812
|
+
],
|
|
813
|
+
[
|
|
814
|
+
'--json [boolean/path]',
|
|
815
|
+
'print tests as JSON or write to a file'
|
|
816
|
+
],
|
|
817
|
+
[
|
|
818
|
+
'--includeSuites',
|
|
819
|
+
'include suites in output'
|
|
820
|
+
],
|
|
821
|
+
[
|
|
822
|
+
'--printLocation',
|
|
823
|
+
'print test case location'
|
|
824
|
+
]
|
|
825
|
+
];
|
|
826
|
+
const applyOptions = (command, definitions)=>{
|
|
827
|
+
for (const [rawName, description, config] of definitions)command.option(rawName, description, config);
|
|
828
|
+
};
|
|
829
|
+
const applyRuntimeCommandOptions = (command)=>{
|
|
830
|
+
applyOptions(command, runtimeOptionDefinitions);
|
|
831
|
+
applyOptions(command, poolOptionDefinitions);
|
|
600
832
|
};
|
|
833
|
+
const filterHelpOptions = (sections, hiddenOptionPrefixes)=>sections.map((section)=>{
|
|
834
|
+
if ('Options' !== section.title) return section;
|
|
835
|
+
return {
|
|
836
|
+
...section,
|
|
837
|
+
body: section.body.split('\n').filter((line)=>!hiddenOptionPrefixes.some((prefix)=>line.trimStart().startsWith(prefix))).join('\n')
|
|
838
|
+
};
|
|
839
|
+
});
|
|
601
840
|
const handleUnexpectedExit = (rstest, err)=>{
|
|
602
841
|
for (const reporter of rstest?.context.reporters || [])reporter.onExit?.();
|
|
603
842
|
logger_logger.error('Failed to run Rstest.');
|
|
@@ -648,12 +887,23 @@ const runRest = async ({ options, filters, command })=>{
|
|
|
648
887
|
handleUnexpectedExit(rstest, err);
|
|
649
888
|
}
|
|
650
889
|
};
|
|
651
|
-
function
|
|
890
|
+
function createCli() {
|
|
652
891
|
const cli = cac('rstest');
|
|
653
|
-
cli.help()
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
892
|
+
cli.help((sections)=>{
|
|
893
|
+
switch(cli.matchedCommand?.name){
|
|
894
|
+
case 'init':
|
|
895
|
+
case 'merge-reports':
|
|
896
|
+
return filterHelpOptions(sections, [
|
|
897
|
+
'--isolate'
|
|
898
|
+
]);
|
|
899
|
+
default:
|
|
900
|
+
return sections;
|
|
901
|
+
}
|
|
902
|
+
});
|
|
903
|
+
cli.version("0.9.6");
|
|
904
|
+
const defaultCommand = cli.command('[...filters]', 'run tests').option('-w, --watch', 'Run tests in watch mode');
|
|
905
|
+
applyRuntimeCommandOptions(defaultCommand);
|
|
906
|
+
defaultCommand.action(async (filters, options)=>{
|
|
657
907
|
if (!determineAgent().isAgent) showRstest();
|
|
658
908
|
if (options.watch) await runRest({
|
|
659
909
|
options,
|
|
@@ -666,7 +916,9 @@ function setupCommands() {
|
|
|
666
916
|
command: 'run'
|
|
667
917
|
});
|
|
668
918
|
});
|
|
669
|
-
cli.command('run [...filters]', 'run tests without watch mode')
|
|
919
|
+
const runCommand = cli.command('run [...filters]', 'run tests without watch mode');
|
|
920
|
+
applyRuntimeCommandOptions(runCommand);
|
|
921
|
+
runCommand.action(async (filters, options)=>{
|
|
670
922
|
if (!determineAgent().isAgent) showRstest();
|
|
671
923
|
await runRest({
|
|
672
924
|
options,
|
|
@@ -674,7 +926,9 @@ function setupCommands() {
|
|
|
674
926
|
command: 'run'
|
|
675
927
|
});
|
|
676
928
|
});
|
|
677
|
-
cli.command('watch [...filters]', 'run tests in watch mode')
|
|
929
|
+
const watchCommand = cli.command('watch [...filters]', 'run tests in watch mode');
|
|
930
|
+
applyRuntimeCommandOptions(watchCommand);
|
|
931
|
+
watchCommand.action(async (filters, options)=>{
|
|
678
932
|
if (!determineAgent().isAgent) showRstest();
|
|
679
933
|
await runRest({
|
|
680
934
|
options,
|
|
@@ -682,7 +936,10 @@ function setupCommands() {
|
|
|
682
936
|
command: 'watch'
|
|
683
937
|
});
|
|
684
938
|
});
|
|
685
|
-
cli.command('list [...filters]', 'lists all test files that Rstest will run')
|
|
939
|
+
const listCommand = cli.command('list [...filters]', 'lists all test files that Rstest will run');
|
|
940
|
+
applyRuntimeCommandOptions(listCommand);
|
|
941
|
+
applyOptions(listCommand, listCommandOptionDefinitions);
|
|
942
|
+
listCommand.action(async (filters, options)=>{
|
|
686
943
|
try {
|
|
687
944
|
const { config, configFilePath, projects, createRstest } = await resolveCliRuntime(options);
|
|
688
945
|
if (options.printLocation) config.includeTaskLocation = true;
|
|
@@ -703,7 +960,10 @@ function setupCommands() {
|
|
|
703
960
|
process.exit(1);
|
|
704
961
|
}
|
|
705
962
|
});
|
|
706
|
-
cli.command('merge-reports [path]', 'Merge blob reports from multiple shards into a unified report')
|
|
963
|
+
const mergeReportsCommand = cli.command('merge-reports [path]', 'Merge blob reports from multiple shards into a unified report');
|
|
964
|
+
applyOptions(mergeReportsCommand, mergeReportsOptionDefinitions);
|
|
965
|
+
applyOptions(mergeReportsCommand, hiddenPassthroughOptionDefinitions);
|
|
966
|
+
mergeReportsCommand.action(async (path, options)=>{
|
|
707
967
|
if (!determineAgent().isAgent) showRstest();
|
|
708
968
|
try {
|
|
709
969
|
const { config, configFilePath, projects, createRstest } = await resolveCliRuntime(options);
|
|
@@ -722,11 +982,11 @@ function setupCommands() {
|
|
|
722
982
|
process.exit(1);
|
|
723
983
|
}
|
|
724
984
|
});
|
|
725
|
-
cli.command('init [project]', 'Initialize rstest configuration').option('--yes', 'Use default options (non-interactive)').action(async (project, options)=>{
|
|
985
|
+
cli.command('init [project]', 'Initialize rstest configuration').option('--yes', 'Use default options (non-interactive)').option('--isolate', 'Run tests in an isolated environment').action(async (project, options)=>{
|
|
726
986
|
try {
|
|
727
987
|
let selectedProject = project;
|
|
728
988
|
if (!selectedProject) {
|
|
729
|
-
const { select, isCancel } = await import("./0
|
|
989
|
+
const { select, isCancel } = await import("./0~@clack/prompts.js");
|
|
730
990
|
console.log();
|
|
731
991
|
const selected = await select({
|
|
732
992
|
message: 'What would you like to initialize?',
|
|
@@ -759,7 +1019,10 @@ function setupCommands() {
|
|
|
759
1019
|
process.exit(1);
|
|
760
1020
|
}
|
|
761
1021
|
});
|
|
762
|
-
cli
|
|
1022
|
+
return cli;
|
|
1023
|
+
}
|
|
1024
|
+
function setupCommands() {
|
|
1025
|
+
createCli().parse();
|
|
763
1026
|
}
|
|
764
1027
|
const findConfig = (basePath)=>DEFAULT_CONFIG_EXTENSIONS.map((ext)=>basePath + ext).find(node_fs.existsSync);
|
|
765
1028
|
const resolveConfigPath = (root, customConfig)=>{
|
|
@@ -861,6 +1124,11 @@ const createDefaultConfig = ()=>({
|
|
|
861
1124
|
testEnvironment: {
|
|
862
1125
|
name: 'node'
|
|
863
1126
|
},
|
|
1127
|
+
output: {
|
|
1128
|
+
distPath: {
|
|
1129
|
+
root: TEMP_RSTEST_OUTPUT_DIR
|
|
1130
|
+
}
|
|
1131
|
+
},
|
|
864
1132
|
retry: 0,
|
|
865
1133
|
reporters: 'true' === process.env.GITHUB_ACTIONS ? [
|
|
866
1134
|
'default',
|
|
@@ -922,7 +1190,11 @@ const withDefaultConfig = (config)=>{
|
|
|
922
1190
|
const merged = mergeRstestConfig(createDefaultConfig(), config);
|
|
923
1191
|
merged.setupFiles = castArray(merged.setupFiles);
|
|
924
1192
|
merged.globalSetup = castArray(merged.globalSetup);
|
|
925
|
-
merged.
|
|
1193
|
+
const outputDistPathRoot = getOutputDistPathRoot(merged.output?.distPath);
|
|
1194
|
+
merged.output.distPath = {
|
|
1195
|
+
root: formatRootStr(outputDistPathRoot, merged.root)
|
|
1196
|
+
};
|
|
1197
|
+
merged.exclude.patterns.push(getTempRstestOutputDirGlob(merged.output?.distPath?.root));
|
|
926
1198
|
const reportsDirectory = formatRootStr(merged.coverage.reportsDirectory, merged.root);
|
|
927
1199
|
merged.coverage.reportsDirectory = isAbsolute(reportsDirectory) ? reportsDirectory : pathe_M_eThtNZ_resolve(merged.root, reportsDirectory);
|
|
928
1200
|
merged.pool = 'string' == typeof config.pool ? {
|
|
@@ -1267,14 +1539,14 @@ const printSnapshotSummaryLog = (snapshots, rootDir)=>{
|
|
|
1267
1539
|
else summary.push(logger_color.bold(logger_color.yellow(`${snapshots.filesRemoved} files obsolete `)));
|
|
1268
1540
|
if (snapshots.filesRemovedList?.length) {
|
|
1269
1541
|
const [head, ...tail] = snapshots.filesRemovedList;
|
|
1270
|
-
summary.push(`${logger_color.gray(
|
|
1542
|
+
summary.push(`${logger_color.gray(POINTER)} ${formatTestPath(rootDir, head)}`);
|
|
1271
1543
|
for (const key of tail)summary.push(` ${formatTestPath(rootDir, key)}`);
|
|
1272
1544
|
}
|
|
1273
1545
|
if (snapshots.unchecked) {
|
|
1274
1546
|
if (snapshots.didUpdate) summary.push(logger_color.bold(logger_color.green(`${snapshots.unchecked} removed`)));
|
|
1275
1547
|
else summary.push(logger_color.bold(logger_color.yellow(`${snapshots.unchecked} obsolete`)));
|
|
1276
1548
|
for (const uncheckedFile of snapshots.uncheckedKeysByFile){
|
|
1277
|
-
summary.push(`${logger_color.gray(
|
|
1549
|
+
summary.push(`${logger_color.gray(POINTER)} ${formatTestPath(rootDir, uncheckedFile.filePath)}`);
|
|
1278
1550
|
for (const key of uncheckedFile.keys)summary.push(` ${key}`);
|
|
1279
1551
|
}
|
|
1280
1552
|
}
|
|
@@ -1311,7 +1583,7 @@ const printSummaryErrorLogs = async ({ testResults, results, rootPath, unhandled
|
|
|
1311
1583
|
for (const test of failedTests){
|
|
1312
1584
|
const relativePath = posix.relative(rootPath, test.testPath);
|
|
1313
1585
|
const nameStr = getTaskNameWithPrefix(test);
|
|
1314
|
-
logger_logger.stderr(`${bgColor('bgRed', ' FAIL ')} ${prettyTestPath(relativePath)} ${nameStr.length ? `${logger_color.dim(
|
|
1586
|
+
logger_logger.stderr(`${bgColor('bgRed', ' FAIL ')} ${prettyTestPath(relativePath)} ${nameStr.length ? `${logger_color.dim(TEST_DELIMITER)} ${nameStr}` : ''}`);
|
|
1315
1587
|
if (test.errors) {
|
|
1316
1588
|
const { printError } = await Promise.resolve(error_namespaceObject);
|
|
1317
1589
|
for (const error of test.errors)await printError(error, getSourcemap, rootPath);
|
|
@@ -1468,7 +1740,7 @@ class StatusRenderer {
|
|
|
1468
1740
|
const relativePath = relative(this.rootPath, module);
|
|
1469
1741
|
summary.push(`${bgColor('bgYellow', ' RUNS ')} ${prettyTestPath(relativePath)}`);
|
|
1470
1742
|
if (runningTests.length && shouldDisplayRunningTests(runningTests)) {
|
|
1471
|
-
let caseLog = ` ${logger_color.gray(
|
|
1743
|
+
let caseLog = ` ${logger_color.gray(POINTER)} ${getTaskNameWithPrefix(runningTests[0])} ${logger_color.magenta(prettyTime(now - runningTests[0].startTime))}`;
|
|
1472
1744
|
if (runningTests.length > 1) caseLog += logger_color.gray(` and ${runningTests.length - 1} more cases`);
|
|
1473
1745
|
summary.push(caseLog);
|
|
1474
1746
|
}
|
|
@@ -1631,7 +1903,7 @@ class BlobReporter {
|
|
|
1631
1903
|
const shard = this.config.shard;
|
|
1632
1904
|
const fileName = shard ? `blob-${shard.index}-${shard.count}.json` : 'blob.json';
|
|
1633
1905
|
const blobData = {
|
|
1634
|
-
version: "0.9.
|
|
1906
|
+
version: "0.9.6",
|
|
1635
1907
|
shard: shard ? {
|
|
1636
1908
|
index: shard.index,
|
|
1637
1909
|
count: shard.count
|
|
@@ -1675,7 +1947,7 @@ class GithubActionsReporter {
|
|
|
1675
1947
|
const { testPath } = test;
|
|
1676
1948
|
const nameStr = getTaskNameWithPrefix(test);
|
|
1677
1949
|
const shortPath = relative(this.rootPath, testPath);
|
|
1678
|
-
const title = `${shortPath}
|
|
1950
|
+
const title = `${shortPath} ${TEST_DELIMITER} ${nameStr}`;
|
|
1679
1951
|
for (const error of test.errors || []){
|
|
1680
1952
|
let file = testPath;
|
|
1681
1953
|
let line = 1;
|
|
@@ -1705,6 +1977,95 @@ class GithubActionsReporter {
|
|
|
1705
1977
|
function escapeData(s) {
|
|
1706
1978
|
return s.replace(/%/g, '%25').replace(/\r/g, '%0D').replace(/\n/g, '%0A').replace(/:/g, '%3A').replace(/,/g, '%2C');
|
|
1707
1979
|
}
|
|
1980
|
+
class JsonReporter {
|
|
1981
|
+
config;
|
|
1982
|
+
rootPath;
|
|
1983
|
+
outputPath;
|
|
1984
|
+
consoleLogs = [];
|
|
1985
|
+
constructor({ config, rootPath, options }){
|
|
1986
|
+
this.config = config;
|
|
1987
|
+
this.rootPath = rootPath;
|
|
1988
|
+
this.outputPath = options?.outputPath;
|
|
1989
|
+
}
|
|
1990
|
+
onUserConsoleLog(log) {
|
|
1991
|
+
this.consoleLogs.push(log);
|
|
1992
|
+
}
|
|
1993
|
+
normalizeTest(test) {
|
|
1994
|
+
return {
|
|
1995
|
+
...test,
|
|
1996
|
+
testPath: relative(this.rootPath, test.testPath),
|
|
1997
|
+
fullName: getTaskNameWithPrefix(test)
|
|
1998
|
+
};
|
|
1999
|
+
}
|
|
2000
|
+
createReport({ results, testResults, duration, snapshotSummary, unhandledErrors }) {
|
|
2001
|
+
const failedTests = testResults.filter((result)=>'fail' === result.status);
|
|
2002
|
+
const passedTests = testResults.filter((result)=>'pass' === result.status);
|
|
2003
|
+
const skippedTests = testResults.filter((result)=>'skip' === result.status);
|
|
2004
|
+
const todoTests = testResults.filter((result)=>'todo' === result.status);
|
|
2005
|
+
const failedFiles = results.filter((result)=>'fail' === result.status);
|
|
2006
|
+
const noTestsDiscovered = 0 === results.length && 0 === testResults.length;
|
|
2007
|
+
const hasFailedStatus = failedTests.length > 0 || failedFiles.length > 0 || (unhandledErrors?.length ?? 0) > 0 || noTestsDiscovered && !this.config.passWithNoTests;
|
|
2008
|
+
return {
|
|
2009
|
+
tool: 'rstest',
|
|
2010
|
+
version: "0.9.6",
|
|
2011
|
+
status: hasFailedStatus ? 'fail' : 'pass',
|
|
2012
|
+
summary: {
|
|
2013
|
+
testFiles: results.length,
|
|
2014
|
+
failedFiles: failedFiles.length,
|
|
2015
|
+
tests: testResults.length,
|
|
2016
|
+
failedTests: failedTests.length,
|
|
2017
|
+
passedTests: passedTests.length,
|
|
2018
|
+
skippedTests: skippedTests.length,
|
|
2019
|
+
todoTests: todoTests.length
|
|
2020
|
+
},
|
|
2021
|
+
durationMs: {
|
|
2022
|
+
total: duration.totalTime,
|
|
2023
|
+
build: duration.buildTime,
|
|
2024
|
+
tests: duration.testTime
|
|
2025
|
+
},
|
|
2026
|
+
snapshot: snapshotSummary,
|
|
2027
|
+
files: results.map((fileResult)=>({
|
|
2028
|
+
...fileResult,
|
|
2029
|
+
testPath: relative(this.rootPath, fileResult.testPath),
|
|
2030
|
+
fullName: getTaskNameWithPrefix(fileResult),
|
|
2031
|
+
results: fileResult.results.map((test)=>this.normalizeTest(test))
|
|
2032
|
+
})),
|
|
2033
|
+
tests: testResults.map((test)=>this.normalizeTest(test)),
|
|
2034
|
+
consoleLogs: this.consoleLogs.length > 0 ? this.consoleLogs.map((log)=>({
|
|
2035
|
+
...log,
|
|
2036
|
+
testPath: relative(this.rootPath, log.testPath)
|
|
2037
|
+
})) : void 0,
|
|
2038
|
+
unhandledErrors: unhandledErrors?.map((error)=>({
|
|
2039
|
+
message: error.message,
|
|
2040
|
+
stack: error.stack,
|
|
2041
|
+
name: error.name
|
|
2042
|
+
}))
|
|
2043
|
+
};
|
|
2044
|
+
}
|
|
2045
|
+
async writeReport(content) {
|
|
2046
|
+
if (!this.outputPath) return void logger_logger.log(content);
|
|
2047
|
+
try {
|
|
2048
|
+
await promises.mkdir(node_path.dirname(this.outputPath), {
|
|
2049
|
+
recursive: true
|
|
2050
|
+
});
|
|
2051
|
+
await promises.writeFile(this.outputPath, content, 'utf-8');
|
|
2052
|
+
logger_logger.log(`JSON report written to: ${this.outputPath}`);
|
|
2053
|
+
} catch (error) {
|
|
2054
|
+
logger_logger.stderr(`Failed to write JSON report to ${this.outputPath}:`, error);
|
|
2055
|
+
logger_logger.log(content);
|
|
2056
|
+
}
|
|
2057
|
+
}
|
|
2058
|
+
async onTestRunEnd({ results, testResults, duration, snapshotSummary, unhandledErrors }) {
|
|
2059
|
+
const report = this.createReport({
|
|
2060
|
+
results,
|
|
2061
|
+
testResults,
|
|
2062
|
+
duration,
|
|
2063
|
+
snapshotSummary,
|
|
2064
|
+
unhandledErrors
|
|
2065
|
+
});
|
|
2066
|
+
await this.writeReport(`${JSON.stringify(report, null, 2)}\n`);
|
|
2067
|
+
}
|
|
2068
|
+
}
|
|
1708
2069
|
function ansiRegex({ onlyFirst = false } = {}) {
|
|
1709
2070
|
const ST = '(?:\\u0007|\\u001B\\u005C|\\u009C)';
|
|
1710
2071
|
const osc = `(?:\\u001B\\][\\s\\S]*?${ST})`;
|
|
@@ -2022,7 +2383,7 @@ function traceSegmentInternal(segments, memo, line, column, bias) {
|
|
|
2022
2383
|
const isRelativePath = (p)=>/^\.\.?\//.test(p);
|
|
2023
2384
|
const isHttpLikeFile = (file)=>/^https?:\/\//.test(file);
|
|
2024
2385
|
const hintNotDefinedError = (message)=>{
|
|
2025
|
-
const [, varName] =
|
|
2386
|
+
const [, varName] = /(\w+) is not defined/.exec(message) || [];
|
|
2026
2387
|
if (varName) {
|
|
2027
2388
|
if (globalApis.includes(varName)) return message.replace(`${varName} is not defined`, `${varName} is not defined. Did you forget to enable "globals" configuration?`);
|
|
2028
2389
|
if ([
|
|
@@ -2067,7 +2428,7 @@ async function printCodeFrame(frame) {
|
|
|
2067
2428
|
if (!filePath) return;
|
|
2068
2429
|
const source = node_fs.existsSync(filePath) ? node_fs.readFileSync(filePath, 'utf-8') : void 0;
|
|
2069
2430
|
if (!source) return;
|
|
2070
|
-
const { codeFrameColumns } = await import("./0
|
|
2431
|
+
const { codeFrameColumns } = await import("./0~@babel/code-frame.js").then(__webpack_require__.bind(__webpack_require__, "../../node_modules/.pnpm/@babel+code-frame@7.29.0/node_modules/@babel/code-frame/lib/index.js"));
|
|
2071
2432
|
const result = codeFrameColumns(source, {
|
|
2072
2433
|
start: {
|
|
2073
2434
|
line: frame.lineNumber,
|
|
@@ -2101,10 +2462,15 @@ const stackIgnores = [
|
|
|
2101
2462
|
'<anonymous>'
|
|
2102
2463
|
];
|
|
2103
2464
|
async function error_parseErrorStacktrace({ stack, getSourcemap, fullStack = isDebug() }) {
|
|
2465
|
+
const traceMapCache = new Map();
|
|
2104
2466
|
const stackFrames = await Promise.all(stack_trace_parser_esm_parse(stack).filter((frame)=>fullStack ? true : frame.file && !stackIgnores.some((entry)=>frame.file?.match(entry))).map(async (frame)=>{
|
|
2105
2467
|
const sourcemap = await getSourcemap?.(frame.file);
|
|
2106
2468
|
if (sourcemap) {
|
|
2107
|
-
|
|
2469
|
+
let traceMap = traceMapCache.get(frame.file);
|
|
2470
|
+
if (!traceMap) {
|
|
2471
|
+
traceMap = new TraceMap(sourcemap);
|
|
2472
|
+
traceMapCache.set(frame.file, traceMap);
|
|
2473
|
+
}
|
|
2108
2474
|
const { line, column, source, name } = originalPositionFor(traceMap, {
|
|
2109
2475
|
line: frame.lineNumber,
|
|
2110
2476
|
column: frame.column
|
|
@@ -2995,7 +3361,7 @@ const formatFailureListValue = (value)=>{
|
|
|
2995
3361
|
};
|
|
2996
3362
|
const getErrorType = (error)=>{
|
|
2997
3363
|
const rawName = error.name || 'Error';
|
|
2998
|
-
if (
|
|
3364
|
+
if (rawName.includes('AssertionError')) return 'AssertionError';
|
|
2999
3365
|
if (/\bSnapshot\b.*\bmismatched\b/i.test(error.message)) return 'SnapshotMismatchError';
|
|
3000
3366
|
return rawName;
|
|
3001
3367
|
};
|
|
@@ -3183,6 +3549,7 @@ const excludedRoots = (()=>{
|
|
|
3183
3549
|
return resolvedRoots;
|
|
3184
3550
|
})();
|
|
3185
3551
|
const md_parseErrorStacktrace = async ({ stack, getSourcemap, fullStack = false })=>{
|
|
3552
|
+
const traceMapCache = new Map();
|
|
3186
3553
|
const frames = stack_trace_parser_esm_parse(stack).filter((frame)=>{
|
|
3187
3554
|
if (fullStack) return true;
|
|
3188
3555
|
if (!frame.file) return false;
|
|
@@ -3200,7 +3567,11 @@ const md_parseErrorStacktrace = async ({ stack, getSourcemap, fullStack = false
|
|
|
3200
3567
|
...frame,
|
|
3201
3568
|
file
|
|
3202
3569
|
};
|
|
3203
|
-
|
|
3570
|
+
let traceMap = traceMapCache.get(file);
|
|
3571
|
+
if (!traceMap) {
|
|
3572
|
+
traceMap = new TraceMap(sourcemap);
|
|
3573
|
+
traceMapCache.set(file, traceMap);
|
|
3574
|
+
}
|
|
3204
3575
|
const { line, column, source, name } = originalPositionFor(traceMap, {
|
|
3205
3576
|
line: frame.lineNumber || 1,
|
|
3206
3577
|
column: frame.column || 1
|
|
@@ -3289,7 +3660,7 @@ class MdReporter {
|
|
|
3289
3660
|
}
|
|
3290
3661
|
renderFrontMatter(lines) {
|
|
3291
3662
|
const frontMatter = {
|
|
3292
|
-
tool: "@rstest/core@0.9.
|
|
3663
|
+
tool: "@rstest/core@0.9.6",
|
|
3293
3664
|
timestamp: new Date().toISOString()
|
|
3294
3665
|
};
|
|
3295
3666
|
if (this.options.header.env) frontMatter.runtime = {
|
|
@@ -3433,10 +3804,10 @@ class MdReporter {
|
|
|
3433
3804
|
getSourcemap,
|
|
3434
3805
|
fullStack: false
|
|
3435
3806
|
}) : [];
|
|
3436
|
-
const fullFrames = error.stack ? await md_parseErrorStacktrace({
|
|
3807
|
+
const fullFrames = error.fullStack && error.stack ? await md_parseErrorStacktrace({
|
|
3437
3808
|
stack: error.stack,
|
|
3438
3809
|
getSourcemap,
|
|
3439
|
-
fullStack:
|
|
3810
|
+
fullStack: true
|
|
3440
3811
|
}) : candidateFrames;
|
|
3441
3812
|
const trimmedFrames = resolveStackFrames(fullFrames, this.options);
|
|
3442
3813
|
const topFrame = fullFrames[0] ?? candidateFrames[0];
|
|
@@ -3663,7 +4034,7 @@ class Rstest {
|
|
|
3663
4034
|
updateSnapshot: rstestConfig.update ? 'all' : dist_m ? 'none' : 'new'
|
|
3664
4035
|
});
|
|
3665
4036
|
this.snapshotManager = snapshotManager;
|
|
3666
|
-
this.version = "0.9.
|
|
4037
|
+
this.version = "0.9.6";
|
|
3667
4038
|
this.rootPath = rootPath;
|
|
3668
4039
|
this.originalConfig = userConfig;
|
|
3669
4040
|
this.normalizedConfig = rstestConfig;
|
|
@@ -3743,6 +4114,7 @@ const reportersMap = {
|
|
|
3743
4114
|
verbose: VerboseReporter,
|
|
3744
4115
|
'github-actions': GithubActionsReporter,
|
|
3745
4116
|
junit: JUnitReporter,
|
|
4117
|
+
json: JsonReporter,
|
|
3746
4118
|
md: MdReporter,
|
|
3747
4119
|
blob: BlobReporter
|
|
3748
4120
|
};
|
|
@@ -3799,7 +4171,10 @@ function core_createRstest({ config, projects, configFilePath }, command, fileFi
|
|
|
3799
4171
|
function defineConfig(config) {
|
|
3800
4172
|
return config;
|
|
3801
4173
|
}
|
|
4174
|
+
function defineInlineProject(config) {
|
|
4175
|
+
return config;
|
|
4176
|
+
}
|
|
3802
4177
|
function defineProject(config) {
|
|
3803
4178
|
return config;
|
|
3804
4179
|
}
|
|
3805
|
-
export { config_loadConfig as loadConfig, core_createRstest as createRstest, core_namespaceObject, defineConfig, defineProject, detect, error_parseErrorStacktrace as parseErrorStacktrace, error_printError as printError, formatStack, init_initCli as initCli, init_namespaceObject, mergeProjectConfig, mergeRstestConfig, resolveCommand, runCLI, runRest };
|
|
4180
|
+
export { config_loadConfig as loadConfig, core_createRstest as createRstest, core_namespaceObject, defineConfig, defineInlineProject, defineProject, detect, error_parseErrorStacktrace as parseErrorStacktrace, error_printError as printError, formatStack, init_initCli as initCli, init_namespaceObject, mergeProjectConfig, mergeRstestConfig, resolveCommand, runCLI, runRest };
|