UNPKG

@cloudnc/grpc-web-testing-toolbox

Version:

Utility functions to help you stub and assert on grpc calls.

23 lines (22 loc) 882 B
import { grpc } from '@improbable-eng/grpc-web'; import { Request } from 'playwright-core'; import { status as Status, Metadata } from '@grpc/grpc-js'; export interface UnaryMethodDefinitionish extends grpc.UnaryMethodDefinition<any, any> { requestStream: any; responseStream: any; } export declare type RequestPredicate = (requestMessage: Uint8Array | null, request: Request) => boolean | Promise<boolean>; export interface MockedGrpcCall { waitForMock(requestPredicate?: RequestPredicate): Promise<{ requestMessage: Uint8Array | null; }>; } export interface ObservedGrpcCallResponse { requestMessage: Uint8Array | null; responseMessage: Uint8Array | null; statusCode: Status; trailers: Metadata | null; } export interface ObservedGrpcCall { waitForResponse: (requestPredicate?: RequestPredicate) => Promise<ObservedGrpcCallResponse>; }