@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/index.mjs CHANGED
@@ -3026,9 +3026,7 @@ var __webpack_modules__ = {
3026
3026
  "./src/index.ts" (__unused_rspack_module, __unused_rspack___webpack_exports__, __webpack_require__) {
3027
3027
  var main = __webpack_require__("../../node_modules/.pnpm/dotenv@16.4.5/node_modules/dotenv/lib/main.js");
3028
3028
  var main_default = /*#__PURE__*/ __webpack_require__.n(main);
3029
- var package_namespaceObject = {
3030
- rE: "1.9.1"
3031
- };
3029
+ var package_namespaceObject = JSON.parse('{"rE":"1.9.2-beta-20260605092310.0"}');
3032
3030
  var brace_expansion = __webpack_require__("../../node_modules/.pnpm/brace-expansion@2.0.1/node_modules/brace-expansion/index.js");
3033
3031
  const MAX_PATTERN_LENGTH = 65536;
3034
3032
  const assertValidPattern = (pattern)=>{
@@ -10851,7 +10849,7 @@ Usage:
10851
10849
  type: 'boolean',
10852
10850
  description: `Turn on logging to help debug why certain keys or values are not being set as you expect, default is ${config_factory_defaultConfig.dotenvDebug}`
10853
10851
  }
10854
- }).version('version', 'Show version number', "1.9.1").help().epilogue(`For complete list of configuration options, please visit:
10852
+ }).version('version', 'Show version number', "1.9.2-beta-20260605092310.0").help().epilogue(`For complete list of configuration options, please visit:
10855
10853
  • Web options: https://midscenejs.com/automate-with-scripts-in-yaml#the-web-part
10856
10854
  • Android options: https://midscenejs.com/automate-with-scripts-in-yaml#the-android-part
10857
10855
  • iOS options: https://midscenejs.com/automate-with-scripts-in-yaml#the-ios-part
@@ -11056,12 +11054,15 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
11056
11054
  `;
11057
11055
  };
11058
11056
  const resolveDefaultFrameworkImport = ()=>{
11059
- const entry = process.argv[1] ? external_node_path_resolve(process.argv[1]) : '';
11060
11057
  const candidates = [
11061
- entry ? external_node_path_join(external_node_path_dirname(entry), 'framework', 'index.js') : '',
11062
- entry ? external_node_path_join(external_node_path_dirname(entry), '..', 'dist', 'lib', 'framework', 'index.js') : ''
11063
- ].filter(Boolean);
11064
- const matched = candidates.find((candidate)=>(0, __rspack_external_node_fs_5ea92f0c.existsSync)(candidate));
11058
+ 'undefined' != typeof __dirname ? external_node_path_join(__dirname, 'framework', 'index.js') : ''
11059
+ ];
11060
+ const entry = process.argv[1] ? external_node_path_resolve(process.argv[1]) : '';
11061
+ if (entry) {
11062
+ candidates.push(external_node_path_join(external_node_path_dirname(entry), 'framework', 'index.js'));
11063
+ candidates.push(external_node_path_join(external_node_path_dirname(entry), '..', 'dist', 'lib', 'framework', 'index.js'));
11064
+ }
11065
+ const matched = candidates.filter(Boolean).find((candidate)=>(0, __rspack_external_node_fs_5ea92f0c.existsSync)(candidate));
11065
11066
  return matched || '@midscene/cli/dist/lib/framework/index.js';
11066
11067
  };
11067
11068
  function createRstestYamlProject(options) {
@@ -11149,6 +11150,73 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
11149
11150
  return createRequire(rstestPackageJsonPath).resolve(packageName);
11150
11151
  };
11151
11152
  const formatRunError = (error)=>error.stack || `${error.name}: ${error.message}`;
11153
+ const collectRunErrors = (result)=>{
11154
+ const messages = [];
11155
+ const push = (error, label)=>{
11156
+ const formatted = formatRunError(error);
11157
+ messages.push(label ? `${label}: ${formatted}` : formatted);
11158
+ };
11159
+ for (const file of result.files ?? []){
11160
+ for (const error of file.errors ?? [])push(error, file.name || file.testPath);
11161
+ for (const testResult of file.results ?? [])for (const error of testResult.errors ?? [])push(error, testResult.name);
11162
+ }
11163
+ for (const error of result.unhandledErrors ?? [])push(error);
11164
+ return Array.from(new Set(messages));
11165
+ };
11166
+ const rstest_runner_errorMessage = (error)=>error.message || error.name || 'YAML case failed';
11167
+ const mapRunErrorsToCases = (project, result)=>{
11168
+ const byTestName = new Map(project.cases.map((item)=>[
11169
+ item.testName,
11170
+ item
11171
+ ]));
11172
+ const errors = new Map();
11173
+ const add = (item, message)=>{
11174
+ if (item && message && !errors.has(item.yamlFile)) errors.set(item.yamlFile, message);
11175
+ };
11176
+ const matchFileCase = (file)=>{
11177
+ for (const key of [
11178
+ file.name,
11179
+ file.testPath
11180
+ ]){
11181
+ if (!key) continue;
11182
+ const matched = project.cases.find((item)=>key === item.testModule || key.includes(item.testModule));
11183
+ if (matched) return matched;
11184
+ }
11185
+ };
11186
+ for (const file of result.files ?? []){
11187
+ const fileCase = matchFileCase(file);
11188
+ for (const error of file.errors ?? [])add(fileCase, rstest_runner_errorMessage(error));
11189
+ for (const testResult of file.results ?? []){
11190
+ const item = byTestName.get(testResult.name) ?? fileCase;
11191
+ for (const error of testResult.errors ?? [])add(item, rstest_runner_errorMessage(error));
11192
+ }
11193
+ }
11194
+ if (1 === project.cases.length && 0 === errors.size && result.unhandledErrors?.length) add(project.cases[0], rstest_runner_errorMessage(result.unhandledErrors[0]));
11195
+ return errors;
11196
+ };
11197
+ const recordUnreportedCaseFailures = (project, result)=>{
11198
+ if (!project.cases.length) return;
11199
+ const caseErrors = mapRunErrorsToCases(project, result);
11200
+ for (const item of project.cases){
11201
+ if ((0, __rspack_external_node_fs_5ea92f0c.existsSync)(item.resultFile)) continue;
11202
+ const error = caseErrors.get(item.yamlFile);
11203
+ if (!error) continue;
11204
+ const failure = {
11205
+ file: item.yamlFile,
11206
+ success: false,
11207
+ executed: true,
11208
+ output: void 0,
11209
+ report: void 0,
11210
+ duration: 0,
11211
+ resultType: 'failed',
11212
+ error
11213
+ };
11214
+ (0, __rspack_external_node_fs_5ea92f0c.mkdirSync)(external_node_path_dirname(item.resultFile), {
11215
+ recursive: true
11216
+ });
11217
+ (0, __rspack_external_node_fs_5ea92f0c.writeFileSync)(item.resultFile, JSON.stringify(failure, null, 2));
11218
+ }
11219
+ };
11152
11220
  async function runRstestYamlProject(options) {
11153
11221
  const [{ runRstest }, { rspack }] = await Promise.all([
11154
11222
  import("@rstest/core/api"),
@@ -11184,7 +11252,13 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
11184
11252
  cwd: options.cwd || project.projectDir,
11185
11253
  inlineConfig
11186
11254
  });
11187
- if (!result.ok && 'pipe' !== options.stdio && result.unhandledErrors.length) console.error(result.unhandledErrors.map((error)=>formatRunError(error)).join('\n'));
11255
+ if (!result.ok) {
11256
+ recordUnreportedCaseFailures(project, result);
11257
+ if ('pipe' !== options.stdio) {
11258
+ const runErrors = collectRunErrors(result);
11259
+ if (runErrors.length) console.error(`\nYAML execution failed:\n${runErrors.join('\n\n')}`);
11260
+ }
11261
+ }
11188
11262
  return result.ok ? 0 : 1;
11189
11263
  }
11190
11264
  const createCaseOptions = (config)=>{