@rstest/core 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{359.js → 12.js} +156 -94
- package/dist/{72.js → 171.js} +2 -1
- package/dist/223.js +135 -0
- package/dist/{920.js → 33.js} +125 -81
- package/dist/{44.js → 350.js} +6 -5
- package/dist/{813.js → 607.js} +16 -15
- package/dist/{208.js → 655.js} +60 -59
- package/dist/{355.js → 704.js} +17 -16
- package/dist/{965.js → 711.js} +6 -5
- package/dist/{443.js → 755.js} +2 -1
- package/dist/{723.js → 829.js} +5 -4
- package/dist/{867.js → 85.js} +140 -67
- package/dist/{668.js → 928.js} +3 -2
- package/dist/{25.js → 967.js} +19 -14
- package/dist/{64.js → 969.js} +2 -1
- package/dist/{285.js → 971.js} +66 -33
- package/dist/{854.js → 985.js} +153 -81
- package/dist/index.js +93 -121
- package/dist/worker.js +45 -38
- package/dist-types/index.d.ts +55 -3
- package/dist-types/worker.d.ts +124 -4
- package/globals.d.ts +2 -0
- package/package.json +6 -6
- /package/dist/{208.js.LICENSE.txt → 655.js.LICENSE.txt} +0 -0
- /package/dist/{668.js.LICENSE.txt → 928.js.LICENSE.txt} +0 -0
package/dist/index.js
CHANGED
|
@@ -2181,8 +2181,8 @@ var __webpack_modules__ = {
|
|
|
2181
2181
|
},
|
|
2182
2182
|
"./src/cli/commands.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
2183
2183
|
__webpack_require__.d(__webpack_exports__, {
|
|
2184
|
-
|
|
2185
|
-
|
|
2184
|
+
a: ()=>runRest,
|
|
2185
|
+
Q: ()=>setupCommands
|
|
2186
2186
|
});
|
|
2187
2187
|
var external_events_ = __webpack_require__("events");
|
|
2188
2188
|
function toArr(any) {
|
|
@@ -2671,7 +2671,6 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
2671
2671
|
const cac = (name = "")=>new CAC(name);
|
|
2672
2672
|
const dist = cac;
|
|
2673
2673
|
var external_pathe_ = __webpack_require__("pathe");
|
|
2674
|
-
var src_config = __webpack_require__("./src/config.ts");
|
|
2675
2674
|
var helper = __webpack_require__("./src/utils/helper.ts");
|
|
2676
2675
|
var logger = __webpack_require__("./src/utils/logger.ts");
|
|
2677
2676
|
var prepare = __webpack_require__("./src/cli/prepare.ts");
|
|
@@ -2680,55 +2679,19 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
2680
2679
|
default: 'jiti'
|
|
2681
2680
|
}).option('-r, --root <root>', 'Specify the project root directory, can be an absolute path or a path relative to cwd').option('--globals', 'Provide global APIs').option('--isolate', 'Run tests in an isolated environment').option('--include <include>', 'Match test files').option('--exclude <exclude>', 'Exclude files from test').option('-u, --update', 'Update snapshot files').option('--passWithNoTests', 'Allows the test suite to pass when no files are found').option('--printConsoleTrace', 'Print console traces when calling any console method').option('--disableConsoleIntercept', 'Disable console intercept').option('--slowTestThreshold <value>', 'The number of milliseconds after which a test or suite is considered slow').option('--reporter <reporter>', 'Specify the reporter to use').option('-t, --testNamePattern <value>', 'Run only tests with a name that matches the regex').option('--testEnvironment <name>', 'The environment that will be used for testing').option('--testTimeout <value>', 'Timeout of a test in milliseconds').option('--hookTimeout <value>', 'Timeout of hook in milliseconds').option('--retry <retry>', 'Number of times to retry a test if it fails').option('--maxConcurrency <value>', 'Maximum number of concurrent tests').option('--clearMocks', 'Automatically clear mock calls, instances, contexts and results before every test').option('--resetMocks', 'Automatically reset mock state before every test').option('--restoreMocks', 'Automatically restore mock state and implementation before every test').option('--unstubGlobals', 'Restores all global variables that were changed with `rstest.stubGlobal` before every test').option('--unstubEnvs', 'Restores all `process.env` values that were changed with `rstest.stubEnv` before every test');
|
|
2682
2681
|
};
|
|
2683
|
-
async function initCli(options) {
|
|
2684
|
-
const cwd = process.cwd();
|
|
2685
|
-
const root = options.root ? (0, helper.ZY)(cwd, options.root) : cwd;
|
|
2686
|
-
const { content: config, filePath: configFilePath } = await (0, src_config.ME)({
|
|
2687
|
-
cwd: root,
|
|
2688
|
-
path: options.config,
|
|
2689
|
-
configLoader: options.configLoader
|
|
2690
|
-
});
|
|
2691
|
-
const keys = [
|
|
2692
|
-
'root',
|
|
2693
|
-
'globals',
|
|
2694
|
-
'isolate',
|
|
2695
|
-
'passWithNoTests',
|
|
2696
|
-
'update',
|
|
2697
|
-
'testNamePattern',
|
|
2698
|
-
'testTimeout',
|
|
2699
|
-
'hookTimeout',
|
|
2700
|
-
'clearMocks',
|
|
2701
|
-
'resetMocks',
|
|
2702
|
-
'restoreMocks',
|
|
2703
|
-
'unstubEnvs',
|
|
2704
|
-
'unstubGlobals',
|
|
2705
|
-
'retry',
|
|
2706
|
-
'slowTestThreshold',
|
|
2707
|
-
'maxConcurrency',
|
|
2708
|
-
'printConsoleTrace',
|
|
2709
|
-
'disableConsoleIntercept',
|
|
2710
|
-
'testEnvironment'
|
|
2711
|
-
];
|
|
2712
|
-
for (const key of keys)if (void 0 !== options[key]) config[key] = options[key];
|
|
2713
|
-
if (options.exclude) config.exclude = (0, helper.XQ)(options.exclude);
|
|
2714
|
-
if (options.reporter) config.reporters = (0, helper.XQ)(options.reporter);
|
|
2715
|
-
if (options.include) config.include = (0, helper.XQ)(options.include);
|
|
2716
|
-
return {
|
|
2717
|
-
config,
|
|
2718
|
-
configFilePath: configFilePath ?? void 0
|
|
2719
|
-
};
|
|
2720
|
-
}
|
|
2721
2682
|
const runRest = async ({ options, filters, command })=>{
|
|
2722
2683
|
let rstest;
|
|
2723
2684
|
try {
|
|
2724
|
-
const {
|
|
2725
|
-
const {
|
|
2685
|
+
const { initCli } = await __webpack_require__.e("223").then(__webpack_require__.bind(__webpack_require__, "./src/cli/init.ts"));
|
|
2686
|
+
const { config, configFilePath, projects } = await initCli(options);
|
|
2687
|
+
const { createRstest } = await __webpack_require__.e("12").then(__webpack_require__.bind(__webpack_require__, "./src/core/index.ts"));
|
|
2726
2688
|
rstest = createRstest({
|
|
2727
2689
|
config,
|
|
2728
|
-
configFilePath
|
|
2690
|
+
configFilePath,
|
|
2691
|
+
projects
|
|
2729
2692
|
}, command, filters.map(external_pathe_.normalize));
|
|
2730
2693
|
if ('watch' === command && configFilePath) {
|
|
2731
|
-
const { watchFilesForRestart } = await __webpack_require__.e("
|
|
2694
|
+
const { watchFilesForRestart } = await __webpack_require__.e("967").then(__webpack_require__.bind(__webpack_require__, "./src/core/restart.ts"));
|
|
2732
2695
|
watchFilesForRestart({
|
|
2733
2696
|
rstest,
|
|
2734
2697
|
options,
|
|
@@ -2738,18 +2701,18 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
2738
2701
|
await rstest.runTests();
|
|
2739
2702
|
} catch (err) {
|
|
2740
2703
|
for (const reporter of rstest?.context.reporters || [])reporter.onExit?.();
|
|
2741
|
-
logger.
|
|
2742
|
-
logger.
|
|
2704
|
+
logger.vF.error('Failed to run Rstest.');
|
|
2705
|
+
logger.vF.error((0, helper.Wk)(err));
|
|
2743
2706
|
process.exit(1);
|
|
2744
2707
|
}
|
|
2745
2708
|
};
|
|
2746
2709
|
function setupCommands() {
|
|
2747
2710
|
const cli = dist('rstest');
|
|
2748
2711
|
cli.help();
|
|
2749
|
-
cli.version("0.
|
|
2712
|
+
cli.version("0.3.0");
|
|
2750
2713
|
applyCommonOptions(cli);
|
|
2751
|
-
cli.command('[...filters]', 'run tests').option('--watch', 'Run tests in watch mode').action(async (filters, options)=>{
|
|
2752
|
-
(0, prepare.
|
|
2714
|
+
cli.command('[...filters]', 'run tests').option('-w, --watch', 'Run tests in watch mode').action(async (filters, options)=>{
|
|
2715
|
+
(0, prepare.N)();
|
|
2753
2716
|
if (options.watch) await runRest({
|
|
2754
2717
|
options,
|
|
2755
2718
|
filters,
|
|
@@ -2762,7 +2725,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
2762
2725
|
});
|
|
2763
2726
|
});
|
|
2764
2727
|
cli.command('run [...filters]', 'run tests without watch mode').action(async (filters, options)=>{
|
|
2765
|
-
(0, prepare.
|
|
2728
|
+
(0, prepare.N)();
|
|
2766
2729
|
await runRest({
|
|
2767
2730
|
options,
|
|
2768
2731
|
filters,
|
|
@@ -2770,7 +2733,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
2770
2733
|
});
|
|
2771
2734
|
});
|
|
2772
2735
|
cli.command('watch [...filters]', 'run tests in watch mode').action(async (filters, options)=>{
|
|
2773
|
-
(0, prepare.
|
|
2736
|
+
(0, prepare.N)();
|
|
2774
2737
|
await runRest({
|
|
2775
2738
|
options,
|
|
2776
2739
|
filters,
|
|
@@ -2779,19 +2742,21 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
2779
2742
|
});
|
|
2780
2743
|
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)=>{
|
|
2781
2744
|
try {
|
|
2782
|
-
const {
|
|
2783
|
-
const {
|
|
2745
|
+
const { initCli } = await __webpack_require__.e("223").then(__webpack_require__.bind(__webpack_require__, "./src/cli/init.ts"));
|
|
2746
|
+
const { config, configFilePath, projects } = await initCli(options);
|
|
2747
|
+
const { createRstest } = await __webpack_require__.e("12").then(__webpack_require__.bind(__webpack_require__, "./src/core/index.ts"));
|
|
2784
2748
|
const rstest = createRstest({
|
|
2785
2749
|
config,
|
|
2786
|
-
configFilePath
|
|
2750
|
+
configFilePath,
|
|
2751
|
+
projects
|
|
2787
2752
|
}, 'list', filters.map(external_pathe_.normalize));
|
|
2788
2753
|
await rstest.listTests({
|
|
2789
2754
|
filesOnly: options.filesOnly,
|
|
2790
2755
|
json: options.json
|
|
2791
2756
|
});
|
|
2792
2757
|
} catch (err) {
|
|
2793
|
-
logger.
|
|
2794
|
-
logger.
|
|
2758
|
+
logger.vF.error('Failed to run Rstest list.');
|
|
2759
|
+
logger.vF.error((0, helper.Wk)(err));
|
|
2795
2760
|
process.exit(1);
|
|
2796
2761
|
}
|
|
2797
2762
|
});
|
|
@@ -2800,8 +2765,8 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
2800
2765
|
},
|
|
2801
2766
|
"./src/cli/prepare.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
2802
2767
|
__webpack_require__.d(__webpack_exports__, {
|
|
2803
|
-
|
|
2804
|
-
|
|
2768
|
+
N: ()=>showRstest,
|
|
2769
|
+
k: ()=>prepareCli
|
|
2805
2770
|
});
|
|
2806
2771
|
var _utils_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./src/utils/logger.ts");
|
|
2807
2772
|
function initNodeEnv() {
|
|
@@ -2814,35 +2779,35 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
2814
2779
|
if (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) console.log();
|
|
2815
2780
|
}
|
|
2816
2781
|
function showRstest() {
|
|
2817
|
-
_utils_logger__WEBPACK_IMPORTED_MODULE_0__.
|
|
2818
|
-
_utils_logger__WEBPACK_IMPORTED_MODULE_0__.
|
|
2782
|
+
_utils_logger__WEBPACK_IMPORTED_MODULE_0__.vF.greet(" Rstest v0.3.0");
|
|
2783
|
+
_utils_logger__WEBPACK_IMPORTED_MODULE_0__.vF.log('');
|
|
2819
2784
|
}
|
|
2820
2785
|
},
|
|
2821
2786
|
"./src/config.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
2822
2787
|
__webpack_require__.d(__webpack_exports__, {
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2788
|
+
ST: ()=>mergeRstestConfig,
|
|
2789
|
+
Z9: ()=>loadConfig,
|
|
2790
|
+
wX: ()=>withDefaultConfig
|
|
2826
2791
|
});
|
|
2827
2792
|
var node_fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("node:fs");
|
|
2828
2793
|
var _rsbuild_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("@rsbuild/core");
|
|
2829
2794
|
var pathe__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("pathe");
|
|
2830
2795
|
var _utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./src/utils/index.ts");
|
|
2831
|
-
const findConfig = (basePath)=>_utils__WEBPACK_IMPORTED_MODULE_3__.
|
|
2796
|
+
const findConfig = (basePath)=>_utils__WEBPACK_IMPORTED_MODULE_3__.kv.map((ext)=>basePath + ext).find(node_fs__WEBPACK_IMPORTED_MODULE_0__["default"].existsSync);
|
|
2832
2797
|
const resolveConfigPath = (root, customConfig)=>{
|
|
2833
2798
|
if (customConfig) {
|
|
2834
2799
|
const customConfigPath = (0, pathe__WEBPACK_IMPORTED_MODULE_2__.isAbsolute)(customConfig) ? customConfig : (0, pathe__WEBPACK_IMPORTED_MODULE_2__.join)(root, customConfig);
|
|
2835
2800
|
if (node_fs__WEBPACK_IMPORTED_MODULE_0__["default"].existsSync(customConfigPath)) return customConfigPath;
|
|
2836
|
-
throw `Cannot find config file: ${_utils__WEBPACK_IMPORTED_MODULE_3__
|
|
2801
|
+
throw `Cannot find config file: ${_utils__WEBPACK_IMPORTED_MODULE_3__.yW.dim(customConfigPath)}`;
|
|
2837
2802
|
}
|
|
2838
|
-
const configFilePath = findConfig((0, pathe__WEBPACK_IMPORTED_MODULE_2__.join)(root, _utils__WEBPACK_IMPORTED_MODULE_3__.
|
|
2803
|
+
const configFilePath = findConfig((0, pathe__WEBPACK_IMPORTED_MODULE_2__.join)(root, _utils__WEBPACK_IMPORTED_MODULE_3__.t));
|
|
2839
2804
|
if (configFilePath) return configFilePath;
|
|
2840
2805
|
return null;
|
|
2841
2806
|
};
|
|
2842
2807
|
async function loadConfig({ cwd = process.cwd(), path, envMode, configLoader }) {
|
|
2843
2808
|
const configFilePath = resolveConfigPath(cwd, path);
|
|
2844
2809
|
if (!configFilePath) {
|
|
2845
|
-
_utils__WEBPACK_IMPORTED_MODULE_3__.
|
|
2810
|
+
_utils__WEBPACK_IMPORTED_MODULE_3__.vF.debug('no rstest config file found');
|
|
2846
2811
|
return {
|
|
2847
2812
|
content: {},
|
|
2848
2813
|
filePath: configFilePath
|
|
@@ -2903,7 +2868,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
2903
2868
|
const merged = mergeRstestConfig(createDefaultConfig(), config);
|
|
2904
2869
|
merged.include = config.include || merged.include;
|
|
2905
2870
|
merged.exclude = (config.exclude || merged.exclude || []).concat([
|
|
2906
|
-
_utils__WEBPACK_IMPORTED_MODULE_3__.
|
|
2871
|
+
_utils__WEBPACK_IMPORTED_MODULE_3__.EJ
|
|
2907
2872
|
]);
|
|
2908
2873
|
merged.reporters = config.reporters ?? merged.reporters;
|
|
2909
2874
|
merged.pool = 'string' == typeof config.pool ? {
|
|
@@ -2914,11 +2879,11 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
2914
2879
|
},
|
|
2915
2880
|
"./src/utils/constants.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
2916
2881
|
__webpack_require__.d(__webpack_exports__, {
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2882
|
+
EJ: ()=>TEMP_RSTEST_OUTPUT_DIR_GLOB,
|
|
2883
|
+
kv: ()=>DEFAULT_CONFIG_EXTENSIONS,
|
|
2884
|
+
t: ()=>DEFAULT_CONFIG_NAME,
|
|
2885
|
+
vO: ()=>TEST_DELIMITER,
|
|
2886
|
+
zZ: ()=>TEMP_RSTEST_OUTPUT_DIR
|
|
2922
2887
|
});
|
|
2923
2888
|
const DEFAULT_CONFIG_NAME = 'rstest.config';
|
|
2924
2889
|
const TEST_DELIMITER = '>';
|
|
@@ -2935,17 +2900,17 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
2935
2900
|
},
|
|
2936
2901
|
"./src/utils/helper.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
2937
2902
|
__webpack_require__.d(__webpack_exports__, {
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2903
|
+
C3: ()=>needFlagExperimentalDetectModule,
|
|
2904
|
+
FI: ()=>getAbsolutePath,
|
|
2905
|
+
Kv: ()=>NODE_BUILTINS,
|
|
2906
|
+
Ok: ()=>serializableConfig,
|
|
2907
|
+
P2: ()=>parsePosix,
|
|
2908
|
+
Un: ()=>isTTY,
|
|
2909
|
+
Wk: ()=>formatError,
|
|
2910
|
+
bg: ()=>castArray,
|
|
2911
|
+
fN: ()=>getTaskNameWithPrefix,
|
|
2912
|
+
kV: ()=>prettyTime,
|
|
2913
|
+
yW: ()=>picocolors__WEBPACK_IMPORTED_MODULE_2___default.a
|
|
2949
2914
|
});
|
|
2950
2915
|
var pathe__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("pathe");
|
|
2951
2916
|
var picocolors__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
@@ -2997,7 +2962,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
2997
2962
|
return time;
|
|
2998
2963
|
};
|
|
2999
2964
|
const getTaskNames = (test)=>(test.parentNames || []).concat(test.name).filter(Boolean);
|
|
3000
|
-
const getTaskNameWithPrefix = (test, delimiter = _constants__WEBPACK_IMPORTED_MODULE_1__.
|
|
2965
|
+
const getTaskNameWithPrefix = (test, delimiter = _constants__WEBPACK_IMPORTED_MODULE_1__.vO)=>getTaskNames(test).join(` ${delimiter} `);
|
|
3001
2966
|
const REGEXP_FLAG_PREFIX = 'RSTEST_REGEXP:';
|
|
3002
2967
|
const wrapRegex = (value)=>`${REGEXP_FLAG_PREFIX}${value.toString()}`;
|
|
3003
2968
|
const serializableConfig = (normalizedConfig)=>{
|
|
@@ -3090,25 +3055,27 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
3090
3055
|
},
|
|
3091
3056
|
"./src/utils/index.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
3092
3057
|
__webpack_require__.d(__webpack_exports__, {
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3058
|
+
C3: ()=>helper.C3,
|
|
3059
|
+
Ok: ()=>helper.Ok,
|
|
3060
|
+
XJ: ()=>formatTestPath,
|
|
3061
|
+
zZ: ()=>constants.zZ,
|
|
3062
|
+
fN: ()=>helper.fN,
|
|
3063
|
+
vF: ()=>logger.vF,
|
|
3064
|
+
vO: ()=>constants.vO,
|
|
3065
|
+
tG: ()=>getTestEntries,
|
|
3066
|
+
FI: ()=>helper.FI,
|
|
3067
|
+
kv: ()=>constants.kv,
|
|
3068
|
+
yW: ()=>helper.yW,
|
|
3069
|
+
EQ: ()=>prettyTestPath,
|
|
3070
|
+
_o: ()=>logger._o,
|
|
3071
|
+
pr: ()=>getSetupFiles,
|
|
3072
|
+
Kv: ()=>helper.Kv,
|
|
3073
|
+
mT: ()=>logger.mT,
|
|
3074
|
+
t: ()=>constants.t,
|
|
3075
|
+
kV: ()=>helper.kV,
|
|
3076
|
+
EJ: ()=>constants.EJ,
|
|
3077
|
+
bg: ()=>helper.bg,
|
|
3078
|
+
Un: ()=>helper.Un
|
|
3112
3079
|
});
|
|
3113
3080
|
var constants = __webpack_require__("./src/utils/constants.ts");
|
|
3114
3081
|
var helper = __webpack_require__("./src/utils/helper.ts");
|
|
@@ -3177,12 +3144,12 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
3177
3144
|
return;
|
|
3178
3145
|
}
|
|
3179
3146
|
};
|
|
3180
|
-
const getSetupFiles = (setups, rootPath)=>Object.fromEntries((0, helper.
|
|
3181
|
-
const setupFilePath = (0, helper.
|
|
3147
|
+
const getSetupFiles = (setups, rootPath)=>Object.fromEntries((0, helper.bg)(setups).map((setupFile)=>{
|
|
3148
|
+
const setupFilePath = (0, helper.FI)(rootPath, setupFile);
|
|
3182
3149
|
try {
|
|
3183
3150
|
if (!(0, external_node_fs_.existsSync)(setupFilePath)) {
|
|
3184
|
-
let errorMessage = `Setup file ${helper
|
|
3185
|
-
if (setupFilePath !== setupFile) errorMessage += helper
|
|
3151
|
+
let errorMessage = `Setup file ${helper.yW.red(setupFile)} not found`;
|
|
3152
|
+
if (setupFilePath !== setupFile) errorMessage += helper.yW.gray(` (resolved path: ${setupFilePath})`);
|
|
3186
3153
|
throw errorMessage;
|
|
3187
3154
|
}
|
|
3188
3155
|
const relativePath = external_pathe_["default"].relative(rootPath, setupFilePath);
|
|
@@ -3199,8 +3166,8 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
3199
3166
|
}
|
|
3200
3167
|
}));
|
|
3201
3168
|
const prettyTestPath = (testPath)=>{
|
|
3202
|
-
const { dir, base } = (0, helper.
|
|
3203
|
-
return `${'.' !== dir ? helper
|
|
3169
|
+
const { dir, base } = (0, helper.P2)(testPath);
|
|
3170
|
+
return `${'.' !== dir ? helper.yW.gray(`${dir}/`) : ''}${helper.yW.cyan(base)}`;
|
|
3204
3171
|
};
|
|
3205
3172
|
const formatTestPath = (root, testFilePath)=>{
|
|
3206
3173
|
let testPath = testFilePath;
|
|
@@ -3210,8 +3177,9 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
3210
3177
|
},
|
|
3211
3178
|
"./src/utils/logger.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
3212
3179
|
__webpack_require__.d(__webpack_exports__, {
|
|
3213
|
-
|
|
3214
|
-
|
|
3180
|
+
_o: ()=>isDebug,
|
|
3181
|
+
mT: ()=>clearScreen,
|
|
3182
|
+
vF: ()=>src_logger
|
|
3215
3183
|
});
|
|
3216
3184
|
var external_node_os_ = __webpack_require__("node:os");
|
|
3217
3185
|
var external_node_tty_ = __webpack_require__("node:tty");
|
|
@@ -3482,10 +3450,13 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
3482
3450
|
src_logger.override({
|
|
3483
3451
|
debug: (message, ...args)=>{
|
|
3484
3452
|
if ('verbose' !== src_logger.level) return;
|
|
3485
|
-
const time = helper
|
|
3486
|
-
console.log(` ${helper
|
|
3453
|
+
const time = helper.yW.gray(getTime());
|
|
3454
|
+
console.log(` ${helper.yW.magenta('rstest')} ${time} ${message}`, ...args);
|
|
3487
3455
|
}
|
|
3488
3456
|
});
|
|
3457
|
+
const clearScreen = (force = false)=>{
|
|
3458
|
+
if (!isDebug() || force) console.log('\x1Bc');
|
|
3459
|
+
};
|
|
3489
3460
|
},
|
|
3490
3461
|
"@rsbuild/core": function(module) {
|
|
3491
3462
|
module.exports = __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__;
|
|
@@ -3546,6 +3517,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
3546
3517
|
},
|
|
3547
3518
|
"../../node_modules/.pnpm/tinyglobby@0.2.14/node_modules/tinyglobby/dist/index.mjs": function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
3548
3519
|
__webpack_require__.d(__webpack_exports__, {
|
|
3520
|
+
ey: ()=>isDynamicPattern,
|
|
3549
3521
|
glob: ()=>glob
|
|
3550
3522
|
});
|
|
3551
3523
|
var path__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("node:path");
|
|
@@ -3825,7 +3797,7 @@ __webpack_require__.m = __webpack_modules__;
|
|
|
3825
3797
|
})();
|
|
3826
3798
|
(()=>{
|
|
3827
3799
|
var installedChunks = {
|
|
3828
|
-
|
|
3800
|
+
410: 0
|
|
3829
3801
|
};
|
|
3830
3802
|
var installChunk = (data)=>{
|
|
3831
3803
|
var __webpack_ids__ = data.__webpack_ids__;
|
|
@@ -3864,17 +3836,17 @@ var logger = __webpack_require__("./src/utils/logger.ts");
|
|
|
3864
3836
|
var commands = __webpack_require__("./src/cli/commands.ts");
|
|
3865
3837
|
var prepare = __webpack_require__("./src/cli/prepare.ts");
|
|
3866
3838
|
async function runCLI() {
|
|
3867
|
-
(0, prepare.
|
|
3839
|
+
(0, prepare.k)();
|
|
3868
3840
|
try {
|
|
3869
|
-
(0, commands.
|
|
3841
|
+
(0, commands.Q)();
|
|
3870
3842
|
} catch (err) {
|
|
3871
|
-
logger.
|
|
3872
|
-
logger.
|
|
3843
|
+
logger.vF.error('Failed to start Rstest CLI.');
|
|
3844
|
+
logger.vF.error(err);
|
|
3873
3845
|
}
|
|
3874
3846
|
}
|
|
3875
3847
|
var src_config = __webpack_require__("./src/config.ts");
|
|
3876
3848
|
function defineConfig(config) {
|
|
3877
3849
|
return config;
|
|
3878
3850
|
}
|
|
3879
|
-
var __webpack_exports__mergeRstestConfig = src_config.
|
|
3851
|
+
var __webpack_exports__mergeRstestConfig = src_config.ST;
|
|
3880
3852
|
export { defineConfig, runCLI, __webpack_exports__mergeRstestConfig as mergeRstestConfig };
|
package/dist/worker.js
CHANGED
|
@@ -4967,11 +4967,11 @@ var __webpack_modules__ = {
|
|
|
4967
4967
|
},
|
|
4968
4968
|
"./src/runtime/util.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
4969
4969
|
__webpack_require__.d(__webpack_exports__, {
|
|
4970
|
-
|
|
4971
|
-
|
|
4972
|
-
|
|
4973
|
-
|
|
4974
|
-
|
|
4970
|
+
zH: ()=>setRealTimers,
|
|
4971
|
+
nD: ()=>formatName,
|
|
4972
|
+
o9: ()=>formatTestError,
|
|
4973
|
+
si: ()=>TestRegisterError,
|
|
4974
|
+
rZ: ()=>getRealTimers
|
|
4975
4975
|
});
|
|
4976
4976
|
var external_node_util_ = __webpack_require__("node:util");
|
|
4977
4977
|
var build = __webpack_require__("../../node_modules/.pnpm/jest-diff@30.0.5/node_modules/jest-diff/build/index.js");
|
|
@@ -5002,7 +5002,9 @@ var __webpack_modules__ = {
|
|
|
5002
5002
|
stack: error.stack
|
|
5003
5003
|
};
|
|
5004
5004
|
if (error instanceof TestRegisterError && test?.type === 'case') errObj.message = `Can't nest describe or test inside a test. ${error.message} because it is nested within test '${test.name}'`;
|
|
5005
|
-
if (error.showDiff || void 0 === error.showDiff && void 0 !== error.expected && void 0 !== error.actual) errObj.diff = diff(err.expected, err.actual
|
|
5005
|
+
if (error.showDiff || void 0 === error.showDiff && void 0 !== error.expected && void 0 !== error.actual) errObj.diff = diff(err.expected, err.actual, {
|
|
5006
|
+
expand: false
|
|
5007
|
+
});
|
|
5006
5008
|
for (const key of [
|
|
5007
5009
|
'actual',
|
|
5008
5010
|
'expected'
|
|
@@ -5045,9 +5047,9 @@ var __webpack_modules__ = {
|
|
|
5045
5047
|
},
|
|
5046
5048
|
"./src/utils/constants.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
5047
5049
|
__webpack_require__.d(__webpack_exports__, {
|
|
5048
|
-
|
|
5049
|
-
|
|
5050
|
-
|
|
5050
|
+
TE: ()=>globalApis,
|
|
5051
|
+
q_: ()=>ROOT_SUITE_NAME,
|
|
5052
|
+
vO: ()=>TEST_DELIMITER
|
|
5051
5053
|
});
|
|
5052
5054
|
const TEST_DELIMITER = '>';
|
|
5053
5055
|
const ROOT_SUITE_NAME = 'Rstest:_internal_root_suite';
|
|
@@ -5067,12 +5069,12 @@ var __webpack_modules__ = {
|
|
|
5067
5069
|
},
|
|
5068
5070
|
"./src/utils/helper.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
5069
5071
|
__webpack_require__.d(__webpack_exports__, {
|
|
5070
|
-
|
|
5071
|
-
|
|
5072
|
-
|
|
5073
|
-
|
|
5074
|
-
|
|
5075
|
-
|
|
5072
|
+
Gv: ()=>isObject,
|
|
5073
|
+
bg: ()=>castArray,
|
|
5074
|
+
fN: ()=>getTaskNameWithPrefix,
|
|
5075
|
+
gy: ()=>undoSerializableConfig,
|
|
5076
|
+
kV: ()=>prettyTime,
|
|
5077
|
+
yW: ()=>picocolors__WEBPACK_IMPORTED_MODULE_2___default.a
|
|
5076
5078
|
});
|
|
5077
5079
|
__webpack_require__("pathe");
|
|
5078
5080
|
var picocolors__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
@@ -5104,7 +5106,7 @@ var __webpack_modules__ = {
|
|
|
5104
5106
|
return time;
|
|
5105
5107
|
};
|
|
5106
5108
|
const getTaskNames = (test)=>(test.parentNames || []).concat(test.name).filter(Boolean);
|
|
5107
|
-
const getTaskNameWithPrefix = (test, delimiter = _constants__WEBPACK_IMPORTED_MODULE_1__.
|
|
5109
|
+
const getTaskNameWithPrefix = (test, delimiter = _constants__WEBPACK_IMPORTED_MODULE_1__.vO)=>getTaskNames(test).join(` ${delimiter} `);
|
|
5108
5110
|
const REGEXP_FLAG_PREFIX = 'RSTEST_REGEXP:';
|
|
5109
5111
|
const unwrapRegex = (value)=>{
|
|
5110
5112
|
if (value.startsWith(REGEXP_FLAG_PREFIX)) {
|
|
@@ -5127,7 +5129,7 @@ var __webpack_modules__ = {
|
|
|
5127
5129
|
},
|
|
5128
5130
|
"./src/utils/logger.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
5129
5131
|
__webpack_require__.d(__webpack_exports__, {
|
|
5130
|
-
|
|
5132
|
+
vF: ()=>src_logger
|
|
5131
5133
|
});
|
|
5132
5134
|
var external_node_os_ = __webpack_require__("node:os");
|
|
5133
5135
|
var external_node_tty_ = __webpack_require__("node:tty");
|
|
@@ -5398,8 +5400,8 @@ var __webpack_modules__ = {
|
|
|
5398
5400
|
src_logger.override({
|
|
5399
5401
|
debug: (message, ...args)=>{
|
|
5400
5402
|
if ('verbose' !== src_logger.level) return;
|
|
5401
|
-
const time = helper
|
|
5402
|
-
console.log(` ${helper
|
|
5403
|
+
const time = helper.yW.gray(getTime());
|
|
5404
|
+
console.log(` ${helper.yW.magenta('rstest')} ${time} ${message}`, ...args);
|
|
5403
5405
|
}
|
|
5404
5406
|
});
|
|
5405
5407
|
},
|
|
@@ -5533,7 +5535,7 @@ __webpack_require__.m = __webpack_modules__;
|
|
|
5533
5535
|
})();
|
|
5534
5536
|
(()=>{
|
|
5535
5537
|
var installedChunks = {
|
|
5536
|
-
|
|
5538
|
+
270: 0
|
|
5537
5539
|
};
|
|
5538
5540
|
var installChunk = (data)=>{
|
|
5539
5541
|
var __webpack_ids__ = data.__webpack_ids__;
|
|
@@ -5641,7 +5643,7 @@ const createRequire = (filename, distPath, rstestContext, assetFiles, interopDef
|
|
|
5641
5643
|
interopDefault
|
|
5642
5644
|
});
|
|
5643
5645
|
} catch (err) {
|
|
5644
|
-
logger.
|
|
5646
|
+
logger.vF.error(`load file ${joinedPath} failed:\n`, err instanceof Error ? err.message : err);
|
|
5645
5647
|
}
|
|
5646
5648
|
const resolved = _require.resolve(id);
|
|
5647
5649
|
return _require(resolved);
|
|
@@ -5804,20 +5806,20 @@ class RstestSnapshotEnvironment extends NodeSnapshotEnvironment {
|
|
|
5804
5806
|
return `// Rstest Snapshot v${this.getVersion()}`;
|
|
5805
5807
|
}
|
|
5806
5808
|
}
|
|
5807
|
-
const getGlobalApi = (api)=>constants.
|
|
5809
|
+
const getGlobalApi = (api)=>constants.TE.reduce((apis, key)=>{
|
|
5808
5810
|
apis[key] = api[key];
|
|
5809
5811
|
return apis;
|
|
5810
5812
|
}, {});
|
|
5811
5813
|
const listeners = [];
|
|
5812
5814
|
let isTeardown = false;
|
|
5813
5815
|
const preparePool = async ({ entryInfo: { distPath, testPath }, sourceMaps, updateSnapshot, context })=>{
|
|
5814
|
-
(0, util.
|
|
5815
|
-
context.runtimeConfig = (0, helper.
|
|
5816
|
+
(0, util.zH)();
|
|
5817
|
+
context.runtimeConfig = (0, helper.gy)(context.runtimeConfig);
|
|
5816
5818
|
const cleanupFns = [];
|
|
5817
5819
|
const { rpc } = createRuntimeRpc(createForksRpcOptions());
|
|
5818
5820
|
const { runtimeConfig: { globals, printConsoleTrace, disableConsoleIntercept, testEnvironment } } = context;
|
|
5819
5821
|
if (!disableConsoleIntercept) {
|
|
5820
|
-
const { createCustomConsole } = await __webpack_require__.e("
|
|
5822
|
+
const { createCustomConsole } = await __webpack_require__.e("607").then(__webpack_require__.bind(__webpack_require__, "./src/runtime/worker/console.ts"));
|
|
5821
5823
|
global.console = createCustomConsole({
|
|
5822
5824
|
rpc,
|
|
5823
5825
|
testPath,
|
|
@@ -5836,10 +5838,10 @@ const preparePool = async ({ entryInfo: { distPath, testPath }, sourceMaps, upda
|
|
|
5836
5838
|
environment: 'node'
|
|
5837
5839
|
};
|
|
5838
5840
|
const { createRstestRuntime } = await Promise.all([
|
|
5839
|
-
__webpack_require__.e("
|
|
5840
|
-
__webpack_require__.e("
|
|
5841
|
+
__webpack_require__.e("655"),
|
|
5842
|
+
__webpack_require__.e("85")
|
|
5841
5843
|
]).then(__webpack_require__.bind(__webpack_require__, "./src/runtime/api/index.ts"));
|
|
5842
|
-
const { install } = await __webpack_require__.e("
|
|
5844
|
+
const { install } = await __webpack_require__.e("969").then(__webpack_require__.t.bind(__webpack_require__, "../../node_modules/.pnpm/source-map-support@0.5.21/node_modules/source-map-support/source-map-support.js", 23));
|
|
5843
5845
|
install({
|
|
5844
5846
|
retrieveSourceMap: (source)=>{
|
|
5845
5847
|
if (sourceMaps[source]) return {
|
|
@@ -5849,14 +5851,16 @@ const preparePool = async ({ entryInfo: { distPath, testPath }, sourceMaps, upda
|
|
|
5849
5851
|
return null;
|
|
5850
5852
|
}
|
|
5851
5853
|
});
|
|
5852
|
-
listeners.forEach((fn)=>
|
|
5854
|
+
listeners.forEach((fn)=>{
|
|
5855
|
+
fn();
|
|
5856
|
+
});
|
|
5853
5857
|
listeners.length = 0;
|
|
5854
5858
|
const unhandledErrors = [];
|
|
5855
5859
|
const handleError = (e, type)=>{
|
|
5856
5860
|
const error = 'string' == typeof e ? new Error(e) : e;
|
|
5857
5861
|
error.name = type;
|
|
5858
5862
|
if (isTeardown) {
|
|
5859
|
-
error.stack = `${helper
|
|
5863
|
+
error.stack = `${helper.yW.yellow('Caught error after test environment was torn down:')}\n\n${error.stack}`;
|
|
5860
5864
|
console.error(error);
|
|
5861
5865
|
} else {
|
|
5862
5866
|
console.error(error);
|
|
@@ -5877,14 +5881,14 @@ const preparePool = async ({ entryInfo: { distPath, testPath }, sourceMaps, upda
|
|
|
5877
5881
|
break;
|
|
5878
5882
|
case 'jsdom':
|
|
5879
5883
|
{
|
|
5880
|
-
const { environment } = await __webpack_require__.e("
|
|
5884
|
+
const { environment } = await __webpack_require__.e("711").then(__webpack_require__.bind(__webpack_require__, "./src/runtime/worker/env/jsdom.ts"));
|
|
5881
5885
|
const { teardown } = await environment.setup(global, {});
|
|
5882
5886
|
cleanupFns.push(()=>teardown(global));
|
|
5883
5887
|
break;
|
|
5884
5888
|
}
|
|
5885
5889
|
case 'happy-dom':
|
|
5886
5890
|
{
|
|
5887
|
-
const { environment } = await __webpack_require__.e("
|
|
5891
|
+
const { environment } = await __webpack_require__.e("350").then(__webpack_require__.bind(__webpack_require__, "./src/runtime/worker/env/happyDom.ts"));
|
|
5888
5892
|
const { teardown } = await environment.setup(global, {});
|
|
5889
5893
|
cleanupFns.push(async ()=>teardown(global));
|
|
5890
5894
|
break;
|
|
@@ -5947,7 +5951,7 @@ const onExit = ()=>{
|
|
|
5947
5951
|
};
|
|
5948
5952
|
const runInPool = async (options)=>{
|
|
5949
5953
|
isTeardown = false;
|
|
5950
|
-
const { entryInfo: { distPath, testPath }, setupEntries, assetFiles, type, context: { runtimeConfig: { isolate } } } = options;
|
|
5954
|
+
const { entryInfo: { distPath, testPath }, setupEntries, assetFiles, type, context: { project, runtimeConfig: { isolate } } } = options;
|
|
5951
5955
|
const cleanups = [];
|
|
5952
5956
|
const exit = process.exit.bind(process);
|
|
5953
5957
|
process.exit = (code = process.exitCode || 0)=>{
|
|
@@ -5958,7 +5962,7 @@ const runInPool = async (options)=>{
|
|
|
5958
5962
|
});
|
|
5959
5963
|
process.off('SIGTERM', onExit);
|
|
5960
5964
|
const teardown = async ()=>{
|
|
5961
|
-
await new Promise((resolve)=>(0, util.
|
|
5965
|
+
await new Promise((resolve)=>(0, util.rZ)().setTimeout(resolve));
|
|
5962
5966
|
await Promise.all(cleanups.map((fn)=>fn()));
|
|
5963
5967
|
isTeardown = true;
|
|
5964
5968
|
process.once('SIGTERM', onExit);
|
|
@@ -5977,15 +5981,17 @@ const runInPool = async (options)=>{
|
|
|
5977
5981
|
});
|
|
5978
5982
|
const tests = await runner.collectTests();
|
|
5979
5983
|
return {
|
|
5984
|
+
project,
|
|
5980
5985
|
testPath,
|
|
5981
5986
|
tests,
|
|
5982
|
-
errors: (0, util.
|
|
5987
|
+
errors: (0, util.o9)(unhandledErrors)
|
|
5983
5988
|
};
|
|
5984
5989
|
} catch (err) {
|
|
5985
5990
|
return {
|
|
5991
|
+
project,
|
|
5986
5992
|
testPath,
|
|
5987
5993
|
tests: [],
|
|
5988
|
-
errors: (0, util.
|
|
5994
|
+
errors: (0, util.o9)(err)
|
|
5989
5995
|
};
|
|
5990
5996
|
} finally{
|
|
5991
5997
|
await teardown();
|
|
@@ -6015,16 +6021,17 @@ const runInPool = async (options)=>{
|
|
|
6015
6021
|
}, api);
|
|
6016
6022
|
if (unhandledErrors.length > 0) {
|
|
6017
6023
|
results.status = 'fail';
|
|
6018
|
-
results.errors = (results.errors || []).concat(...(0, util.
|
|
6024
|
+
results.errors = (results.errors || []).concat(...(0, util.o9)(unhandledErrors));
|
|
6019
6025
|
}
|
|
6020
6026
|
return results;
|
|
6021
6027
|
} catch (err) {
|
|
6022
6028
|
return {
|
|
6029
|
+
project,
|
|
6023
6030
|
testPath,
|
|
6024
6031
|
status: 'fail',
|
|
6025
6032
|
name: '',
|
|
6026
6033
|
results: [],
|
|
6027
|
-
errors: (0, util.
|
|
6034
|
+
errors: (0, util.o9)(err)
|
|
6028
6035
|
};
|
|
6029
6036
|
} finally{
|
|
6030
6037
|
await teardown();
|