Skip to main content

Module websocket

Module websocket 

Source
Expand description

WebSocket testing client. WebSocket test client and utilities for integration testing

Provides WebSocket test client for end-to-end WebSocket testing with support for authentication, connection management, and message assertions.

§Usage Examples

§Basic WebSocket Connection

use reinhardt_testkit::websocket::WebSocketTestClient;
use rstest::*;

#[rstest]
#[tokio::test]
async fn test_websocket_connection() {
    let client = WebSocketTestClient::connect("ws://localhost:8080/ws").await.unwrap();
    client.send_text("Hello").await.unwrap();
    let response = client.receive_text().await.unwrap();
    assert_eq!(response, "Hello");
}

§WebSocket with Authentication

use reinhardt_testkit::websocket::WebSocketTestClient;

#[tokio::test]
async fn test_websocket_auth() {
    let client = WebSocketTestClient::connect_with_token(
        "ws://localhost:8080/ws",
        "my-auth-token"
    ).await.unwrap();
    // ...
}

Modules§

assertions
WebSocket message assertion utilities

Structs§

WebSocketTestClient
WebSocket test client for integration testing