Raxol.Test.Visual (Raxol v0.2.0)
View SourceProvides utilities for visual testing of Raxol components.
This module handles:
- Component rendering verification
- Layout testing
- Style validation
- Terminal output comparison
- Cross-terminal compatibility testing
Example
defmodule MyComponent.VisualTest do
use ExUnit.Case
use Raxol.Test.Visual
test "renders correctly" do
component = setup_visual_component(MyComponent)
assert_renders_as component, fn output ->
assert output =~ "Expected Content"
assert_layout_matches output, width: 10, height: 5
end
end
end
Summary
Functions
Verifies that a component renders as expected.
Captures the rendered output of a component.
Compares a component's current render with its snapshot.
Sets up a component for visual testing.
Creates or updates a snapshot of the component's rendered output.
Tests a component's rendering across different terminal sizes.
Tests a component's rendering with different style themes.
Functions
Verifies that a component renders as expected.
Takes a function that can make assertions about the rendered output.
Captures the rendered output of a component.
Returns the terminal output as a string for comparison.
Compares a component's current render with its snapshot.
Returns a detailed diff if there are differences.
Sets up a component for visual testing.
This function:
- Initializes the component
- Sets up the render context
- Configures the test terminal
- Prepares snapshot directories
Creates or updates a snapshot of the component's rendered output.
Used for visual regression testing.
Tests a component's rendering across different terminal sizes.
Verifies responsive behavior and layout adaptability.
Tests a component's rendering with different style themes.
Verifies proper style application and theme switching.