MockTransport

Playwright\Transport\MockTransport

Deterministic in-memory implementation of the Playwright transport interface. Allows tests to queue scripted responses, inspect sent messages, and simulate async/event flows without starting the real Playwright server.

implements TransportInterface

Methods

connect()

void
function connect(): void

disconnect()

void
function disconnect(): void

send()

array
function send(array $message): array

sendAsync()

void
function sendAsync(array $message): void

isConnected()

bool
function isConnected(): bool

processEvents()

void
function processEvents(): void

queueResponse()

void

Queue a scripted response for the next {@see send()} call.

function queueResponse(array|callable|\Throwable $payload, ?callable $matcher = null): void

onSendAsync()

void

Register a callback invoked on every {@see sendAsync()} call.

function onSendAsync(callable $handler): void

queueProcessEvent()

void

Queue an event callback executed from {@see processEvents()}.

function queueProcessEvent(callable $callback): void

resetHistory()

void

Reset recorded history while keeping scripted responses and queued events.

function resetHistory(): void

storePendingCallback()

void
function storePendingCallback(string $requestId, callable $callback): void

getStoredPendingCallbacks()

array
function getStoredPendingCallbacks(): array

executePendingCallback()

mixed
function executePendingCallback(string $requestId, array $message = []): mixed

getSentMessages()

array
function getSentMessages(): array

getAsyncMessages()

array
function getAsyncMessages(): array

getProcessedEventResults()

array
function getProcessedEventResults(): array

getPendingResponseCount()

int
function getPendingResponseCount(): int

getPendingEventCount()

int
function getPendingEventCount(): int