kane-cli testmd command family: how to run a test, what the flags do, how replay works, what shows up in the output directory, and what the exit codes mean.
To learn the _test.md file format, see Writing test.md files. To reuse flows across tests, see Composing tests with @import.
Commands
tags:, use kane-cli testrun run.
In a TTY, kane-cli testmd with no subcommand opens an interactive picker that walks the current directory and lets you pick a _test.md to run.
kane-cli testmd run
The main command. Point it at a _test.md file and it runs:
Flag reference
Every flag accepted bykane-cli testmd run:
Most flags have a frontmatter key with the same name, written with underscores. When both are set, the CLI flag wins. The exception is
variables: values in the file win. See Writing test.md files.
Before any step runs, kane-cli checks every {{name}} used by the authored steps against the file’s own variables: frontmatter, the variable files, --variables-file, and --variables. A name with no value prints a warning that names the variable, the file where its value belongs, and the step. The run then continues, and the name is typed literally as written unless an earlier step sets its value. Replayed steps are not checked. See Before a run.
How a run works
A run proceeds in four phases:- Parse: kane-cli reads the
_test.mdfile (and any helper it imports) and validates frontmatter, step bodies, and the@importgraph. Parse errors abort here with exit2; no browser is launched. - Decide replay vs author per step: for each step, kane-cli decides whether to replay a cached recording or author a fresh one. See Replay vs author.
- Execute: kane-cli launches Chrome and works through every step in order. Each step either replays its cached recording or asks the agent to figure it out.
- Finalize: kane-cli writes
Result.md, saves recordings, uploads the run to Test Manager, and (if enabled) generates code export.
Replay vs author
The first time you run a_test.md, every step is authored: the agent works out how to satisfy the objective and a recording is saved next to the test. On every later run, kane-cli tries to replay the saved recording for each step, with no agent involved and no LLM cost, so the run is much faster.
An authorable step replays only when all of the following are true. (Steps marked replay-only always replay, so these conditions do not apply to them.)
- A recording exists for it on disk.
- The step’s objective text has not changed since the recording.
- The step’s
yamlblock has not changed since the recording. - No earlier step in the same file invalidated it (see below).
Edits cascade to the rest of the file
Editing one step re-records that step and every authorable step after it in the same file. Steps marked replay-only still replay. This is because each step starts where the previous step left off (same browser, same URL, same logged-in state). If you change step 3, the page state that step 4 expects may be different, so replaying step 4 from cache is not safe. As a result, a small text fix at the top of a test can re-author every authorable step in the file. If you are iterating on a test and want only the last step to re-record, edit that last step.Forcing a fresh recording
To author everything again:--author: skips the replay decision for one run. Every authorable step is authored again; steps marked replay-only still replay.- Keep the output recordings for steps marked replay-only. Deleting them does not make those steps author again.
Handling replay failures
A replay can fail if the site has changed: a button moved, the page is slower than expected, or an extra modal appears. The healing policy controls recovery:- Adaptive healing is on by default. The runner retries smaller and smaller replay windows (up to three), then re-authors the authorable steps. Pass
--no-adaptive-healto turn it off. See Replay policy and completion.
Replays don’t need a project or folder
When every step of an already-authored test replays from cache, you do not need a Test Manager project or folder configured. kane-cli shows no interactive picker and creates no project: the test already records where it belongs, and the replay runs with that identity. Authoring runs (first runs, edited steps,--author) still resolve a project and folder.
Run mode
The--mode flag controls how the agent handles authentication walls, blocked pages, and error pages. The same setting can be put in frontmatter as mode: (root-only).
testing(default): the agent treats those pages as part of the run and continues. This lets negative tests (for example, “verify the error message is shown”) work, because the run does not stop at the first error page.action: the agent stops on auth, blocked, and error pages so a person can step in before the run continues.
testing is the right default for automated suites; action is for one-off authoring sessions where you want manual control.
The output directory
A successful run writes everything it needs to replay next time intooutput-<stem>/ next to the test file, where <stem> is the filename without _test.md:
Result.md is the human-readable run report. .internal/ holds the recordings kane-cli replays on the next run. The whole output-<stem>/ directory is safe (and recommended) to commit to git: it makes your tests reproducibly replayable on any teammate’s machine and on CI.
For tests that @import helpers, kane-cli also writes one helper-output-... directory per call site next to the helper file. See Composing tests with @import.
The evidence pack
Besides the output directory, everytestmd run seals an evidence pack (screenshots, per-step console and network logs, and failure records for the whole run) and copies it into <cwd>/.testmuai/evidence/. In a terminal, kane-cli offers to open it in the browser viewer at the end of the run. Replayed runs also publish their pack to your project’s execution history in Test Manager. Do not commit .testmuai/evidence/ to git. Packs are run artifacts, not test sources.
Result.md
Result.md is generated on every run. It is intended to be read in a browser or editor. Drop it into any Markdown viewer.
The file begins with frontmatter:
When an
@import step fails, the badge points at the failing leaf inside the helper, e.g. ✗ failed (via @import ./helpers/login.md — at sub-step 2 → 3, 8s → ./helpers/helper-output-login-checkout-3). The sub-step chain walks from the import down to the actual failing step.
Exit codes
Use these to gate downstream CI steps.
Lock conflicts
Each test in Test Manager has a single-writer lock so two engineers cannot author the same test at the same time. When you run a test and someone else already holds the lock,--on-lock-conflict decides what to do:
The lock is acquired before Chrome launches, so a
fail policy aborts with zero side effects.
Code export
kane-cli testmd run can generate runnable Playwright code from a successful run. Enable it via frontmatter:
output-<stem>/playwright-<lang>-code/. Code export runs only after a successful Test Manager upload, so it is only useful when a project and folder are configured.
For the configurable options (default language, validation toggle, persistent enable from the TUI), see Configuration.
Running in CI
A CI-friendly invocation:--agent: plain NDJSON to stdout, with no interactive terminal UI. It turns on automatically when stdin is not a TTY, but pass it explicitly for clarity.--headless: Chrome runs without a window.--on-lock-conflict wait: block instead of failing if a teammate is editing the same test.- Adaptive healing recovers from replay failures by default; pass
--no-adaptive-healto turn it off.
ask_user prompt, so kane-cli disables it: a step that would otherwise wait for input fails cleanly instead of blocking forever. Write test steps that do not depend on mid-run prompts when running in CI.
If the runner cannot have Chrome at all, run the tests as a suite on the cloud grid instead. kane-cli testrun run --match '^tests/' --remote executes every testmd run on a HyperExecute macOS runner and returns the recordings and the evidence pack. See Remote Runs.
Capture exit code in a shell script:
--agent mode. Each line is a JSON object you can parse in a downstream step.
kane-cli testmd list
Walks the current directory and prints every *_test.md file it finds:
kane-cli testmd status <path>
Shows the Test Manager identity of a recorded test: the project, the folder, the testcase ID, and whether the local recordings are in sync with the last upload.
kane-cli testmd delete <path>
Removes the test source and its output-<stem>/ directory:
kane-cli testmd export <path>
Regenerates the code export from existing recordings without re-running the test:
kane-cli testmd sync <path>
Pushes a test’s replay bundle to the cloud: the _test.md itself, every helper it @imports, and the replay-required outputs (Result.md, recordings). The bundle is tied to the test’s last commit.
You rarely need to run this yourself: after every successful authored commit, kane-cli pushes the same bundle automatically. Use the manual command to re-sync a test when the automatic push failed (for example, because the network dropped at the end of a run).
Replay policy and completion
Adaptive healing is on by default. After a replay failure, the runner tries up to three smaller and smaller replay windows, then fully re-authors the authorable steps.--no-adaptive-heal turns this recovery off. The --retry and --retry-count flags are accepted but have no effect: they only print a notice, and they do not turn on healing or change its fixed number of attempts.
Steps whose heading is marked @db, @api, @js, @smartui, @network_query, or @network_assertion are replay-only. They still replay under --author, when an earlier step changes, and during adaptive healing. If a replay-only step’s recording is missing, kane-cli cannot re-author it from the marker: restore the recording, or recreate it with the workflow that originally produced it. Do not delete these recordings to force authoring. Adding a marker to a heading does not create the operation.
Structured control flow uses heading markers that must be balanced: @if, @elif, @else, @end-if, @while, @end-while. An @else must be the last branch in its conditional, and each end marker must match the type of block it closes. These markers are separate from conditionals written in natural language. The markers themselves are not included in the step body hash. A step can have only one replay-only marker, and an @import step cannot also be marked replay-only.
Under --agent, wait for both the test_md_done event (which carries the file-level overall_status, duration_s, session_id, and an optional share_url) and the process exit. Individual run_end events do not mean the file is complete.
Next steps
- Writing test.md files: file format, frontmatter, steps, variables.
- Batch runs with testrun: run many tests as one execution with one evidence pack.
- Evidence packs: what every run captures and how to view it.
- Composition with @import: reusable helpers across tests.
- Configuration: persistent settings: Chrome profile, window size, code export defaults.
- Test Manager integration: what happens during the upload.