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()
voidfunction connect(): void
disconnect()
voidfunction disconnect(): void
send()
arrayfunction send(array $message): array
sendAsync()
voidfunction sendAsync(array $message): void
isConnected()
boolfunction isConnected(): bool
processEvents()
voidfunction processEvents(): void
queueResponse()
voidQueue a scripted response for the next {@see send()} call.
function queueResponse(array|callable|\Throwable $payload, ?callable $matcher = null): void
onSendAsync()
voidRegister a callback invoked on every {@see sendAsync()} call.
function onSendAsync(callable $handler): void
queueProcessEvent()
voidQueue an event callback executed from {@see processEvents()}.
function queueProcessEvent(callable $callback): void
resetHistory()
voidReset recorded history while keeping scripted responses and queued events.
function resetHistory(): void
storePendingCallback()
voidfunction storePendingCallback(string $requestId, callable $callback): void
getStoredPendingCallbacks()
arrayfunction getStoredPendingCallbacks(): array
executePendingCallback()
mixedfunction executePendingCallback(string $requestId, array $message = []): mixed
getSentMessages()
arrayfunction getSentMessages(): array
getAsyncMessages()
arrayfunction getAsyncMessages(): array
getProcessedEventResults()
arrayfunction getProcessedEventResults(): array
getPendingResponseCount()
intfunction getPendingResponseCount(): int
getPendingEventCount()
intfunction getPendingEventCount(): int