@midscene/cli 1.9.5-beta-20260611051901.0 → 1.9.5
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/es/framework/index.mjs +22 -54
- package/dist/es/framework/index.mjs.map +1 -1
- package/dist/es/index.mjs +19 -37
- package/dist/es/index.mjs.map +1 -1
- package/dist/lib/framework/index.js +21 -53
- package/dist/lib/framework/index.js.map +1 -1
- package/dist/lib/index.js +16 -34
- package/dist/lib/index.js.map +1 -1
- package/dist/types/framework/index.d.ts +2 -18
- package/package.json +8 -8
|
@@ -8,6 +8,7 @@ import { getMidsceneRunSubDir } from "@midscene/shared/common";
|
|
|
8
8
|
import { getDebug } from "@midscene/shared/logger";
|
|
9
9
|
import { createRequire } from "node:module";
|
|
10
10
|
import { pathToFileURL } from "node:url";
|
|
11
|
+
import { test } from "@rstest/core";
|
|
11
12
|
import { ScriptPlayer, parseYamlScript } from "@midscene/core/yaml";
|
|
12
13
|
import { buildChromeArgs, defaultViewportHeight, defaultViewportWidth, puppeteerAgentForTarget } from "@midscene/web/puppeteer-agent-launcher";
|
|
13
14
|
import lodash_merge from "lodash.merge";
|
|
@@ -2611,20 +2612,6 @@ function printExecutionSummary(results, summaryPath) {
|
|
|
2611
2612
|
else console.log('\n⚠️ Some files failed or were not executed.');
|
|
2612
2613
|
return success;
|
|
2613
2614
|
}
|
|
2614
|
-
const requireFromCliPackage = ()=>{
|
|
2615
|
-
if ('undefined' != typeof __dirname) return createRequire(join(__dirname, 'index.js'));
|
|
2616
|
-
const entry = process.argv[1] ? external_node_path_resolve(process.argv[1]) : join(process.cwd(), 'midscene-cli.js');
|
|
2617
|
-
return createRequire(entry);
|
|
2618
|
-
};
|
|
2619
|
-
const resolvePackageFromRstestCore = (packageName)=>{
|
|
2620
|
-
const require = requireFromCliPackage();
|
|
2621
|
-
const rstestPackageJsonPath = require.resolve('@rstest/core/package.json');
|
|
2622
|
-
return createRequire(rstestPackageJsonPath).resolve(packageName);
|
|
2623
|
-
};
|
|
2624
|
-
function resolveRstestCoreImportPath() {
|
|
2625
|
-
const require = requireFromCliPackage();
|
|
2626
|
-
return require.resolve('@rstest/core');
|
|
2627
|
-
}
|
|
2628
2615
|
const DEFAULT_YAML_TEST_TIMEOUT = 0;
|
|
2629
2616
|
const RSTEST_YAML_BATCH_TEST_MODULE = 'virtual:midscene-yaml/batch.test.ts';
|
|
2630
2617
|
const RSTEST_YAML_BATCH_TEST_NAME = 'midscene yaml batch';
|
|
@@ -2651,16 +2638,9 @@ const createGeneratedTestContent = (options)=>{
|
|
|
2651
2638
|
webRuntimeOptions: options.webRuntimeOptions
|
|
2652
2639
|
} : {}
|
|
2653
2640
|
};
|
|
2654
|
-
return `import {
|
|
2655
|
-
import { defineYamlCaseTest } from ${toImportLiteral(options.frameworkImport)};
|
|
2656
|
-
|
|
2657
|
-
const testOptions = ${JSON.stringify(testOptions, null, 2)};
|
|
2641
|
+
return `import { defineYamlCaseTest } from ${toImportLiteral(options.frameworkImport)};
|
|
2658
2642
|
|
|
2659
|
-
|
|
2660
|
-
defineYamlCaseTest(test, testOptions);
|
|
2661
|
-
} else {
|
|
2662
|
-
await defineYamlCaseTest(testOptions);
|
|
2663
|
-
}
|
|
2643
|
+
defineYamlCaseTest(${JSON.stringify(testOptions, null, 2)});
|
|
2664
2644
|
`;
|
|
2665
2645
|
};
|
|
2666
2646
|
const createGeneratedBatchTestContent = (options)=>{
|
|
@@ -2669,16 +2649,9 @@ const createGeneratedBatchTestContent = (options)=>{
|
|
|
2669
2649
|
config: options.config,
|
|
2670
2650
|
resultFiles: options.resultFiles
|
|
2671
2651
|
};
|
|
2672
|
-
return `import {
|
|
2673
|
-
import { defineYamlBatchTest } from ${toImportLiteral(options.frameworkImport)};
|
|
2674
|
-
|
|
2675
|
-
const testOptions = ${JSON.stringify(testOptions, null, 2)};
|
|
2652
|
+
return `import { defineYamlBatchTest } from ${toImportLiteral(options.frameworkImport)};
|
|
2676
2653
|
|
|
2677
|
-
|
|
2678
|
-
defineYamlBatchTest(test, testOptions);
|
|
2679
|
-
} else {
|
|
2680
|
-
await defineYamlBatchTest(testOptions);
|
|
2681
|
-
}
|
|
2654
|
+
defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
2682
2655
|
`;
|
|
2683
2656
|
};
|
|
2684
2657
|
const resolveDefaultFrameworkImport = (moduleDir)=>{
|
|
@@ -2699,7 +2672,6 @@ function createRstestYamlProject(options) {
|
|
|
2699
2672
|
const outputDir = options.outputDir || join(getMidsceneRunSubDir('tmp'), `rstest-yaml-${Date.now()}`);
|
|
2700
2673
|
const resultDir = options.resultDir || join(outputDir, 'results');
|
|
2701
2674
|
const frameworkImport = options.frameworkImport || resolveDefaultFrameworkImport();
|
|
2702
|
-
const rstestCoreImport = options.rstestCoreImport || resolveRstestCoreImportPath();
|
|
2703
2675
|
const testTimeout = options.testTimeout ?? DEFAULT_YAML_TEST_TIMEOUT;
|
|
2704
2676
|
rmSync(outputDir, {
|
|
2705
2677
|
recursive: true,
|
|
@@ -2716,7 +2688,6 @@ function createRstestYamlProject(options) {
|
|
|
2716
2688
|
const resultFile = join(resultDir, `${fileStem}.json`);
|
|
2717
2689
|
const testModule = toVirtualModuleId(fileStem);
|
|
2718
2690
|
virtualModules[testModule] = createGeneratedTestContent({
|
|
2719
|
-
rstestCoreImport,
|
|
2720
2691
|
frameworkImport,
|
|
2721
2692
|
yamlFile,
|
|
2722
2693
|
resultFile,
|
|
@@ -2749,7 +2720,6 @@ function createRstestYamlProject(options) {
|
|
|
2749
2720
|
],
|
|
2750
2721
|
virtualModules: {
|
|
2751
2722
|
[batchTest.testModule]: createGeneratedBatchTestContent({
|
|
2752
|
-
rstestCoreImport,
|
|
2753
2723
|
frameworkImport,
|
|
2754
2724
|
testName: batchTest.testName,
|
|
2755
2725
|
config: options.batchConfig,
|
|
@@ -2776,6 +2746,21 @@ function createRstestYamlProject(options) {
|
|
|
2776
2746
|
retry: options.retry
|
|
2777
2747
|
};
|
|
2778
2748
|
}
|
|
2749
|
+
const requireFromCliPackage = ()=>{
|
|
2750
|
+
if ('undefined' != typeof __dirname) return createRequire(join(__dirname, 'index.js'));
|
|
2751
|
+
const entry = process.argv[1] ? external_node_path_resolve(process.argv[1]) : join(process.cwd(), 'midscene-cli.js');
|
|
2752
|
+
return createRequire(entry);
|
|
2753
|
+
};
|
|
2754
|
+
const resolvePackageFromRstestCore = (packageName)=>{
|
|
2755
|
+
const require = requireFromCliPackage();
|
|
2756
|
+
const rstestPackageJsonPath = require.resolve('@rstest/core/package.json');
|
|
2757
|
+
return createRequire(rstestPackageJsonPath).resolve(packageName);
|
|
2758
|
+
};
|
|
2759
|
+
function resolveRstestCoreImportPath() {
|
|
2760
|
+
const require = requireFromCliPackage();
|
|
2761
|
+
const packageJsonPath = require.resolve('@rstest/core/package.json');
|
|
2762
|
+
return join(dirname(packageJsonPath), 'dist', 'index.js');
|
|
2763
|
+
}
|
|
2779
2764
|
const formatRunError = (error)=>error.stack || `${error.name}: ${error.message}`;
|
|
2780
2765
|
const collectRunErrors = (result)=>{
|
|
2781
2766
|
const messages = [];
|
|
@@ -4108,12 +4093,7 @@ const createRuntimeFailureResult = (file, startTime, error)=>({
|
|
|
4108
4093
|
resultType: 'failed',
|
|
4109
4094
|
error: rstest_entry_errorMessageOf(error)
|
|
4110
4095
|
});
|
|
4111
|
-
|
|
4112
|
-
const loadRstestTest = async ()=>{
|
|
4113
|
-
if (!rstestCorePromise) rstestCorePromise = import("@rstest/core");
|
|
4114
|
-
return (await rstestCorePromise).test;
|
|
4115
|
-
};
|
|
4116
|
-
const registerYamlCaseTest = (test, options)=>{
|
|
4096
|
+
function defineYamlCaseTest(options) {
|
|
4117
4097
|
test(options.testName, async ()=>{
|
|
4118
4098
|
const file = external_node_path_resolve(options.yamlFile);
|
|
4119
4099
|
const startTime = Date.now();
|
|
@@ -4135,26 +4115,14 @@ const registerYamlCaseTest = (test, options)=>{
|
|
|
4135
4115
|
throw error;
|
|
4136
4116
|
}
|
|
4137
4117
|
});
|
|
4138
|
-
};
|
|
4139
|
-
function defineYamlCaseTest(testOrOptions, maybeOptions) {
|
|
4140
|
-
if (maybeOptions) return void registerYamlCaseTest(testOrOptions, maybeOptions);
|
|
4141
|
-
return loadRstestTest().then((test)=>{
|
|
4142
|
-
registerYamlCaseTest(test, testOrOptions);
|
|
4143
|
-
});
|
|
4144
4118
|
}
|
|
4145
|
-
|
|
4119
|
+
function defineYamlBatchTest(options) {
|
|
4146
4120
|
test(options.testName, async ()=>{
|
|
4147
4121
|
await runYamlBatchInRstest({
|
|
4148
4122
|
config: options.config,
|
|
4149
4123
|
resultFiles: options.resultFiles
|
|
4150
4124
|
});
|
|
4151
4125
|
});
|
|
4152
|
-
};
|
|
4153
|
-
function defineYamlBatchTest(testOrOptions, maybeOptions) {
|
|
4154
|
-
if (maybeOptions) return void registerYamlBatchTest(testOrOptions, maybeOptions);
|
|
4155
|
-
return loadRstestTest().then((test)=>{
|
|
4156
|
-
registerYamlBatchTest(test, testOrOptions);
|
|
4157
|
-
});
|
|
4158
4126
|
}
|
|
4159
4127
|
export { createRstestYamlProject, createYamlCaseFailure, createYamlCaseResult, defineYamlBatchTest, defineYamlCaseTest, getYamlPlayerFailure, resolveRstestCoreImportPath, resolveTestName, runFrameworkTestConfig, runRstestYamlProject, runYamlBatchInRstest, runYamlCase, runYamlCaseResult };
|
|
4160
4128
|
|