@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.
- package/dist/es/1~891.mjs +3 -1
- package/dist/es/1~891.mjs.map +1 -1
- package/dist/es/cli/index.mjs +20 -10
- package/dist/es/cli/index.mjs.map +1 -1
- package/dist/es/test-cli.mjs +20 -10
- package/dist/es/test-cli.mjs.map +1 -1
- package/dist/lib/0~458.js +3 -1
- package/dist/lib/0~458.js.map +1 -1
- package/dist/lib/cli/index.js +20 -10
- package/dist/lib/cli/index.js.map +1 -1
- package/dist/lib/test-cli.js +20 -10
- package/dist/lib/test-cli.js.map +1 -1
- package/package.json +8 -8
package/dist/es/test-cli.mjs
CHANGED
|
@@ -717,11 +717,12 @@ const validateTestProjectDefinition = (definition)=>{
|
|
|
717
717
|
resolveNode: (name)=>nodes.get(name)
|
|
718
718
|
};
|
|
719
719
|
};
|
|
720
|
-
const
|
|
721
|
-
if (!absolutePath.endsWith('.ts')) {
|
|
720
|
+
const assertSupportedConfig = (absolutePath)=>{
|
|
721
|
+
if (!absolutePath.endsWith('.ts') && !absolutePath.endsWith('.mjs')) {
|
|
722
722
|
const extension = absolutePath.match(/(\.[^./\\]+)$/)?.[1] ?? '(none)';
|
|
723
|
-
throw new TypeError(`Unsupported Midscene config extension: ${extension}. Supported
|
|
723
|
+
throw new TypeError(`Unsupported Midscene config extension: ${extension}. Supported extensions: .ts, .mjs.`);
|
|
724
724
|
}
|
|
725
|
+
return absolutePath.endsWith('.mjs') ? '.mjs' : '.ts';
|
|
725
726
|
};
|
|
726
727
|
const canRetryWithCjsLoader = (error)=>{
|
|
727
728
|
if (!(error instanceof Error)) return false;
|
|
@@ -733,16 +734,16 @@ async function loadTestProject(configPath) {
|
|
|
733
734
|
nodes: []
|
|
734
735
|
});
|
|
735
736
|
const absolutePath = (0, external_node_path_.resolve)(configPath);
|
|
736
|
-
|
|
737
|
+
const extension = assertSupportedConfig(absolutePath);
|
|
737
738
|
let loaded;
|
|
738
739
|
try {
|
|
739
|
-
loaded = await tsImport(pathToFileURL(absolutePath).href, {
|
|
740
|
+
loaded = '.mjs' === extension ? await import(pathToFileURL(absolutePath).href) : await tsImport(pathToFileURL(absolutePath).href, {
|
|
740
741
|
parentURL: pathToFileURL(`${(0, external_node_path_.dirname)(absolutePath)}${external_node_path_.sep}`).href,
|
|
741
742
|
tsconfig: false
|
|
742
743
|
});
|
|
743
744
|
} catch (error) {
|
|
744
745
|
try {
|
|
745
|
-
if (!canRetryWithCjsLoader(error)) throw error;
|
|
746
|
+
if ('.mjs' === extension || !canRetryWithCjsLoader(error)) throw error;
|
|
746
747
|
loaded = api_require(absolutePath, pathToFileURL(absolutePath));
|
|
747
748
|
} catch (fallbackError) {
|
|
748
749
|
const message = fallbackError instanceof Error ? `: ${fallbackError.message}` : '';
|
|
@@ -2213,7 +2214,10 @@ const writeTestProjectRunResult = (options)=>{
|
|
|
2213
2214
|
}))
|
|
2214
2215
|
});
|
|
2215
2216
|
};
|
|
2216
|
-
const
|
|
2217
|
+
const CONFIG_NAMES = [
|
|
2218
|
+
'midscene.config.ts',
|
|
2219
|
+
'midscene.config.mjs'
|
|
2220
|
+
];
|
|
2217
2221
|
const CONFIG_PREFIX = 'midscene.config.';
|
|
2218
2222
|
const ALWAYS_IGNORED_PATTERNS = [
|
|
2219
2223
|
'.git/**',
|
|
@@ -2259,13 +2263,19 @@ const discoverTestFiles = (projectRoot, selection = DEFAULT_TEST_FILE_SELECTION)
|
|
|
2259
2263
|
const discoverTestConfig = (projectRoot)=>{
|
|
2260
2264
|
const root = (0, external_node_path_.resolve)(projectRoot);
|
|
2261
2265
|
const candidates = (0, external_node_fs_.readdirSync)(root).filter((name)=>name.startsWith(CONFIG_PREFIX)).sort();
|
|
2262
|
-
const
|
|
2266
|
+
const supported = candidates.filter((name)=>CONFIG_NAMES.includes(name));
|
|
2267
|
+
const unsupported = candidates.filter((name)=>!CONFIG_NAMES.includes(name));
|
|
2263
2268
|
if (unsupported.length > 0) throw new Error([
|
|
2264
2269
|
`Unsupported or conflicting Midscene configs found in ${root}:`,
|
|
2265
2270
|
...candidates.map((name)=>`- ${name}`),
|
|
2266
|
-
`Only ${
|
|
2271
|
+
`Only ${CONFIG_NAMES.join(' and ')} are supported.`
|
|
2272
|
+
].join('\n'));
|
|
2273
|
+
if (supported.length > 1) throw new Error([
|
|
2274
|
+
`Multiple Midscene configs found in ${root}:`,
|
|
2275
|
+
...supported.map((name)=>`- ${name}`),
|
|
2276
|
+
'Pass --config <path> to select one explicitly.'
|
|
2267
2277
|
].join('\n'));
|
|
2268
|
-
return
|
|
2278
|
+
return supported[0] ? (0, external_node_path_.join)(root, supported[0]) : void 0;
|
|
2269
2279
|
};
|
|
2270
2280
|
const defaultResultDir = (projectRoot)=>(0, external_node_path_.join)(projectRoot, '.midscene', 'test-results');
|
|
2271
2281
|
const padDatePart = (value)=>String(value).padStart(2, '0');
|