@midscene/cli 1.13.1-beta-20260922030100.0 → 1.13.1
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 +51 -31
- package/dist/es/framework/index.mjs.map +1 -1
- package/dist/es/index.mjs +66 -33
- package/dist/es/index.mjs.map +1 -1
- package/dist/lib/framework/index.js +51 -31
- package/dist/lib/framework/index.js.map +1 -1
- package/dist/lib/index.js +66 -33
- package/dist/lib/index.js.map +1 -1
- package/dist/types/framework/index.d.ts +2 -0
- package/package.json +10 -10
|
@@ -2719,6 +2719,7 @@ var __webpack_exports__ = {};
|
|
|
2719
2719
|
console.log(` Continue on error: ${config.continueOnError}`);
|
|
2720
2720
|
console.log(` Retry: ${config.retry ?? 0}`);
|
|
2721
2721
|
console.log(` Share browser context: ${config.shareBrowserContext ?? false}`);
|
|
2722
|
+
console.log(` Reuse browser page: ${config.reusePage ?? false}`);
|
|
2722
2723
|
console.log(` Summary output: ${config.summary}`);
|
|
2723
2724
|
}
|
|
2724
2725
|
function printExecutionFinished() {
|
|
@@ -3422,11 +3423,22 @@ var __webpack_exports__ = {};
|
|
|
3422
3423
|
}
|
|
3423
3424
|
if (setupContext && !shareBrowserContext && 'puppeteer-web' === resolveBatchRuntimeTarget(setupContext.executionConfig)) throw new Error(`Puppeteer Web setup "${setupContext.file}" requires shareBrowserContext: true so its browser state can be shared with the main files.`);
|
|
3424
3425
|
};
|
|
3425
|
-
const createSharedBrowserRuntime = async (browser, browserContextOptions)=>{
|
|
3426
|
+
const createSharedBrowserRuntime = async (browser, browserContextOptions, reusePage = false)=>{
|
|
3426
3427
|
const browserContext = await browser.createBrowserContext(browserContextOptions);
|
|
3427
|
-
|
|
3428
|
-
browserContext
|
|
3429
|
-
|
|
3428
|
+
try {
|
|
3429
|
+
const page = reusePage ? await browserContext.newPage() : void 0;
|
|
3430
|
+
return {
|
|
3431
|
+
browserContext,
|
|
3432
|
+
page
|
|
3433
|
+
};
|
|
3434
|
+
} catch (error) {
|
|
3435
|
+
try {
|
|
3436
|
+
await browserContext.close();
|
|
3437
|
+
} catch (cleanupError) {
|
|
3438
|
+
batchWarning('failed to close the shared browser context after page creation failed; preserving the original error', cleanupError);
|
|
3439
|
+
}
|
|
3440
|
+
throw error;
|
|
3441
|
+
}
|
|
3430
3442
|
};
|
|
3431
3443
|
class YamlBatchExecutor {
|
|
3432
3444
|
async run(options = {}) {
|
|
@@ -3511,10 +3523,11 @@ var __webpack_exports__ = {};
|
|
|
3511
3523
|
sharedRuntime.current = null;
|
|
3512
3524
|
await staleRuntime.browserContext.close();
|
|
3513
3525
|
}
|
|
3514
|
-
sharedRuntime.current = await createSharedBrowserRuntime(browser, browserContextOptions);
|
|
3526
|
+
sharedRuntime.current = await createSharedBrowserRuntime(browser, browserContextOptions, this.config.reusePage);
|
|
3515
3527
|
for (const context of allContexts){
|
|
3516
3528
|
context.options.browser = browser;
|
|
3517
3529
|
context.options.browserContext = sharedRuntime.current.browserContext;
|
|
3530
|
+
if (sharedRuntime.current.page) context.options.page = sharedRuntime.current.page;
|
|
3518
3531
|
}
|
|
3519
3532
|
};
|
|
3520
3533
|
await resetSetupRuntime();
|
|
@@ -3794,6 +3807,8 @@ var __webpack_exports__ = {};
|
|
|
3794
3807
|
}, (_, index)=>`batch-occurrence-${index + 1}`);
|
|
3795
3808
|
if (this.caseIds.length !== occurrenceCount) throw new Error(`Batch occurrence identity mismatch: expected ${occurrenceCount} case ID(s), received ${this.caseIds.length}`);
|
|
3796
3809
|
if (new Set(this.caseIds).size !== this.caseIds.length) throw new Error('Batch occurrence case IDs must be unique');
|
|
3810
|
+
if (config.reusePage && !config.shareBrowserContext) throw new Error('reusePage requires shareBrowserContext: true');
|
|
3811
|
+
if (config.reusePage && 1 !== config.concurrent) throw new Error('reusePage requires concurrent: 1');
|
|
3797
3812
|
}
|
|
3798
3813
|
}
|
|
3799
3814
|
async function runYamlBatch(config, options = {}) {
|
|
@@ -4029,29 +4044,26 @@ defineYamlBatchTest(test, testOptions);
|
|
|
4029
4044
|
};
|
|
4030
4045
|
}
|
|
4031
4046
|
var external_node_url_ = __webpack_require__("node:url");
|
|
4047
|
+
const error_formatter_namespaceObject = require("@midscene/shared/agent-tools/error-formatter");
|
|
4032
4048
|
var progress_reporter = __webpack_require__("./src/framework/progress-reporter.ts");
|
|
4033
4049
|
var rstest_contract = __webpack_require__("./src/framework/rstest-contract.ts");
|
|
4034
|
-
const formatRunError = (error)=>error.stack || `${error.name}: ${error.message}`;
|
|
4050
|
+
const formatRunError = (error)=>error.stack || `${error.name || 'Error'}: ${error.message}`;
|
|
4035
4051
|
const collectRunErrors = (result)=>{
|
|
4036
4052
|
const messages = [];
|
|
4037
4053
|
const push = (error, label)=>{
|
|
4038
4054
|
const formatted = formatRunError(error);
|
|
4039
4055
|
messages.push(label ? `${label}: ${formatted}` : formatted);
|
|
4040
4056
|
};
|
|
4041
|
-
for (const file of result.
|
|
4057
|
+
for (const file of result.results){
|
|
4042
4058
|
for (const error of file.errors ?? [])push(error, file.name || file.testPath);
|
|
4043
4059
|
for (const testResult of file.results ?? [])for (const error of testResult.errors ?? [])push(error, testResult.name);
|
|
4044
4060
|
}
|
|
4045
|
-
for (const error of result.unhandledErrors
|
|
4061
|
+
for (const error of result.unhandledErrors)push(error);
|
|
4046
4062
|
return Array.from(new Set(messages));
|
|
4047
4063
|
};
|
|
4048
4064
|
const rstest_runner_errorMessage = (error)=>error.message || error.name || 'YAML case failed';
|
|
4049
4065
|
const mapRunErrorsToCases = (project, result)=>{
|
|
4050
|
-
const
|
|
4051
|
-
item.caseId,
|
|
4052
|
-
item
|
|
4053
|
-
]));
|
|
4054
|
-
const knownCaseIds = new Set(casesById.keys());
|
|
4066
|
+
const knownCaseIds = new Set(project.cases.map((item)=>item.caseId));
|
|
4055
4067
|
const errors = new Map();
|
|
4056
4068
|
const add = (caseId, message)=>{
|
|
4057
4069
|
if (knownCaseIds.has(caseId) && message && !errors.has(caseId)) errors.set(caseId, message);
|
|
@@ -4074,7 +4086,7 @@ defineYamlBatchTest(test, testOptions);
|
|
|
4074
4086
|
const value = testResult.meta?.[rstest_contract.k];
|
|
4075
4087
|
return Array.isArray(value) ? value.filter((item)=>'string' == typeof item) : [];
|
|
4076
4088
|
};
|
|
4077
|
-
for (const file of result.
|
|
4089
|
+
for (const file of result.results){
|
|
4078
4090
|
const moduleCaseIds = findModuleCaseIds(file);
|
|
4079
4091
|
for (const error of file.errors ?? [])addCases(moduleCaseIds, rstest_runner_errorMessage(error));
|
|
4080
4092
|
for (const testResult of file.results ?? []){
|
|
@@ -4082,18 +4094,13 @@ defineYamlBatchTest(test, testOptions);
|
|
|
4082
4094
|
for (const error of testResult.errors ?? [])addCases(caseIds.length ? caseIds : moduleCaseIds, rstest_runner_errorMessage(error));
|
|
4083
4095
|
}
|
|
4084
4096
|
}
|
|
4085
|
-
if (
|
|
4097
|
+
if (result.unhandledErrors.length) {
|
|
4086
4098
|
const message = rstest_runner_errorMessage(result.unhandledErrors[0]);
|
|
4087
|
-
for (const
|
|
4088
|
-
const item = casesById.get(caseId);
|
|
4089
|
-
if (!errors.has(caseId) || item && !(0, external_node_fs_.existsSync)(item.resultFile)) errors.set(caseId, message);
|
|
4090
|
-
}
|
|
4099
|
+
for (const item of project.cases)if (!errors.has(item.caseId) && !(0, external_node_fs_.existsSync)(item.resultFile)) errors.set(item.caseId, message);
|
|
4091
4100
|
}
|
|
4092
4101
|
return errors;
|
|
4093
4102
|
};
|
|
4094
|
-
const
|
|
4095
|
-
if (!project.cases.length) return;
|
|
4096
|
-
const caseErrors = mapRunErrorsToCases(project, result);
|
|
4103
|
+
const writePendingCaseFailures = (project, caseErrors)=>{
|
|
4097
4104
|
for (const item of project.cases){
|
|
4098
4105
|
if ((0, external_node_fs_.existsSync)(item.resultFile)) continue;
|
|
4099
4106
|
const error = caseErrors.get(item.caseId);
|
|
@@ -4115,13 +4122,13 @@ defineYamlBatchTest(test, testOptions);
|
|
|
4115
4122
|
}
|
|
4116
4123
|
};
|
|
4117
4124
|
async function runRstestYamlProject(options) {
|
|
4118
|
-
const [{
|
|
4125
|
+
const [{ createRstest }, { rspack }] = await Promise.all([
|
|
4119
4126
|
import("@rstest/core/api"),
|
|
4120
4127
|
import((0, external_node_url_.pathToFileURL)(resolvePackageFromRstestCore('@rsbuild/core')).href)
|
|
4121
4128
|
]);
|
|
4122
4129
|
const { project } = options;
|
|
4123
4130
|
const maxConcurrency = void 0 !== project.maxConcurrency ? Math.max(1, project.maxConcurrency) : void 0;
|
|
4124
|
-
const
|
|
4131
|
+
const config = {
|
|
4125
4132
|
root: project.projectDir,
|
|
4126
4133
|
include: project.modules.map((item)=>item.id),
|
|
4127
4134
|
testEnvironment: 'node',
|
|
@@ -4152,18 +4159,31 @@ defineYamlBatchTest(test, testOptions);
|
|
|
4152
4159
|
}
|
|
4153
4160
|
}
|
|
4154
4161
|
};
|
|
4155
|
-
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
|
|
4159
|
-
|
|
4160
|
-
|
|
4162
|
+
let result;
|
|
4163
|
+
try {
|
|
4164
|
+
const rstest = await createRstest({
|
|
4165
|
+
cwd: options.cwd || project.projectDir,
|
|
4166
|
+
config
|
|
4167
|
+
});
|
|
4168
|
+
result = await rstest.run();
|
|
4169
|
+
} catch (error) {
|
|
4170
|
+
const serialized = (0, error_formatter_namespaceObject.serializeError)(error);
|
|
4171
|
+
writePendingCaseFailures(project, new Map(project.cases.map((item)=>[
|
|
4172
|
+
item.caseId,
|
|
4173
|
+
serialized.message
|
|
4174
|
+
])));
|
|
4175
|
+
if ('pipe' !== options.stdio) console.error(`\nYAML execution failed:\n${formatRunError(serialized)}`);
|
|
4176
|
+
return 1;
|
|
4177
|
+
}
|
|
4178
|
+
const ok = 'pass' === result.status;
|
|
4179
|
+
if (!ok) {
|
|
4180
|
+
writePendingCaseFailures(project, mapRunErrorsToCases(project, result));
|
|
4161
4181
|
if ('pipe' !== options.stdio) {
|
|
4162
4182
|
const runErrors = collectRunErrors(result);
|
|
4163
4183
|
if (runErrors.length) console.error(`\nYAML execution failed:\n${runErrors.join('\n\n')}`);
|
|
4164
4184
|
}
|
|
4165
4185
|
}
|
|
4166
|
-
return
|
|
4186
|
+
return ok ? 0 : 1;
|
|
4167
4187
|
}
|
|
4168
4188
|
const defaultInProcessRunner = (config)=>new BatchRunner(config).run();
|
|
4169
4189
|
async function runConfigInMainProcess(config, commandOptions) {
|