agentjido / agentjido/term_ui

Evaluate SexySpex for executable TermUI specifications

Open
#68 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

documentation enhancement
Dominant language
Elixir
Stars
205
Forks
16
Avg merge
27m
Merged PRs (30d)
5

Description

Goal

Evaluate sexy_spex as a way to write executable, Given-When-Then specifications for TermUI behavior.

Research summary

SexySpex is an Elixir BDD framework built on ExUnit. It provides:

  • Given-When-Then executable specifications
  • Living documentation
  • Manual, step-by-step execution
  • Error-log detection
  • A separate mix spex test command

TermUI already has the lower-level tools that a specification can use:

  • TermUI.Test.ComponentHarness to mount components
  • TermUI.Test.EventSimulator to create keyboard, mouse, paste, focus, and resize events
  • TermUI.Test.TestRenderer to inspect terminal output
  • TermUI.Test.Assertions to check text, style, state, and snapshots
  • TermUI.Runtime with skip_terminal: true for runtime tests without a real terminal

The likely design is to use SexySpex as the BDD and documentation layer, and use TermUI.Test.* inside each specification step. The Scenic helpers in SexySpex do not apply to TermUI.

Proposed proof of concept

Create one specification for a small interactive component:

  1. Given a counter with an initial value of zero.
  2. When the user presses the Up key.
  3. Then the state changes to one.
  4. And the rendered buffer contains Count: 1.

The proof should use ComponentHarness.event_cycle/2, EventSimulator.simulate_key/2, and TermUI render assertions. It must unmount the harness after the scenario.

Integration notes

Suggested test dependency:

{:sexy_spex, "~> 0.2.1", only: :test}

Suggested Mix configuration:

preferred_cli_env: [spex: :test]

SexySpex specifications run with mix spex, not mix test. CI must run both commands if the project keeps its normal ExUnit suite.

Risks and questions

  • SexySpex is a small and new dependency with limited adoption.
  • The current Hex release is 0.2.1, but parts of its README still show 0.1.0.
  • We must decide whether the additional BDD syntax and separate CI path give enough value over descriptive ExUnit tests.
  • Start with public component behavior. Do not tie specifications to internal renderer details unless that detail is part of the supported contract.

Acceptance criteria

  • Decide whether to adopt, reject, or defer SexySpex.
  • If adopted, add the test-only dependency and test environment configuration.
  • Add one working TermUI executable specification.
  • Check state and rendered output after simulated input.
  • Add mix spex to CI.
  • Document how executable specifications differ from normal unit tests.
  • Record any problems found with cleanup, logs, or test isolation.

References

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the TermUI.Test.ComponentHarness, EventSimulator, TestRenderer, and Assertions APIs, then review the SexySpex integration and the existing CI configuration. Implement or evaluate the counter specification using ComponentHarness.event_cycle/2 and simulated input, checking state and rendered output. Done means the adoption decision, configuration, CI behavior, documentation, and any cleanup or isolation issues are recorded.

Written by the indexing model from the issue text.

Assessment

Tech stack
elixir
Domain
ci-cd, documentation, testing-qa
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.