teatest
Crystal port of Go teatest library
Test Bubbletea programs easily, including golden files
Architecture · Development · Guidelines · Testing · PR Workflow · Porting Parity
Test helpers for Term2 programs. This is a Crystal port of the Go x/exp/teatest/v2 package from charmbracelet/ansi.
Quick Start
- Add the dependency to your
shard.yml:
dependencies:
teatest:
github: dsisnero/teatest
-
Run
shards install -
Use in your tests:
require "teatest"
require "term2"
class Counter
include Term2::Model
def initialize(@n : Int32 = 0)
end
def init : Term2::Cmd
Term2::Cmds.none
end
def update(msg : Term2::Msg) : {Term2::Model, Term2::Cmd}
case msg
when Term2::KeyMsg
if msg.code == Ultraviolet::KeyEnter
return {self, nil}
end
end
{self, nil}
end
def view : String
"count=#{@n}\n"
end
end
tm = Teatest.new_test_model(Counter.new)
Teatest.wait_for(tm.output, ->(b : Bytes) { String.new(b).includes?("count=") })
tm.quit
Features
- Golden file testing: Compare output with expected golden files
- Async testing: Wait for specific output patterns
- Term2 integration: Test Bubble Tea applications
- Go parity: Behavior matches upstream Go
x/exp/teatest/v2 - ANSI handling: Proper terminal escape sequence support
Development
# Install dependencies
make install
# Run tests
make test
# Check code quality
make format
make lint
See Development Guide for full setup instructions.
Documentation
| Document | Purpose |
|---|---|
| Architecture | System design and data flow |
| Development | Setup and daily workflow |
| Coding Guidelines | Code style and conventions |
| Testing | Test commands and patterns |
| PR Workflow | Commits, PRs, and review process |
| Porting Parity | Upstream source mapping and behavior parity |
Contributing
- Create an issue:
/forge-create-issue - Implement:
/forge-implement-issue <number> - Self-review:
/forge-reflect-pr - Address feedback:
/forge-address-pr-feedback - Update changelog:
/forge-update-changelog
Repository
teatest
Owner
Statistic
- 0
- 0
- 0
- 2
- 3
- 18 days ago
- February 10, 2026
License
MIT License
Links
Synced at
Fri, 06 Mar 2026 20:42:40 GMT
Languages