freya-testing. Run your Freya applications in a headless environment, simulate user interactions, and verify rendering output without a window.
Quick Start
Addfreya-testing to your dev dependencies:
Creating Test Runners
launch_test
Simple test runner for basic cases:- Window size: 500x500
- Scale factor: 1.0
- No custom context
TestingRunner::new
Full control with custom configuration:launch_doc
Render to PNG for documentation:Simulating User Input
Mouse Events
Keyboard Events
Custom Platform Events
State Management
With Provided Context
Share state between test and app:Querying Elements
find - Find Single Element
find_many - Find Multiple Elements
TestingNode API
Async Operations
Handling Async Events
Polling for Animations
Test animations by polling over time:Rendering
Render to Memory
Render to File
Visual Regression Testing
Font Configuration
Custom Fonts
Default Font Family
Animation Clock
Control animation timing for deterministic tests:Complete Testing Example
Counter app with comprehensive tests:Best Practices
- Call sync_and_update - Always call after TestingRunner creation and events
- Test user flows - Simulate real user interactions
- Check state and UI - Verify both internal state and rendered output
- Use find helpers - Query elements by their properties
- Test edge cases - Include boundary conditions
- Test async operations - Use
handle_events_immediately()orhandle_events().await - Visual regression - Compare rendered output for UI changes
- Deterministic tests - Control animation clock for consistent results