Migrate to Midscene Test
Legacy YAML and native Midscene Test share the same underlying execution kernel and report page, but they have separate user-facing entries. The midscene command owns legacy tasks/flow files, YAML batch configuration, and legacy CLI options. The midscene-test command owns native cases/steps files, TypeScript or JavaScript project configuration, lifecycle hooks, and Nodes.
In this guide, “legacy YAML” specifically means the YAML automation protocol from @midscene/cli, not every YAML file. It typically has these characteristics: the workflow has top-level tasks and sequences actions through tasks[].flow; platform, Agent, and output configuration is written directly in workflow YAML; batch execution uses YAML configuration with fields such as files, setup, concurrent, and retry; and the entry command is midscene. A file with top-level cases/steps and lifecycle hooks that runs through midscene-test is native Test YAML, not legacy YAML.
The legacy path receives compatibility maintenance and necessary fixes only. It will not receive new syntax, capabilities, configuration fields, or CLI options. Use native Midscene Test for new projects, new cases, and future capability development; existing legacy projects can continue to run and migrate gradually.
There are two migration paths:
- Upgrade in place: keep legacy cases, batch configuration, directory layout, and the
midscenecommand unchanged. This adopts the shared execution kernel and new report without changing the input contract. - Native migration: rewrite complete files as Test Documents, Cases, and Steps; replace batch YAML with project configuration; then switch those files to
midscene-test.
The complete legacy field reference remains available in YAML script runner and Workflow in YAML format for maintaining and migrating existing projects.
Path 1: upgrade legacy execution in place
If the project already uses @midscene/cli, upgrade it and keep the existing command. midscene preserves the legacy input contract while executing through the shared kernel and generating the new report page:
Platform configuration, agent, environment interpolation, task continuation, whole-file retries, output files, and summary retain their legacy semantics. Reports use the new Test page; existing HTML files need no conversion, so rerun to regenerate them. Legacy agent.generateReport: false remains respected.
Legacy flags such as --files, --setup, --concurrent, --retry, --continue-on-error, --summary, --headed, --keep-window, --share-browser-context, --dotenv-override, --dotenv-debug, --<target>.<field>, and --no-<target>.<field> remain accepted by midscene. They are not midscene-test options and do not appear in its help.
midsceneaccepts only legacytasks/flowworkflow files and YAML batch configuration.midscene-testaccepts only nativecases/stepsworkflow files and TypeScript or JavaScript project configuration.- A YAML file cannot mix legacy
taskswith nativecasesor lifecycle hooks. - One command invocation cannot select both formats. During gradual migration, keep them in separate directories or file selections and run two commands.
--project,--result-dir, andmidscene-test nodesapply only to native Test projects. Legacy scheduling and platform flags remain onmidscene.
Both commands validate this boundary before creating browser, device, or Agent resources. They report the wrong-format files and point to the matching command instead of silently rerouting them.
Path 2: migrate to a native Test project
Use the following order so each step can be run and compared independently:
- Run the existing project with
midsceneand save its exit status, summary, and new report as a baseline. - Use
pnpm dlx @midscene/test createto create a Test project for the target platform. Start with the generatedmidscene.config.tsand setup. - Map the legacy batch configuration to an Execution Project. Move platform, Agent, and resource creation into setup.
- Convert one complete
tasks/flowfile tocases/steps, move it into the native file selection, and run it withmidscene-test. Keep unconverted files onmidscene. - Run
pnpm exec midscene-test nodes --project <name>to generate the current Project's Node Spec, then validate action names, inputs, and string shorthand against it. - After all files are converted, remove the legacy batch configuration, legacy command, and legacy-only command-line options.
Case structure mapping
Legacy YAML:
Native Test:
Keeping old files unchanged preserves their failure policy. Rewriting them as native Cases adopts native semantics; it is not an exact scheduling equivalence. Step $: { continue-on-error: true } continues later Steps in that phase, not later legacy tasks, and does not make a failed Case pass.
Flow action mapping
The legacy runtime keeps accepting the fields in the left column and adapts them internally to the shared kernel. That internal adaptation is not a native Test input contract. When migrating a file, write the native form in the right column and use the Nodes registered in the project's midscene-node-reference.md as the source of truth.
Concrete example: migrate one order-submission Case
The following legacy case fills in a recipient, waits for the submit button, submits the order, and records the result. It uses task failure policy, an action alias, locate input, action timeout, an assertion message, a fixed wait, and report recording:
The same Case in native Test YAML is:
The conversion has several parts:
web.urlno longer sits beside case content. Project setup creates the browser. Because every Case must start on the checkout page,gotoUrlinbeforeEachowns the URL.- The task becomes a Case. Native Test already continues after a failed Case, so this example needs no continuation option.
- The
aiInputvalue and locate description move from legacy sibling fields to the Node'svalueandprompt. aiWaitFor.timeoutlimits that wait operation, so it becomesoptions.timeoutMs. To limit the complete Step instead, use$: { timeout: 10000 }.aibecomesaiAct, andaiAssert.errorMessagebecomesaiAssert.message.- The fixed delay uses the native common
waitNode. The report title and body move torecordToReport.titleandoptions.content.
This example changes the input structure without changing business execution order. During a real migration, run pnpm exec midscene-test nodes --project <name> to generate the current Project's midscene-node-reference.md. Use this Node Spec—not examples from another platform—to confirm whether gotoUrl, aiInput, aiWaitFor, and the other referenced Nodes are available and how to provide their inputs.
Script and Agent configuration mapping
midscene continues to read top-level legacy YAML configuration. In a native migration, move these fields out of Case YAML and into midscene.config.ts, setup, or Nodes:
See Configure the runtime environment for complete setup and platform Node registration examples.
Batch configuration mapping
Legacy batch.yaml:
Native Test moves execution settings into midscene.config.ts:
This native example selects files and adopts Case retries; it does not preserve the old setup-file or concurrent-file scheduling. For parallel native execution, split files across independent Projects and use test.maxConcurrency. Legacy file concurrency and document setup stay behind the midscene entry and are not public Test configuration.
The midscene entry preserves legacy output naming: explicit flow name values, numeric keys for unnamed extracted results, and the existing overwrite behavior for duplicate names.
Validate the migration
Run the legacy version with midscene and the converted version with midscene-test, then compare at least:
- Process exit status and continuation after a failure.
- Whether retries apply to one Case or the complete file.
- Environment variables, platform connection settings, and initial page state.
- AI action inputs, timeouts, and assertion failure messages.
- Business output consumers and Step results in the new Test report.
- Page, Agent, device, and test-data isolation during concurrent execution.
- Lifecycle hooks and resource cleanup after failures, timeouts, and Ctrl+C interruption.
After migration, write new cases with cases/steps. Keep tasks/flow only in files that have not yet been migrated so the compatibility format does not expand into new code.

