@midscene/test 1.12.9-beta-20260917120835.0 → 1.12.9

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.
@@ -707,11 +707,12 @@ A Node may map a string step value to one declared input field. Each Node sectio
707
707
  resolveNode: (name)=>nodes.get(name)
708
708
  };
709
709
  };
710
- const assertTypeScriptConfig = (absolutePath)=>{
711
- if (!absolutePath.endsWith('.ts')) {
710
+ const assertSupportedConfig = (absolutePath)=>{
711
+ if (!absolutePath.endsWith('.ts') && !absolutePath.endsWith('.mjs')) {
712
712
  const extension = absolutePath.match(/(\.[^./\\]+)$/)?.[1] ?? '(none)';
713
- throw new TypeError(`Unsupported Midscene config extension: ${extension}. Supported extension: .ts.`);
713
+ throw new TypeError(`Unsupported Midscene config extension: ${extension}. Supported extensions: .ts, .mjs.`);
714
714
  }
715
+ return absolutePath.endsWith('.mjs') ? '.mjs' : '.ts';
715
716
  };
716
717
  const canRetryWithCjsLoader = (error)=>{
717
718
  if (!(error instanceof Error)) return false;
@@ -723,16 +724,16 @@ A Node may map a string step value to one declared input field. Each Node sectio
723
724
  nodes: []
724
725
  });
725
726
  const absolutePath = (0, external_node_path_.resolve)(configPath);
726
- assertTypeScriptConfig(absolutePath);
727
+ const extension = assertSupportedConfig(absolutePath);
727
728
  let loaded;
728
729
  try {
729
- loaded = await (0, esm_api_namespaceObject.tsImport)((0, external_node_url_namespaceObject.pathToFileURL)(absolutePath).href, {
730
+ loaded = '.mjs' === extension ? await import((0, external_node_url_namespaceObject.pathToFileURL)(absolutePath).href) : await (0, esm_api_namespaceObject.tsImport)((0, external_node_url_namespaceObject.pathToFileURL)(absolutePath).href, {
730
731
  parentURL: (0, external_node_url_namespaceObject.pathToFileURL)(`${(0, external_node_path_.dirname)(absolutePath)}${external_node_path_.sep}`).href,
731
732
  tsconfig: false
732
733
  });
733
734
  } catch (error) {
734
735
  try {
735
- if (!canRetryWithCjsLoader(error)) throw error;
736
+ if ('.mjs' === extension || !canRetryWithCjsLoader(error)) throw error;
736
737
  loaded = (0, api_namespaceObject.require)(absolutePath, (0, external_node_url_namespaceObject.pathToFileURL)(absolutePath));
737
738
  } catch (fallbackError) {
738
739
  const message = fallbackError instanceof Error ? `: ${fallbackError.message}` : '';
@@ -2209,7 +2210,10 @@ A Node may map a string step value to one declared input field. Each Node sectio
2209
2210
  }))
2210
2211
  });
2211
2212
  };
2212
- const CONFIG_NAME = 'midscene.config.ts';
2213
+ const CONFIG_NAMES = [
2214
+ 'midscene.config.ts',
2215
+ 'midscene.config.mjs'
2216
+ ];
2213
2217
  const CONFIG_PREFIX = 'midscene.config.';
2214
2218
  const ALWAYS_IGNORED_PATTERNS = [
2215
2219
  '.git/**',
@@ -2255,13 +2259,19 @@ A Node may map a string step value to one declared input field. Each Node sectio
2255
2259
  const discoverTestConfig = (projectRoot)=>{
2256
2260
  const root = (0, external_node_path_.resolve)(projectRoot);
2257
2261
  const candidates = (0, external_node_fs_.readdirSync)(root).filter((name)=>name.startsWith(CONFIG_PREFIX)).sort();
2258
- const unsupported = candidates.filter((name)=>name !== CONFIG_NAME);
2262
+ const supported = candidates.filter((name)=>CONFIG_NAMES.includes(name));
2263
+ const unsupported = candidates.filter((name)=>!CONFIG_NAMES.includes(name));
2259
2264
  if (unsupported.length > 0) throw new Error([
2260
2265
  `Unsupported or conflicting Midscene configs found in ${root}:`,
2261
2266
  ...candidates.map((name)=>`- ${name}`),
2262
- `Only ${CONFIG_NAME} is supported.`
2267
+ `Only ${CONFIG_NAMES.join(' and ')} are supported.`
2268
+ ].join('\n'));
2269
+ if (supported.length > 1) throw new Error([
2270
+ `Multiple Midscene configs found in ${root}:`,
2271
+ ...supported.map((name)=>`- ${name}`),
2272
+ 'Pass --config <path> to select one explicitly.'
2263
2273
  ].join('\n'));
2264
- return candidates.includes(CONFIG_NAME) ? (0, external_node_path_.join)(root, CONFIG_NAME) : void 0;
2274
+ return supported[0] ? (0, external_node_path_.join)(root, supported[0]) : void 0;
2265
2275
  };
2266
2276
  const defaultResultDir = (projectRoot)=>(0, external_node_path_.join)(projectRoot, '.midscene', 'test-results');
2267
2277
  const padDatePart = (value)=>String(value).padStart(2, '0');