Skip to Content
HeyBug docs
CLI

Runs from the CLI

Use `@@CLI@@ runs` to start a test run from a terminal or CI job, wait for it to finish, cancel it, or list recent runs.

Use heybug runs to start a test run from a terminal or CI job, wait for it to finish, cancel it, or list recent runs. The same runs appear in the dashboard, with the same verdicts and results.

start and list need a project id. Find it in the project's URL, or list your projects with heybug project list. wait and cancel take run ids instead.

Start a run

heybug runs start --project <projectId>

With no test ids, this runs the whole suite. Pass test ids after the command to run only those cases:

heybug runs start TC-12 TC-15 --project <projectId>

Useful flags:

FlagWhat it does
--filter textRuns only the tests whose titles match the text.
--env nameRuns against the project environment with this name. The name is matched without regard to case.
--target-url urlSets the target URL for this run.
--max-concurrency nCaps how many cases run at the same time.
--timeout sStops following the run after this many seconds. 0 means no limit.
--dry-runShows which cases would run, and starts nothing.
--allow-emptyStarts nothing and does not fail when no test matches. Without it, an empty match is an error.
--waitFollows the runs to their verdict. This is the default. Exits 0 when every run passes and 1 otherwise. Cannot be used with --no-wait.
--no-waitStarts the runs and exits at once.
--detachPressing Ctrl-C stops following but leaves the runs going.
--idempotency-key kMakes a retry safe. A repeated key returns the first run instead of starting another.
--output jsonPrints one JSON receipt on stdout instead of text.

While it follows a run, the command prints one line each time a case changes state, with its key, its status and the failing step if there is one. Progress goes to stderr, so stdout stays clean for --output json.

Wait for runs

heybug runs wait <runId...> --timeout 30m

wait starts nothing. It follows one or more runs that are already going, and all of them share one deadline. The default timeout is 30 minutes.

Cancel runs

heybug runs cancel <runId...>

Cancel stops runs that are still going. A run that has already finished keeps its verdict. The receipt marks each run as alreadyFinished or alreadyCancelled, so repeating the command is safe.

Pressing Ctrl-C while start is following a run cancels the runs that command started. Add --detach to keep them running. The command then prints how to follow them again with heybug runs wait.

List recent runs

heybug runs list --project <projectId> --limit 20

This prints the latest runs of a project, newest first, with their number and status. --limit sets how many to show.

Example: a CI job

RUN=$(heybug runs start --project "$HEYBUG_PROJECT" --env staging \
  --filter checkout --idempotency-key "$CI_PIPELINE_ID" \
  --output json --no-wait)
RUN_ID=$(echo "$RUN" | jq -r '.runs[0].runId')
heybug runs wait "$RUN_ID" --timeout 20m --output json > receipt.json

In CI, sign in with heybug auth login --token-stdin and a token from a secret store, and keep the project id in a variable. Read the receipt file afterwards to show per-case results in your CI log.

Receipt shape

With --output json, every command prints one receipt:

{"runs":[{"runId","number","status","dashboardUrl","alreadyCancelled","alreadyFinished"}],
 "results":[{"resultId","caseKey","status","failedStep"}]}

failedStep appears only when a case failed. A dry run also sets "dryRun": true.

Exit codes

CodeMeaning
0Every run passed.
1A run failed, was blocked or was cancelled.
2Bad command or flags.
3Not signed in. Run heybug auth login again.
4Project or run not found.
5Invalid input, such as an unknown --env name.
6The server could not be reached, or wait timed out. Runs that already started keep going.
7Rate limited. Wait and try again.
12Out of credits.
13Blocked by a gate.
130Interrupted.

When something fails

  • "No environment named ... in this project." (exit 5) The --env name does not match an environment in the project. Check the environment names in the project, or drop the flag.
  • Exit 3. Your token is missing or expired. Run heybug doctor to see what is wrong, then heybug auth login.
  • Exit 6 from wait. The timeout passed, or the server could not be reached. The runs are still going. Run heybug runs wait <runId> again, or open the dashboard link from the receipt.
  • Exit 1 from start. At least one case failed. Read the failedStep for each case in the receipt, or open dashboardUrl.
  • "Nothing matched" error. No test matched the filter or the ids. Check the spelling of --filter, or add --allow-empty if an empty run is fine.
  • A retry started a second run. Add the same --idempotency-key to every attempt of the same job. A repeated key returns the earlier run.

From an AI coding agent, the same work runs through the MCP tools heybug_list_runs and heybug_rerun. See the MCP guide for setup.

On this page