Skip to content

CLI: Add snapshot tests for CLI output (Vitest, lock current behavior) #89

@PetarStoev02

Description

@PetarStoev02

Context

The CLI is about to gain several new commands (chains, doctor, --json flag, error message improvements). Before that surface expands, we need a test foundation that locks the current output and catches regressions when changes are made. Snapshot tests are the cheapest way to do this for CLI output.

What to build

Add Vitest-based snapshot tests that exercise every existing CLI command:

  • Capture stdout and stderr
  • Capture exit code
  • Normalize anything non-deterministic (timestamps, paths, version numbers) before snapshot comparison

Set up the test infrastructure so future commands can be added with minimal boilerplate (a helper like runCli(args) returning { stdout, stderr, exitCode }).

Acceptance criteria

  • Every current CLI command has at least one snapshot test (happy path)
  • Tests run in CI on every PR
  • A clear runCli helper exists for adding new tests
  • Normalization layer documented so contributors know how to handle non-deterministic output
  • README updated with how to run and update snapshots

Pointers

  • Vitest snapshot docs
  • Look at how gh CLI or npm CLI test their output for inspiration

Complexity

🔴 Advanced

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions