Skip to content

Add PTY-based end-to-end CLI testing infrastructure #392

@JeanMertz

Description

@JeanMertz

Add infrastructure for testing interactive CLI features using pseudo-terminal (PTY) simulation.

Context

Currently, interactive prompts (jp_inquire, inquire) require a real TTY and cannot be tested automatically. While we can use dependency injection to test the logic around prompts, true end-to-end testing of the CLI's interactive behavior requires simulating terminal input/output.

Libraries like portable-pty or expectrl can create pseudo-terminals that allow injecting keystrokes and capturing output, enabling tests like:

  • Interrupt handling (Ctrl+C menus)
  • Tool permission prompts
  • Multi-select dialogs
  • Editor integration

Alternatives

Dependency injection at the prompt level (implemented separately) covers unit testing of prompt-adjacent logic but doesn't verify the actual terminal rendering or keystroke handling.

Proposed Implementation

  1. Evaluate portable-pty vs expectrl for our needs
  2. Create a test harness that spawns jp commands in a PTY
  3. Add helper functions for sending keystrokes and matching output
  4. Write e2e tests for critical interactive flows

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions