clasp-test-utils
Common test helpers and utilities for CLASP (Creative Low-Latency Application Streaming Protocol) test suites.
Features
- TestRouter - RAII-wrapped test router with automatic cleanup
- ValueCollector - Thread-safe value collection for subscription testing
- Condition-based waiting - Avoid flaky tests with proper async waiting
- Port allocation - Find available ports for test servers
- Assertion helpers - Enhanced assertions for test readability
Usage
use ;
use Duration;
async
Key Components
TestRouter
// Start with default config
let router = start.await;
// Start with custom config
let router = start_with_config.await;
// Get connection URL
let url = router.url; // "ws://127.0.0.1:XXXX"
// Connect clients
let client = router.connect_client.await?;
let client = router.connect_client_named.await?;
ValueCollector
let collector = new;
// Use as subscription callback
client.subscribe.await?;
// Wait and verify
collector.wait_for_count.await;
assert_eq!;
assert!;
Condition-Based Waiting
use ;
// Wait for a custom condition
let success = wait_for.await;
// Wait for atomic counter
wait_for_count.await;
// Wait for flag
wait_for_flag.await;
License
Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Maintained by LumenCanvas | 2026