Raxol.Test.TestHelper (Raxol v0.5.0)

View Source

Provides common test utilities and setup functions for Raxol tests.

This module includes:

  • Test environment setup
  • Mock data generation
  • Common test scenarios
  • Cleanup utilities

Summary

Functions

Captures all terminal output during a test.

Cleans up an ETS table.

Cleans up a process and waits for it to be down.

Cleans up a registry.

Cleans up a temporary directory.

Cleans up test resources and resets the environment.

Creates a temporary directory for test files.

Creates a test component with the given module and initial state.

Sets up a test environment with necessary services and configurations.

Creates a mock terminal for testing.

Simulates a sequence of events on a component.

Generates test events for common scenarios.

Generates test layouts for component positioning.

Generates test styles for component rendering.

Returns a complete theme struct for tests, merging any overrides provided. Ensures all required component_styles are present.

Waits for a condition to be true, with a timeout. Uses event-based synchronization instead of Process.sleep.

Functions

capture_terminal_output(fun)

Captures all terminal output during a test.

cleanup_ets_table(table)

Cleans up an ETS table.

cleanup_process(pid, timeout \\ 5000)

Cleans up a process and waits for it to be down.

cleanup_registry(registry)

Cleans up a registry.

cleanup_temp_dir(dir)

Cleans up a temporary directory.

cleanup_test_env()

Cleans up test resources and resets the environment.

create_temp_dir()

Creates a temporary directory for test files.

create_test_component(module, initial_state \\ %{})

Creates a test component with the given module and initial state.

setup_test_env()

Sets up a test environment with necessary services and configurations.

setup_test_terminal()

Creates a mock terminal for testing.

simulate_event_sequence(component, events)

Simulates a sequence of events on a component.

start_test_event_source(args \\ %{}, context \\ %{pid: self()})

Starts a test event source.

test_events()

Generates test events for common scenarios.

test_layouts()

Generates test layouts for component positioning.

test_styles()

Generates test styles for component rendering.

test_theme(overrides \\ %{})

Returns a complete theme struct for tests, merging any overrides provided. Ensures all required component_styles are present.

wait_for_state(condition_fun, timeout_ms \\ 100)

Waits for a condition to be true, with a timeout. Uses event-based synchronization instead of Process.sleep.