class Opal::Testing::TestProgram

Overview

Charmbracelet Bubbletea-inspired TestProgram test harness. Wraps a TEA Model/Program running concurrently, enabling programmatic key typing, concurrent message injection (send), output assertion, and graceful termination waiting.

Defined in:

opal/testing/teatest.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(model : TEA::Model, width : Int32 = 80, height : Int32 = 24, alt_screen : Bool = false, mouse_enabled : Bool = false, diff_render : Bool = false) : self #

Factory constructor


[View source]

Instance Method Detail

def driver : Terminal::MockDriver #

[View source]
def error : Exception | Nil #

[View source]
def final_model : TEA::Model | Nil #

[View source]
def finished? : Bool #

[View source]
def key(name : String, char : Char | Nil = nil, ctrl : Bool = false, alt : Bool = false, shift : Bool = false) : self #

Dispatches a single key into the program's input stream.


[View source]
def output : String #

Returns the recorded output stripped of ANSI escapes.


[View source]
def program : TEA::Program #

[View source]
def quit : self #

Programmatically requests program exit.


[View source]
def raw_output : String #

Returns the raw recorded output with ANSI escapes preserved.


[View source]
def send(msg : TEA::Msg) : self #

Sends a message directly into the active application event loop (matching Bubbletea p.Send).


[View source]
def type(text : String) : self #

Simulates typing text into the program's input stream.


[View source]
def wait_finished(timeout : Time::Span = 2.seconds) : TEA::Model #

Waits for the TEA program to exit cleanly and returns the final Model state.


[View source]
def wait_for(timeout : Time::Span = 1.second, interval : Time::Span = 5.milliseconds, message : String = "Condition timed out waiting for output assertion", &block : String -> Bool) : self #

Waits until output matches the condition block within the specified timeout.


[View source]