Expand description
§MockForge Test Utilities
Test utilities for MockForge to simplify integration with test frameworks like Playwright and Vitest.
§Features
- Easy Server Spawning: Start and stop MockForge servers programmatically
- Health Checks: Wait for server readiness with configurable timeouts
- Scenario Management: Switch scenarios/workspaces per-test
- Process Management: Automatic cleanup of spawned processes
- Profile Support: Run with different MockForge profiles
§Quick Start
use mockforge_test::{MockForgeServer, ServerConfig};
#[tokio::test]
async fn test_with_mockforge() {
// Start MockForge server
let server = MockForgeServer::builder()
.http_port(3000)
.build()
.await
.expect("Failed to start server");
// Server is ready - run your tests
let response = reqwest::get("http://localhost:3000/health")
.await
.expect("Failed to get health");
assert!(response.status().is_success());
// Server automatically stops when dropped
}§Scenario Switching
use mockforge_test::MockForgeServer;
#[tokio::test]
async fn test_scenario_switching() {
let server = MockForgeServer::builder()
.http_port(3000)
.build()
.await
.expect("Failed to start server");
// Switch to a different scenario
server.scenario("user-auth-success")
.await
.expect("Failed to switch scenario");
// Test with the new scenario
// ...
}Re-exports§
pub use config::ServerConfig;pub use config::ServerConfigBuilder;pub use error::Error;pub use error::Result;pub use health::HealthCheck;pub use health::HealthStatus;pub use scenario::ScenarioManager;pub use server::MockForgeServer;pub use reqwest;pub use tokio;