Public helpers for deterministic Breeze view tests.
Breeze.Test can render a view against a fixed terminal size, dispatch input
and events without starting the interactive server.
Example
defmodule MyApp.CounterTest do
use ExUnit.Case, async: true
test "counter snapshot" do
session = Breeze.Test.start!(MyApp.CounterView, size: {30, 5})
on_exit(fn -> Breeze.Test.stop(session) end)
assert Breeze.Test.render!(session) =~ "Counter: 0"
assert {:noreply, _focused, true} = Breeze.Test.input(session, "ArrowUp")
assert Breeze.Test.render!(session) =~ "Counter: 1"
end
end
Summary
Functions
Dispatches a named event and payload directly to the view.
Dispatches a message to the view's handle_info/2 callback.
Dispatches a decoded key or input event to the view.
Returns the current metadata for the view session.
Renders the current view state and returns its terminal content.
Renders the current view state, raising on failure.
Starts a deterministic test session for view.
Starts a deterministic test session and returns it, raising on failure.
Stops a test session.
Types
Functions
Dispatches a named event and payload directly to the view.
Dispatches a message to the view's handle_info/2 callback.
Dispatches a decoded key or input event to the view.
Returns the current metadata for the view session.
Renders the current view state and returns its terminal content.
Renders the current view state, raising on failure.
Starts a deterministic test session for view.
Options include:
:size- terminal size as{width, height}or a dimensions map. Defaults to80x24.:terminal- an existing%Termite.Terminal{}. Takes precedence over:size.:theme- the theme used to render the view.:start_opts- options passed to the view'smount/2callback.:global_keybindings- keybindings active for the test session.
Starts a deterministic test session and returns it, raising on failure.
@spec stop(t()) :: :ok
Stops a test session.