Raxol.Test.Visual (Raxol v0.5.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 using a direct rendering pipeline. Ensures that the component is rendered in a controlled environment suitable for visual testing.
Compares a component's current render with its snapshot.
Renders a component state within a controlled test environment. Accepts an optional context map.
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 using a direct rendering pipeline. Ensures that the component is rendered in a controlled environment suitable for visual testing.
The component_struct
argument is expected to be a Raxol component map, potentially
containing a :render_context
key with :width
, :height
, and :theme
information.
If :render_context
or its keys are missing, defaults will be applied.
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.
Renders a component state within a controlled test environment. Accepts an optional context map.
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.