UI Inspect
CLI Reference

build

Capture screenshots and run visual regression comparisons against baselines.

The build command is the primary command for visual regression testing. It captures screenshots, compares them against baselines, and reports results.

Usage

npx ui-inspect build [options]

Options

FlagTypeDefaultDescription
--project <id>stringconfig fileProject ID from dashboard
--branch <name>stringauto-detectGit branch name
--commit <sha>stringauto-detectCommit SHA
--base-url <url>stringhttp://localhost:3000Base URL for screenshots
--dir <path>stringLoad screenshots from directory instead of capturing
--jsonbooleanfalseOutput results as JSON
--dry-runbooleanfalseRun without uploading results
--skip-capturebooleanfalseSkip screenshot capture phase
--threshold <n>number0.1Pixel diff threshold (0-1)
--fail-on-diffbooleanfalseExit with code 1 if diffs found
--auto-approvebooleanfalseAuto-approve new baselines
--reportbooleanfalsePost PR comment with results
--pr <number>numberGitHub PR number for reporting
--turbosnapbooleanfalseEnable smart snapshot filtering
--base-branch <name>stringmainBase branch for TurboSnap

How it works

  1. Creates a build record in the database
  2. TurboSnap analysis (optional) — determines which screenshots need re-testing based on git changes
  3. Captures screenshots — launches Puppeteer, navigates to each URL, captures at each viewport
  4. Fetches baselines — retrieves existing baseline images for comparison
  5. Runs smart diff — SSIM perceptual comparison + pixel matching + anti-flake filtering + layout shift detection
  6. Batch creates comparisons — uploads all results
  7. Finalizes build — calculates totals, determines pass/fail
  8. Auto-approve (optional) — approves screenshots without existing baselines
  9. PR comment (optional) — posts results to GitHub PR

Examples

Basic visual test

npx ui-inspect build --project proj_abc123

CI/CD with PR reporting

npx ui-inspect build \
  --project proj_abc123 \
  --fail-on-diff \
  --report \
  --pr 42 \
  --turbosnap

Using pre-captured screenshots

npx ui-inspect build \
  --project proj_abc123 \
  --dir ./screenshots \
  --skip-capture

Dry run for testing

npx ui-inspect build \
  --project proj_abc123 \
  --dry-run \
  --json

Output

✓ Build created: build_abc123
✓ TurboSnap: testing 3/10 screenshots (70% skipped)
✓ Captured 6 screenshots
✓ Compared against baselines

Results:
  ✓ homepage/desktop — No diff
  ✓ homepage/mobile — No diff
  ⚠ button/desktop — 1.2% diff (below threshold)
  ✗ card/desktop — 18.4% diff (FAILED)

Summary: 3 passed, 1 below threshold, 1 failed
Build: FAILED

Smart diff analysis

Each comparison runs through the smart diff pipeline:

  • Pixel matching — Raw pixel-by-pixel comparison with configurable threshold
  • SSIM — Structural Similarity Index for perceptual quality assessment
  • Layout shift detection — Detects horizontal and vertical content shifts
  • Anti-flake filtering — Removes anti-aliasing noise and sub-pixel rendering artifacts
  • Stability scoring — Classifies results as stable, likely-flaky, or flaky

On this page