@midscene/cli 1.9.1 → 1.9.2-beta-20260605092310.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/es/framework/index.mjs +82 -6
- package/dist/es/framework/index.mjs.map +1 -1
- package/dist/es/index.mjs +84 -10
- package/dist/es/index.mjs.map +1 -1
- package/dist/lib/framework/index.js +82 -6
- package/dist/lib/framework/index.js.map +1 -1
- package/dist/lib/index.js +84 -10
- package/dist/lib/index.js.map +1 -1
- package/package.json +8 -8
|
@@ -2578,12 +2578,15 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
2578
2578
|
`;
|
|
2579
2579
|
};
|
|
2580
2580
|
const resolveDefaultFrameworkImport = ()=>{
|
|
2581
|
-
const entry = process.argv[1] ? external_node_path_resolve(process.argv[1]) : '';
|
|
2582
2581
|
const candidates = [
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
].
|
|
2586
|
-
|
|
2582
|
+
'undefined' != typeof __dirname ? join(__dirname, 'framework', 'index.js') : ''
|
|
2583
|
+
];
|
|
2584
|
+
const entry = process.argv[1] ? external_node_path_resolve(process.argv[1]) : '';
|
|
2585
|
+
if (entry) {
|
|
2586
|
+
candidates.push(join(dirname(entry), 'framework', 'index.js'));
|
|
2587
|
+
candidates.push(join(dirname(entry), '..', 'dist', 'lib', 'framework', 'index.js'));
|
|
2588
|
+
}
|
|
2589
|
+
const matched = candidates.filter(Boolean).find((candidate)=>existsSync(candidate));
|
|
2587
2590
|
return matched || '@midscene/cli/dist/lib/framework/index.js';
|
|
2588
2591
|
};
|
|
2589
2592
|
function createRstestYamlProject(options) {
|
|
@@ -2676,6 +2679,73 @@ function resolveRstestCoreImportPath() {
|
|
|
2676
2679
|
return join(dirname(packageJsonPath), 'dist', 'index.js');
|
|
2677
2680
|
}
|
|
2678
2681
|
const formatRunError = (error)=>error.stack || `${error.name}: ${error.message}`;
|
|
2682
|
+
const collectRunErrors = (result)=>{
|
|
2683
|
+
const messages = [];
|
|
2684
|
+
const push = (error, label)=>{
|
|
2685
|
+
const formatted = formatRunError(error);
|
|
2686
|
+
messages.push(label ? `${label}: ${formatted}` : formatted);
|
|
2687
|
+
};
|
|
2688
|
+
for (const file of result.files ?? []){
|
|
2689
|
+
for (const error of file.errors ?? [])push(error, file.name || file.testPath);
|
|
2690
|
+
for (const testResult of file.results ?? [])for (const error of testResult.errors ?? [])push(error, testResult.name);
|
|
2691
|
+
}
|
|
2692
|
+
for (const error of result.unhandledErrors ?? [])push(error);
|
|
2693
|
+
return Array.from(new Set(messages));
|
|
2694
|
+
};
|
|
2695
|
+
const rstest_runner_errorMessage = (error)=>error.message || error.name || 'YAML case failed';
|
|
2696
|
+
const mapRunErrorsToCases = (project, result)=>{
|
|
2697
|
+
const byTestName = new Map(project.cases.map((item)=>[
|
|
2698
|
+
item.testName,
|
|
2699
|
+
item
|
|
2700
|
+
]));
|
|
2701
|
+
const errors = new Map();
|
|
2702
|
+
const add = (item, message)=>{
|
|
2703
|
+
if (item && message && !errors.has(item.yamlFile)) errors.set(item.yamlFile, message);
|
|
2704
|
+
};
|
|
2705
|
+
const matchFileCase = (file)=>{
|
|
2706
|
+
for (const key of [
|
|
2707
|
+
file.name,
|
|
2708
|
+
file.testPath
|
|
2709
|
+
]){
|
|
2710
|
+
if (!key) continue;
|
|
2711
|
+
const matched = project.cases.find((item)=>key === item.testModule || key.includes(item.testModule));
|
|
2712
|
+
if (matched) return matched;
|
|
2713
|
+
}
|
|
2714
|
+
};
|
|
2715
|
+
for (const file of result.files ?? []){
|
|
2716
|
+
const fileCase = matchFileCase(file);
|
|
2717
|
+
for (const error of file.errors ?? [])add(fileCase, rstest_runner_errorMessage(error));
|
|
2718
|
+
for (const testResult of file.results ?? []){
|
|
2719
|
+
const item = byTestName.get(testResult.name) ?? fileCase;
|
|
2720
|
+
for (const error of testResult.errors ?? [])add(item, rstest_runner_errorMessage(error));
|
|
2721
|
+
}
|
|
2722
|
+
}
|
|
2723
|
+
if (1 === project.cases.length && 0 === errors.size && result.unhandledErrors?.length) add(project.cases[0], rstest_runner_errorMessage(result.unhandledErrors[0]));
|
|
2724
|
+
return errors;
|
|
2725
|
+
};
|
|
2726
|
+
const recordUnreportedCaseFailures = (project, result)=>{
|
|
2727
|
+
if (!project.cases.length) return;
|
|
2728
|
+
const caseErrors = mapRunErrorsToCases(project, result);
|
|
2729
|
+
for (const item of project.cases){
|
|
2730
|
+
if (existsSync(item.resultFile)) continue;
|
|
2731
|
+
const error = caseErrors.get(item.yamlFile);
|
|
2732
|
+
if (!error) continue;
|
|
2733
|
+
const failure = {
|
|
2734
|
+
file: item.yamlFile,
|
|
2735
|
+
success: false,
|
|
2736
|
+
executed: true,
|
|
2737
|
+
output: void 0,
|
|
2738
|
+
report: void 0,
|
|
2739
|
+
duration: 0,
|
|
2740
|
+
resultType: 'failed',
|
|
2741
|
+
error
|
|
2742
|
+
};
|
|
2743
|
+
mkdirSync(dirname(item.resultFile), {
|
|
2744
|
+
recursive: true
|
|
2745
|
+
});
|
|
2746
|
+
writeFileSync(item.resultFile, JSON.stringify(failure, null, 2));
|
|
2747
|
+
}
|
|
2748
|
+
};
|
|
2679
2749
|
async function runRstestYamlProject(options) {
|
|
2680
2750
|
const [{ runRstest }, { rspack }] = await Promise.all([
|
|
2681
2751
|
import("@rstest/core/api"),
|
|
@@ -2711,7 +2781,13 @@ async function runRstestYamlProject(options) {
|
|
|
2711
2781
|
cwd: options.cwd || project.projectDir,
|
|
2712
2782
|
inlineConfig
|
|
2713
2783
|
});
|
|
2714
|
-
if (!result.ok
|
|
2784
|
+
if (!result.ok) {
|
|
2785
|
+
recordUnreportedCaseFailures(project, result);
|
|
2786
|
+
if ('pipe' !== options.stdio) {
|
|
2787
|
+
const runErrors = collectRunErrors(result);
|
|
2788
|
+
if (runErrors.length) console.error(`\nYAML execution failed:\n${runErrors.join('\n\n')}`);
|
|
2789
|
+
}
|
|
2790
|
+
}
|
|
2715
2791
|
return result.ok ? 0 : 1;
|
|
2716
2792
|
}
|
|
2717
2793
|
const createCaseOptions = (config)=>{
|