tuitest

package module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 23, 2026 License: MIT Imports: 9 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

tui-test for Go

Control, inspect, test, and record terminal apps from Go. The binding runs the Rust engine in your process and does not require the CLI.

Install

Use Go 1.26 or newer and select a published Go module release:

go get github.com/microsoft/tui-test/bindings/go@v0.1.1

The repository tag is bindings/go/v<version>. Released modules contain prebuilt native engines. Users need no Rust compiler, Zig, C compiler, CLI, or separate installer. Source checkouts do not contain these binaries; see Build and use.

OS Go architectures Native runtime
Linux amd64, arm64 glibc 2.28+ or musl 1.2+
macOS amd64, arm64 macOS system libraries
Windows amd64 Windows system libraries

Go downloads all platform archives with the module. Each executable embeds compressed archives for its target OS and architecture. Linux executables contain both libc variants and select the one that matches the running process. Other platforms contain one variant.

On first use, the binding extracts the selected engine into the user cache: tui-test/native/<sha256>/. Later processes verify and reuse the same file. The engine stays loaded for the process lifetime. There are no runtime downloads.

The cache must permit file creation, hard links, and native library loading. For a read-only or restricted environment, use an existing installation as described below.

Linux and cross-compilation

PureGo avoids cgo, but it still uses the system dynamic loader and libc. Embedding a library does not make the executable statically linked. Native glibc builds select the GNU engine. Normal native Alpine builds select the musl engine. Neither needs a custom Go build tag. Cgo-enabled applications can require a newer libc than the bundled engine.

Cross-compile for glibc Linux with:

CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build .

For musl, also select the destination interpreter:

CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
  go build -ldflags '-I /lib/ld-musl-x86_64.so.1' .

For ARM64 musl, use GOARCH=arm64 and /lib/ld-musl-aarch64.so.1. The interpreter must exist on the destination machine. A missing interpreter prevents startup before the binding can select an engine.

Existing native installation

Set TUI_TEST_NATIVE_LIBRARY to override the bundled engine:

export TUI_TEST_NATIVE_LIBRARY=/absolute/path/to/libtui_test_ffi.so

Use libtui_test_ffi.dylib on macOS or tui_test_ffi.dll on Windows. Use the native archive from the same release and the correct platform. This mode needs no extraction cache. An invalid override returns an error; it never falls back to the bundled engine. The loader checks the ABI version, but that check does not prove an exact source-revision match.

Quick start

package main

import (
    "fmt"
    "log"

    "github.com/microsoft/tui-test/bindings/go"
)

func main() {
    terminal, err := tuitest.Ephemeral("example", tuitest.ClientOptions{})
    if err != nil {
        log.Fatal(err)
    }
    defer terminal.CloseQuiet()

    if _, err := terminal.Open(tuitest.OpenOptions{}); err != nil {
        log.Print(err)
        return
    }
    if err := terminal.Submit(tuitest.Ptr("echo hello")); err != nil {
        log.Print(err)
        return
    }
    if err := terminal.WaitCommand(tuitest.WaitOptions{}); err != nil {
        log.Print(err)
        return
    }
    output, err := terminal.GetOutput()
    if err != nil {
        log.Print(err)
        return
    }
    if output != nil {
        fmt.Print(*output)
    }
}

Use Run(program, args, SpawnOptions{}) to launch an application directly. Use Open(OpenOptions{}) when you need a shell and its command tracking.

The smoke example runs its own child process and needs no external shell:

go run github.com/microsoft/tui-test/bindings/go/examples/smoke

Without an override, it prints Go binding smoke passed (bundled engine).

Sessions and options

New(session, ClientOptions{}) creates a client for a named session. An empty name uses TUI_TEST_SESSION, falling back to "default". Ephemeral(prefix, options) creates a unique name. Construction does not start a terminal; call Open or Run.

Clients with the same name share the same in-process session. Close closes that session for every client. An existing client can open it again. Restart restarts the current launch; its optional GracefulTimeout defaults to 5 seconds. Sessions lists live sessions, and CloseAll closes them. When the effective automatic-recording mode is enabled, OpenResult.Recording contains its path and Recording(session) reads the current asciicast. After closure, Recording succeeds only if the recording was retained: always-mode recordings are retained, while on-failure recordings are retained only for failed sessions. When recording is disabled, OpenResult.Recording is empty and Recording returns an error.

ClientOptions sets the backend, profile, timeouts, screen-history limit, automatic recording, failure artifacts, and traces. SpawnOptions controls dimensions, working directory, environment, readiness, restart, retries, and per-launch overrides. OpenOptions embeds SpawnOptions and adds Shell.

The default backend is Alacritty. Supported backends are Alacritty, Ghostty, Rio, and xterm.js. The default size is 80 columns by 30 rows.

Automatic recording is disabled when recording, trace, and recording-inclusive artifact options are all omitted. ClientOptions.Recording can select RecordingAlways, RecordingOnFailure, or RecordingDisabled. A supplied ClientOptions.Trace overrides that selection: TraceOn records always, TraceOnFailure records on failure, and TraceOff disables recording. When trace options are omitted, Artifacts.IncludeRecording promotes a disabled recording to on-failure recording. These options can persist terminal output, so select them deliberately.

Optional pointer fields distinguish omission from an explicit value. For example:

options := tuitest.SpawnOptions{
    Cols:      tuitest.Ptr(uint16(100)),
    Rows:      tuitest.Ptr(uint16(40)),
    WaitReady: tuitest.Ptr(false),
}

Timeouts use *time.Duration. A nil timeout uses the client setting, then the engine default: 5 seconds for text and idle, or 30 seconds for command, exit, and ready. Explicit zero remains zero. Negative durations are rejected; positive fractions of a millisecond round upward.

Methods block until their operation completes. Use goroutines for concurrent work. Operations on each session are serialized. This API does not accept contexts or promise per-call cancellation.

SpawnOptions.Retries applies only to retryable launch failures. Usage errors are returned immediately, and each retryable attempt is closed before the next attempt starts.

API reference

Use go doc github.com/microsoft/tui-test/bindings/go for exported type fields and signatures. Methods return ordinary Go errors; getters preserve unavailable values with pointers where applicable.

Capability Methods
Construction and discovery New, Ephemeral, Ptr, Sessions, CloseAll, Recording
Lifecycle Open, Run, Restart, Close, CloseQuiet, Session
Input Type, Write, Submit, Press, Resize, Signal, Kill
Keyboard Keyboard.Press, Down, Repeat, Up
Mouse Mouse.Click, Move, Down, Up, Drag, Scroll
Native history Scroll(int32), ScrollToTop, ScrollToBottom, GetViewport
Screen State, Text, Cells
Command state GetCommand, GetOutput, GetExitCode, GetCwd
Terminal state GetCursor, GetSize, GetTitle, GetClipboard, GetBellCount, GetBellEvents
Waits WaitTitle, WaitClipboard, WaitIdle, WaitCommand, WaitExit, WaitReady, WaitBell
Assertions ExpectTitle, ExpectExitCode, ExpectOutput, ExpectBellCount, ExpectSnapshot
Capture Screenshot, StartRecording, StopRecording

Use WaitCommand after submitting a shell command, and WaitExit after running a program directly. WaitIdle only establishes that the screen stopped changing.

State returns the visible text and terminal dimensions together with command, process-exit, cursor, mode, mouse-mode, color, timeout, readiness, and bell state. Cells returns styles and OSC 8 link metadata through Cell.Link and Cell.LinkID.

Native history

Scroll(lines int32) shows older output for positive values and newer output for negative values. Zero leaves the viewport unchanged. Movement stops at the available history boundaries. GetViewport() returns Viewport{Offset, History} with full-width uint64 row counts. An offset of zero means the live screen.

Visible text, locators, and captures use this viewport. Text(TextOptions{Full: true}) remains independent: it returns history plus the live screen. New output preserves the historical view until retained history expires. Keyboard input returns to the live screen. Mouse input and historical locator clicks fail while the viewport shows history. Call ScrollToBottom() before mouse input. This API is separate from Mouse.Scroll.

GetCursor() and State.Cursor retain the application cursor coordinates. Captures project that cursor into the viewport and hide it outside the view. Raster recordings capture viewport changes. Asciicast remains a PTY stream.

Locators

GetByText, GetByStyle, and GetByLink create lazy locators. Chaining returns a new locator and leaves the original unchanged. For example:

ready := terminal.GetByText("Ready", tuitest.TextSelectorOptions{})
err := ready.Last().Expect(tuitest.LocatorExpectOptions{})

Select matches with Any, Unique, First, Last, or Nth. Inspect them with Locations, Location, Count, or All. Use Wait, Expect, Click, and Highlight for actions. Location and Click require a unique match unless you select one explicitly.

Locator task Methods
Create or refine GetByText, GetByStyle, GetByLink
Compose And, Or, Filter
Select Any, Unique, First, Last, Nth
Inspect Locations, Location, Count, All
Act or assert Wait, Expect, Click, Highlight

Nested text, style, and link selectors support Within, After, and Before directions. Text selectors also support regular expressions, scrollback, and exact or normalized whitespace. Style pointer fields preserve explicit false values, such as Bold: tuitest.Ptr(false).

GetByLink(uri, options) matches an exact OSC 8 target rather than visible URL text; an empty URI requires cells with no link. Root style and link selectors find runs within each row. Chained selectors with the default Within direction test whole matches. Link selectors test every cell in a match.

Compose locators with And, Or, and Filter:

label := terminal.GetByText("Documentation", tuitest.TextSelectorOptions{})
link := terminal.GetByLink("https://example.com/docs", tuitest.LinkSelectorOptions{})

linkedLabel, err := label.And(link)
if err != nil {
    log.Fatal(err)
}
container, err := label.Filter(tuitest.LocatorFilterOptions{Has: link})
if err != nil {
    log.Fatal(err)
}

And and Or form contiguous per-row cell runs. Filter preserves each input match: Has requires its locator inside the candidate, while HasNot requires no such match. Locators in a composition must belong to the same client. Composition leaves its operands unchanged and reads one fresh terminal snapshot when resolved. Apply First, Last, Nth, or Unique at the stage where selection should occur; selection before composition can produce a different result from selection afterward. If any branch sets Full, the whole query includes scrollback.

Errors and artifacts

Use errors.As with *tuitest.Error to inspect Kind, Message, Operation, and optional diagnostics. Error kinds are AssertionError, UsageError, NoSessionError, and InternalError. Structured native failures expose Details; exported failure artifacts expose their paths and write status through Artifact.

Configure ClientOptions.Artifacts with a directory and ArtifactAll, ArtifactHTML, ArtifactText, or ArtifactNone. IncludeRecording copies the automatic cast into the failure artifact. Failure to capture an optional artifact does not replace the assertion error.

Configure ClientOptions.Trace with TraceOn to retain every session trace or TraceOnFailure to retain failed traces. Pass CloseOptions{Failed: tuitest.Ptr(true)} when closing a session whose failure happened outside a tui-test assertion so TraceOnFailure can retain it. The tuitesttest helper supplies this failure state during test cleanup.

Trace and recording-inclusive artifact options also determine the effective automatic-recording mode as described in sessions and options.

Trace and failure-artifact directories can contain terminal output, titles, locator operands, and recordings. Review them before uploading. Users can open trace.html; automated consumers should read trace.md, trace.json, and timeline.json.

Recording and snapshots

Screenshot returns terminal text when its path is empty, or writes SVG or PNG when a path is supplied. ScreenshotOptions controls scrollback, zoom, background color, and transparency. Background color and transparency are mutually exclusive, and canvas options require an output path.

StartRecording supports asciinema, APNG, GIF, and MP4. File extensions select the format unless RecordingOptions.Format overrides it. Recording options control FPS, speed, idle-time limit, zoom, background color, and transparency. Background color and transparency are mutually exclusive. MP4 requires ffmpeg on the executable search path and does not support transparency. StopRecording finishes the recording and returns its path.

ExpectSnapshot returns SnapshotPassed, SnapshotWritten, or SnapshotUpdated. Set SnapshotOptions.Update only when you intend to update the baseline. Snapshot options also control style and title inclusion and the snapshot working directory.

Test cleanup

The tuitesttest package creates unique sessions and registers cleanup before starting the terminal. It closes the session when the test ends, including after a fatal test failure.

func TestTerminal(t *testing.T) {
    terminal := tuitesttest.New(t, tuitesttest.Options{})
    if err := terminal.Submit(tuitest.Ptr("echo hello")); err != nil {
        t.Fatal(err)
    }
    if err := terminal.WaitCommand(tuitest.WaitOptions{}); err != nil {
        t.Fatal(err)
    }
}

Import testing, github.com/microsoft/tui-test/bindings/go, and github.com/microsoft/tui-test/bindings/go/tuitesttest in your test file. tuitesttest.New accepts client, spawn, shell, program, argument, and session-prefix settings through tuitesttest.Options. ClientOptions.Artifacts exports evidence when a tui-test assertion fails. ClientOptions.Trace with TraceOnFailure retains a trace when test cleanup reports that the test failed. tuitesttest.TerminalSnapshot removes trailing whitespace and blank lines for text comparisons. Each call has its own options, so parallel tests do not share mutable defaults.

Documentation

Overview

Package tuitest drives terminal programs through the in-process tui-test engine.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseAll

func CloseAll() error

func Ptr

func Ptr[Value any](value Value) *Value

Ptr marks an option as explicitly supplied, including false and zero.

func Recording

func Recording(session string) (string, error)

func Sessions

func Sessions() ([]string, error)

Types

type ArtifactMode

type ArtifactMode string
const (
	ArtifactAll  ArtifactMode = "all"
	ArtifactHTML ArtifactMode = "html"
	ArtifactText ArtifactMode = "text"
	ArtifactNone ArtifactMode = "none"
)

type ArtifactOptions

type ArtifactOptions struct {
	Dir              string
	OnFailure        ArtifactMode
	IncludeRecording bool
}

type AutomaticRecording

type AutomaticRecording struct {
	Mode      RecordingMode
	Directory string
}

type Backend

type Backend string
const (
	Alacritty Backend = "alacritty"
	Ghostty   Backend = "ghostty"
	Rio       Backend = "rio"
	XtermJS   Backend = "xtermjs"
)

type BellEvent

type BellEvent struct {
	Sequence uint64
	Elapsed  time.Duration
}

type Cell

type Cell struct {
	X, Y                                                            uint16
	Char                                                            string
	FG, BG                                                          Color
	Bold, Dim, Italic, Inverse, Invisible, Strike, Blink, Underline bool
	UnderlineStyle                                                  UnderlineStyle
	UnderlineColor                                                  Color
	Link, LinkID                                                    string
}

type Client

type Client struct {
	Keyboard *Keyboard
	Mouse    *Mouse
	// contains filtered or unexported fields
}

Client is a named handle. Handles with the same name share a session and can be reused after that session closes. Its synchronous methods may run in goroutines.

func Ephemeral

func Ephemeral(prefix string, options ClientOptions) (*Client, error)

Ephemeral creates a handle with a unique, filename-safe session name.

func New

func New(session string, options ClientOptions) (*Client, error)

New resolves an empty session from TUI_TEST_SESSION, then "default".

func (*Client) Cells

func (client *Client) Cells(x, y, width, height uint16) ([]Cell, error)

func (*Client) Close

func (client *Client) Close(options ...CloseOptions) error

func (*Client) CloseQuiet

func (client *Client) CloseQuiet() bool

CloseQuiet attempts cleanup and reports success without returning diagnostics.

func (*Client) ExpectBellCount

func (client *Client) ExpectBellCount(count uint64, options WaitOptions) error

func (*Client) ExpectExitCode

func (client *Client) ExpectExitCode(code int32, options WaitOptions) error

func (*Client) ExpectOutput

func (client *Client) ExpectOutput(text string, options OutputOptions) error

func (*Client) ExpectSnapshot

func (client *Client) ExpectSnapshot(name string, options SnapshotOptions) (SnapshotResult, error)

func (*Client) ExpectTitle

func (client *Client) ExpectTitle(text string, options TitleOptions) error

func (*Client) GetBellCount

func (client *Client) GetBellCount() (uint64, error)

func (*Client) GetBellEvents

func (client *Client) GetBellEvents() ([]BellEvent, error)
func (client *Client) GetByLink(uri string, options LinkSelectorOptions) *Locator

func (*Client) GetByStyle

func (client *Client) GetByStyle(style TextStyle, options StyleSelectorOptions) *Locator

func (*Client) GetByText

func (client *Client) GetByText(text string, options TextSelectorOptions) *Locator

func (*Client) GetClipboard

func (client *Client) GetClipboard() (string, error)

func (*Client) GetCommand

func (client *Client) GetCommand() (*string, error)

func (*Client) GetCursor

func (client *Client) GetCursor() (Cursor, error)

func (*Client) GetCwd

func (client *Client) GetCwd() (*string, error)

func (*Client) GetExitCode

func (client *Client) GetExitCode() (*int32, error)

func (*Client) GetOutput

func (client *Client) GetOutput() (*string, error)

func (*Client) GetSize

func (client *Client) GetSize() (Size, error)

func (*Client) GetTitle

func (client *Client) GetTitle() (*string, error)

func (*Client) GetViewport

func (client *Client) GetViewport() (Viewport, error)

func (*Client) Kill

func (client *Client) Kill() error

func (*Client) Open

func (client *Client) Open(options OpenOptions) (OpenResult, error)

func (*Client) Press

func (client *Client) Press(keys ...string) error

func (*Client) Resize

func (client *Client) Resize(cols, rows uint16) error

func (*Client) Restart

func (client *Client) Restart(values ...RestartOptions) (OpenResult, error)

func (*Client) Run

func (client *Client) Run(program string, args []string, options SpawnOptions) (OpenResult, error)

func (*Client) Screenshot

func (client *Client) Screenshot(path string, options ScreenshotOptions) (string, error)

Screenshot returns terminal text when path is empty, otherwise the written path.

func (*Client) Scroll

func (client *Client) Scroll(lines int32) error

Scroll moves through native history. Positive lines show older output.

func (*Client) ScrollToBottom

func (client *Client) ScrollToBottom() error

ScrollToBottom returns to the live screen.

func (*Client) ScrollToTop

func (client *Client) ScrollToTop() error

ScrollToTop shows the oldest available output.

func (*Client) Session

func (client *Client) Session() string

func (*Client) Signal

func (client *Client) Signal(name string) error

func (*Client) StartRecording

func (client *Client) StartRecording(path string, options RecordingOptions) error

func (*Client) State

func (client *Client) State() (State, error)

func (*Client) StopRecording

func (client *Client) StopRecording() (string, error)

func (*Client) Submit

func (client *Client) Submit(text *string) error

func (*Client) Text

func (client *Client) Text(options TextOptions) (string, error)

func (*Client) Type

func (client *Client) Type(text string) error

func (*Client) WaitBell

func (client *Client) WaitBell(options WaitOptions) error

func (*Client) WaitClipboard

func (client *Client) WaitClipboard(options ClipboardWaitOptions) error

func (*Client) WaitCommand

func (client *Client) WaitCommand(options WaitOptions) error

func (*Client) WaitExit

func (client *Client) WaitExit(options WaitOptions) error

func (*Client) WaitIdle

func (client *Client) WaitIdle(options WaitOptions) error

func (*Client) WaitReady

func (client *Client) WaitReady(options WaitOptions) error

func (*Client) WaitTitle

func (client *Client) WaitTitle(text string, options TitleOptions) error

func (*Client) Write

func (client *Client) Write(data string) error

type ClientOptions

type ClientOptions struct {
	Backend            Backend
	Profile            *Profile
	Timeouts           Timeouts
	ScreenHistoryLimit *uint16
	Recording          *AutomaticRecording
	Artifacts          *ArtifactOptions
	Trace              *TraceOptions
}

type ClipboardWaitOptions

type ClipboardWaitOptions struct {
	Text    *string
	Regex   bool
	Timeout *time.Duration
}

type CloseOptions

type CloseOptions struct{ Failed *bool }

type Color

type Color string

Color is "default", a named or RGB color, or an indexed decimal color.

type Colors

type Colors struct {
	Foreground, Background, Cursor                                                                        string
	Black, Red, Green, Yellow, Blue, Magenta, Cyan, White                                                 string
	BrightBlack, BrightRed, BrightGreen, BrightYellow, BrightBlue, BrightMagenta, BrightCyan, BrightWhite string
}

type Cursor

type Cursor struct {
	X, Y    uint16
	Visible bool
	Shape   string
	Color   string
}

type Direction

type Direction string
const (
	Within Direction = "within"
	After  Direction = "after"
	Before Direction = "before"
)

type EffectiveTimeouts

type EffectiveTimeouts struct{ Text, Idle, Command, Exit, Ready time.Duration }

type Error

type Error struct {
	Kind      ErrorKind
	Message   string
	Operation string
	Details   *FailureDetails
	Artifact  *FailureArtifactRef
}

Error retains the engine's category and diagnostic message for errors.As.

func (*Error) Error

func (failure *Error) Error() string

type ErrorKind

type ErrorKind string
const (
	AssertionError ErrorKind = "assertion"
	UsageError     ErrorKind = "usage"
	NoSessionError ErrorKind = "no_session"
	InternalError  ErrorKind = "internal"
)

type FailureArtifactRef

type FailureArtifactRef struct {
	Status     FailureArtifactStatus `json:"status"`
	Directory  string                `json:"directory"`
	Manifest   *string               `json:"manifest,omitempty"`
	Report     *string               `json:"report,omitempty"`
	ReportHTML *string               `json:"report_html,omitempty"`
	Timeline   *string               `json:"timeline,omitempty"`
	ScreenText *string               `json:"screen_text,omitempty"`
	ScreenSVG  *string               `json:"screen_svg,omitempty"`
	Recording  *string               `json:"recording,omitempty"`
	Errors     []string              `json:"errors,omitempty"`
}

type FailureArtifactStatus

type FailureArtifactStatus string

type FailureCellMismatch

type FailureCellMismatch struct {
	Location TextPosition `json:"location"`
	Grapheme string       `json:"grapheme"`
	Property string       `json:"property"`
	Operator string       `json:"operator"`
	Expected string       `json:"expected"`
	Actual   string       `json:"actual"`
	Resolved *string      `json:"resolved,omitempty"`
	Reason   string       `json:"reason"`
}

type FailureComparison

type FailureComparison struct {
	Kind     string  `json:"kind"`
	Expected *string `json:"expected,omitempty"`
	Actual   *string `json:"actual,omitempty"`
}

type FailureDetails

type FailureDetails struct {
	SchemaVersion uint32                 `json:"schema_version"`
	Operation     string                 `json:"operation"`
	Reason        FailureReason          `json:"reason"`
	Summary       string                 `json:"summary"`
	Locator       *FailureLocatorDetails `json:"locator,omitempty"`
	Comparison    *FailureComparison     `json:"comparison,omitempty"`
	Truncated     bool                   `json:"truncated"`
}

type FailureLocatorDetails

type FailureLocatorDetails struct {
	Reason     *LocatorFailureReason `json:"reason,omitempty"`
	Selectors  []string              `json:"selectors"`
	StageIndex *uint32               `json:"stage_index,omitempty"`
	Locations  []TextPosition        `json:"locations"`
	Mismatches []FailureCellMismatch `json:"mismatches"`
}

type FailureReason

type FailureReason string

type Keyboard

type Keyboard struct {
	// contains filtered or unexported fields
}

Keyboard sends terminal key events, including separate press and release events.

func (*Keyboard) Down

func (keyboard *Keyboard) Down(keys ...string) error

func (*Keyboard) Press

func (keyboard *Keyboard) Press(keys ...string) error

func (*Keyboard) Repeat

func (keyboard *Keyboard) Repeat(keys ...string) error

func (*Keyboard) Up

func (keyboard *Keyboard) Up(keys ...string) error

type LinkSelectorOptions

type LinkSelectorOptions struct {
	Full      bool
	Direction Direction
}

type Locator

type Locator struct {
	// contains filtered or unexported fields
}

Locator is an immutable query, resolved against the current grid on each operation. Invalid selector options are reported when an operation resolves the locator.

func (*Locator) All

func (locator *Locator) All() ([]*Locator, error)

func (*Locator) And

func (locator *Locator) And(other *Locator) (*Locator, error)

func (*Locator) Any

func (locator *Locator) Any() *Locator

func (*Locator) Click

func (locator *Locator) Click(options LocatorClickOptions) error

func (*Locator) Count

func (locator *Locator) Count() (int, error)

func (*Locator) Expect

func (locator *Locator) Expect(options LocatorExpectOptions) error

func (*Locator) Filter

func (locator *Locator) Filter(options LocatorFilterOptions) (*Locator, error)

func (*Locator) First

func (locator *Locator) First() *Locator
func (locator *Locator) GetByLink(uri string, options LinkSelectorOptions) *Locator

func (*Locator) GetByStyle

func (locator *Locator) GetByStyle(style TextStyle, options StyleSelectorOptions) *Locator

func (*Locator) GetByText

func (locator *Locator) GetByText(text string, options TextSelectorOptions) *Locator

func (*Locator) Highlight

func (locator *Locator) Highlight(options WaitOptions) error

func (*Locator) Last

func (locator *Locator) Last() *Locator

func (*Locator) Location

func (locator *Locator) Location() (TextMatch, error)

func (*Locator) Locations

func (locator *Locator) Locations() ([]TextMatch, error)

func (*Locator) Nth

func (locator *Locator) Nth(index uint32) *Locator

func (*Locator) Or

func (locator *Locator) Or(other *Locator) (*Locator, error)

func (*Locator) Unique

func (locator *Locator) Unique() *Locator

func (*Locator) Wait

func (locator *Locator) Wait(options LocatorWaitOptions) error

type LocatorClickOptions

type LocatorClickOptions struct {
	MouseButtonOptions
	Clicks  *uint32
	Timeout *time.Duration
}

type LocatorExpectOptions

type LocatorExpectOptions struct {
	Not     bool
	Timeout *time.Duration
}

type LocatorFailureReason

type LocatorFailureReason string

type LocatorFilterOptions

type LocatorFilterOptions struct {
	Has    *Locator
	HasNot *Locator
}

type LocatorWaitOptions

type LocatorWaitOptions struct {
	State   Visibility
	Timeout *time.Duration
}

type Mouse

type Mouse struct {
	// contains filtered or unexported fields
}

Mouse sends coordinates in terminal cells.

func (*Mouse) Click

func (mouse *Mouse) Click(options MouseClickOptions) error

func (*Mouse) Down

func (mouse *Mouse) Down(x, y uint16, options MouseButtonOptions) error

func (*Mouse) Drag

func (mouse *Mouse) Drag(x1, y1, x2, y2 uint16, options MouseButtonOptions) error

func (*Mouse) Move

func (mouse *Mouse) Move(x, y uint16) error

func (*Mouse) Scroll

func (mouse *Mouse) Scroll(direction ScrollDirection, amount uint32) error

func (*Mouse) Up

func (mouse *Mouse) Up(x, y uint16, options MouseButtonOptions) error

type MouseButton

type MouseButton string
const (
	Left   MouseButton = "left"
	Middle MouseButton = "middle"
	Right  MouseButton = "right"
)

type MouseButtonOptions

type MouseButtonOptions struct {
	Button           MouseButton
	Alt, Ctrl, Shift bool
}

type MouseClickOptions

type MouseClickOptions struct {
	MouseButtonOptions
	X, Y   *uint16
	OnText *string
	Clicks *uint32
}

type OpenOptions

type OpenOptions struct {
	SpawnOptions
	Shell Shell
}

type OpenResult

type OpenResult struct {
	ShellPID  *uint32
	Session   string
	Ready     bool
	Recording string
}

type OutputOptions

type OutputOptions struct{ Regex bool }

type Profile

type Profile struct {
	Scrollback *uint32
	Colors     Colors
}

type RecordingFormat

type RecordingFormat string
const (
	APNG RecordingFormat = "apng"
	GIF  RecordingFormat = "gif"
	MP4  RecordingFormat = "mp4"
	Cast RecordingFormat = "cast"
)

type RecordingMode

type RecordingMode string
const (
	RecordingDisabled  RecordingMode = "disabled"
	RecordingOnFailure RecordingMode = "on-failure"
	RecordingAlways    RecordingMode = "always"
)

type RecordingOptions

type RecordingOptions struct {
	Format                     RecordingFormat
	FPS                        *uint32
	Speed, IdleTimeLimit, Zoom *float64
	Background                 string
	Transparent                bool
}

type RestartOptions

type RestartOptions struct{ GracefulTimeout *time.Duration }

type ScreenshotOptions

type ScreenshotOptions struct {
	Full        bool
	Zoom        *float64
	Background  string
	Transparent bool
}

type ScrollDirection

type ScrollDirection string
const (
	Up   ScrollDirection = "up"
	Down ScrollDirection = "down"
)

type Shell

type Shell string
const (
	Bash       Shell = "bash"
	PowerShell Shell = "powershell"
	Pwsh       Shell = "pwsh"
	Cmd        Shell = "cmd"
	Fish       Shell = "fish"
	Zsh        Shell = "zsh"
	Xonsh      Shell = "xonsh"
	Elvish     Shell = "elvish"
	Nushell    Shell = "nushell"
)

type Size

type Size struct{ Cols, Rows uint16 }

type SnapshotOptions

type SnapshotOptions struct {
	Update, IncludeStyle, IncludeTitle bool
	Cwd                                string
}

type SnapshotResult

type SnapshotResult string
const (
	SnapshotPassed  SnapshotResult = "passed"
	SnapshotWritten SnapshotResult = "written"
	SnapshotUpdated SnapshotResult = "updated"
)

type SpawnOptions

type SpawnOptions struct {
	Backend            Backend
	Cols, Rows         *uint16
	Cwd                string
	Env                map[string]string
	WaitReady, Restart *bool
	Retries            uint32
	Profile            *Profile
	Timeouts           Timeouts
}

type State

type State struct {
	SessionShell            *string
	Cols, Rows              uint16
	Cursor                  Cursor
	Title, Cwd, LastCommand *string
	LastExit                *int32
	ExitSignal              *string
	Exited                  *int32
	Ready                   bool
	BellCount               uint64
	Modes                   map[string]bool
	MouseMode               string
	Colors                  TerminalColors
	Timeouts                EffectiveTimeouts
	Text                    string
}

type StyleSelectorOptions

type StyleSelectorOptions struct {
	Full      bool
	Direction Direction
}

type TerminalColors

type TerminalColors struct {
	Foreground, Background, Cursor string
	Palette                        map[uint8]string
}

type TextMatch

type TextMatch struct {
	Text       string
	Start, End TextPosition
	Spans      []TextSpan
}

type TextOptions

type TextOptions struct{ Full bool }

type TextPosition

type TextPosition struct{ Row, Column uint32 }

type TextSelectorOptions

type TextSelectorOptions struct {
	Regex, Full bool
	Whitespace  Whitespace
	Direction   Direction
}

type TextSpan

type TextSpan struct{ Row, Start, End uint32 }

type TextStyle

type TextStyle struct {
	Foreground, Background                *string
	Bold, Dim, Italic                     *bool
	UnderlineStyle                        *UnderlineStyle
	UnderlineColor                        *string
	Inverse, Hidden, Strikethrough, Blink *bool
}

type Timeouts

type Timeouts struct{ Text, Idle, Command, Exit, Ready *time.Duration }

Timeouts leaves nil fields unspecified and preserves explicit zero durations.

type TitleOptions

type TitleOptions struct {
	Regex, Not bool
	Timeout    *time.Duration
}

type TraceMode

type TraceMode string
const (
	TraceOff       TraceMode = "off"
	TraceOnFailure TraceMode = "on-failure"
	TraceOn        TraceMode = "on"
)

type TraceOptions

type TraceOptions struct {
	Mode      TraceMode
	Directory string
}

type UnderlineStyle

type UnderlineStyle string
const (
	UnderlineNone   UnderlineStyle = "none"
	UnderlineSingle UnderlineStyle = "single"
	UnderlineDouble UnderlineStyle = "double"
	UnderlineCurly  UnderlineStyle = "curly"
	UnderlineDotted UnderlineStyle = "dotted"
	UnderlineDashed UnderlineStyle = "dashed"
)

type Viewport

type Viewport struct{ Offset, History uint64 }

Viewport reports the rows above the live screen and the available history.

type Visibility

type Visibility string
const (
	Visible Visibility = "visible"
	Hidden  Visibility = "hidden"
)

type WaitOptions

type WaitOptions struct{ Timeout *time.Duration }

type Whitespace

type Whitespace string
const (
	Exact     Whitespace = "exact"
	Normalize Whitespace = "normalize"
)

Directories

Path Synopsis
examples
smoke command
The smoke consumer runs itself in child mode, so it needs no external shell.
The smoke consumer runs itself in child mode, so it needs no external shell.
internal
native
Generated by cargo run -p tui-test-bindgen.
Generated by cargo run -p tui-test-bindgen.
Package tuitesttest integrates terminal sessions with Go test cleanup.
Package tuitesttest integrates terminal sessions with Go test cleanup.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL