CLI overview

The motionpr command, its global options, output modes and exit codes.

On this page
  1. Global options
  2. Exit codes
  3. JSON output
Shell
npx motionpr <command> [options]
CommandWhat it does
initCreate motionpr.config.ts with a guided setup
installDownload Chromium, Firefox or WebKit for MotionPR
captureCapture the configured scenarios
compareCompare two captures and generate the report
runCapture, compare with the baseline, report: the everyday command
baselineApprove a capture as its engine's baseline (accept), show them (status), move a 0.1 baseline (migrate)
reportOpen the most recent report, regenerating it if needed
doctorCheck Node.js, the browsers, the config, permissions and adapters
demoCapture the bundled demo app in two versions and open a real report

Global options

OptionDescription
-c, --config <path>Config file (default: motionpr.config.{ts,mts,cts,js,mjs,cjs} in the working directory)
--cwd <dir>Run as if started in <dir>
--env <name>Apply environments[name] from the config (also MOTIONPR_ENV)
--jsonMachine-readable result on stdout; human output goes to stderr
-q, --quietOnly print errors
--verbosePrint diagnostics and debug details (and error causes)
--no-colorDisable colours (also NO_COLOR=1; FORCE_COLOR=1 forces them)
--ciNon-interactive CI mode (also detected from CI, GITHUB_ACTIONS, GITLAB_CI, BUILDKITE)

capture, compare, run, baseline accept, report, doctor and demo also take --browser <name>: chromium, firefox, webkit, all, or a comma list (repeatable). Without it, the engine is MOTIONPR_BROWSER or the config's browser.name. See Cross-browser testing. | -v, --version | Print the version | | -h, --help | Help for any command |

MotionPR never prompts in CI or when stdin or stderr is not a terminal. Where it would ask, it takes the safe answer and says which flag confirms the action: baseline accept refuses to replace a baseline without --yes (exit 2), and init leaves an existing config untouched without --force.

Exit codes

CodeMeaning
0Success; the comparison is within the configured thresholds
1A configured regression threshold was exceeded (comparison.failOn, --threshold)
2Configuration, execution or comparison error, including usage errors
130 / 143Interrupted by Ctrl+C / SIGTERM, after servers and the browser were shut down

See CI exit codes for how run decides between them.

JSON output

With --json, a command prints exactly one JSON document to stdout:

CommandShape
run, compareThe ComparisonResult plus report (and browser, capture for run)
run without baseline{ status: "no-baseline", browser, capture, report }
run with several engines{ kind: "motionpr-run", exitCode, reportIndex, browsers: [{ browser, status, exitCode, capture, report, summary, differences, error }] }
compare with several engines{ kind: "motionpr-comparisons", comparisons: [ComparisonResult + report] }
capture{ id, dir, browser, scenarios: [{ key, status, checkpoints, error }] }; several engines: { captures: [ … ] }
baseline status{ baseline, baselines: { chromium, firefox, webkit } }
doctor{ ok, checks: [{ name, status, detail, fix }] }
errors{ error: { code, message, hint, issues } }
Shell
npx motionpr run --json > motionpr.json; echo "exit $?"
jq '.summary.counts' motionpr.json