@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
|
@@ -2972,12 +2972,15 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
2972
2972
|
`;
|
|
2973
2973
|
};
|
|
2974
2974
|
const resolveDefaultFrameworkImport = ()=>{
|
|
2975
|
-
const entry = process.argv[1] ? (0, external_node_path_.resolve)(process.argv[1]) : '';
|
|
2976
2975
|
const candidates = [
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
].
|
|
2980
|
-
|
|
2976
|
+
(0, external_node_path_.join)(__dirname, 'framework', 'index.js')
|
|
2977
|
+
];
|
|
2978
|
+
const entry = process.argv[1] ? (0, external_node_path_.resolve)(process.argv[1]) : '';
|
|
2979
|
+
if (entry) {
|
|
2980
|
+
candidates.push((0, external_node_path_.join)((0, external_node_path_.dirname)(entry), 'framework', 'index.js'));
|
|
2981
|
+
candidates.push((0, external_node_path_.join)((0, external_node_path_.dirname)(entry), '..', 'dist', 'lib', 'framework', 'index.js'));
|
|
2982
|
+
}
|
|
2983
|
+
const matched = candidates.filter(Boolean).find((candidate)=>(0, external_node_fs_.existsSync)(candidate));
|
|
2981
2984
|
return matched || '@midscene/cli/dist/lib/framework/index.js';
|
|
2982
2985
|
};
|
|
2983
2986
|
function createRstestYamlProject(options) {
|
|
@@ -3068,6 +3071,73 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
3068
3071
|
return (0, external_node_path_.join)((0, external_node_path_.dirname)(packageJsonPath), 'dist', 'index.js');
|
|
3069
3072
|
}
|
|
3070
3073
|
const formatRunError = (error)=>error.stack || `${error.name}: ${error.message}`;
|
|
3074
|
+
const collectRunErrors = (result)=>{
|
|
3075
|
+
const messages = [];
|
|
3076
|
+
const push = (error, label)=>{
|
|
3077
|
+
const formatted = formatRunError(error);
|
|
3078
|
+
messages.push(label ? `${label}: ${formatted}` : formatted);
|
|
3079
|
+
};
|
|
3080
|
+
for (const file of result.files ?? []){
|
|
3081
|
+
for (const error of file.errors ?? [])push(error, file.name || file.testPath);
|
|
3082
|
+
for (const testResult of file.results ?? [])for (const error of testResult.errors ?? [])push(error, testResult.name);
|
|
3083
|
+
}
|
|
3084
|
+
for (const error of result.unhandledErrors ?? [])push(error);
|
|
3085
|
+
return Array.from(new Set(messages));
|
|
3086
|
+
};
|
|
3087
|
+
const rstest_runner_errorMessage = (error)=>error.message || error.name || 'YAML case failed';
|
|
3088
|
+
const mapRunErrorsToCases = (project, result)=>{
|
|
3089
|
+
const byTestName = new Map(project.cases.map((item)=>[
|
|
3090
|
+
item.testName,
|
|
3091
|
+
item
|
|
3092
|
+
]));
|
|
3093
|
+
const errors = new Map();
|
|
3094
|
+
const add = (item, message)=>{
|
|
3095
|
+
if (item && message && !errors.has(item.yamlFile)) errors.set(item.yamlFile, message);
|
|
3096
|
+
};
|
|
3097
|
+
const matchFileCase = (file)=>{
|
|
3098
|
+
for (const key of [
|
|
3099
|
+
file.name,
|
|
3100
|
+
file.testPath
|
|
3101
|
+
]){
|
|
3102
|
+
if (!key) continue;
|
|
3103
|
+
const matched = project.cases.find((item)=>key === item.testModule || key.includes(item.testModule));
|
|
3104
|
+
if (matched) return matched;
|
|
3105
|
+
}
|
|
3106
|
+
};
|
|
3107
|
+
for (const file of result.files ?? []){
|
|
3108
|
+
const fileCase = matchFileCase(file);
|
|
3109
|
+
for (const error of file.errors ?? [])add(fileCase, rstest_runner_errorMessage(error));
|
|
3110
|
+
for (const testResult of file.results ?? []){
|
|
3111
|
+
const item = byTestName.get(testResult.name) ?? fileCase;
|
|
3112
|
+
for (const error of testResult.errors ?? [])add(item, rstest_runner_errorMessage(error));
|
|
3113
|
+
}
|
|
3114
|
+
}
|
|
3115
|
+
if (1 === project.cases.length && 0 === errors.size && result.unhandledErrors?.length) add(project.cases[0], rstest_runner_errorMessage(result.unhandledErrors[0]));
|
|
3116
|
+
return errors;
|
|
3117
|
+
};
|
|
3118
|
+
const recordUnreportedCaseFailures = (project, result)=>{
|
|
3119
|
+
if (!project.cases.length) return;
|
|
3120
|
+
const caseErrors = mapRunErrorsToCases(project, result);
|
|
3121
|
+
for (const item of project.cases){
|
|
3122
|
+
if ((0, external_node_fs_.existsSync)(item.resultFile)) continue;
|
|
3123
|
+
const error = caseErrors.get(item.yamlFile);
|
|
3124
|
+
if (!error) continue;
|
|
3125
|
+
const failure = {
|
|
3126
|
+
file: item.yamlFile,
|
|
3127
|
+
success: false,
|
|
3128
|
+
executed: true,
|
|
3129
|
+
output: void 0,
|
|
3130
|
+
report: void 0,
|
|
3131
|
+
duration: 0,
|
|
3132
|
+
resultType: 'failed',
|
|
3133
|
+
error
|
|
3134
|
+
};
|
|
3135
|
+
(0, external_node_fs_.mkdirSync)((0, external_node_path_.dirname)(item.resultFile), {
|
|
3136
|
+
recursive: true
|
|
3137
|
+
});
|
|
3138
|
+
(0, external_node_fs_.writeFileSync)(item.resultFile, JSON.stringify(failure, null, 2));
|
|
3139
|
+
}
|
|
3140
|
+
};
|
|
3071
3141
|
async function runRstestYamlProject(options) {
|
|
3072
3142
|
const [{ runRstest }, { rspack }] = await Promise.all([
|
|
3073
3143
|
import("@rstest/core/api"),
|
|
@@ -3103,7 +3173,13 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
3103
3173
|
cwd: options.cwd || project.projectDir,
|
|
3104
3174
|
inlineConfig
|
|
3105
3175
|
});
|
|
3106
|
-
if (!result.ok
|
|
3176
|
+
if (!result.ok) {
|
|
3177
|
+
recordUnreportedCaseFailures(project, result);
|
|
3178
|
+
if ('pipe' !== options.stdio) {
|
|
3179
|
+
const runErrors = collectRunErrors(result);
|
|
3180
|
+
if (runErrors.length) console.error(`\nYAML execution failed:\n${runErrors.join('\n\n')}`);
|
|
3181
|
+
}
|
|
3182
|
+
}
|
|
3107
3183
|
return result.ok ? 0 : 1;
|
|
3108
3184
|
}
|
|
3109
3185
|
const createCaseOptions = (config)=>{
|