declare namespace WdioInterceptorService { type HTTPMethod = | 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'CONNECT' | 'OPTIONS' | 'TRACE' | 'PATCH'; interface ExpectedRequest { method: HTTPMethod; url: string; statusCode: number; } interface PendingRequest { url: string; method: HTTPMethod; body: string | null | object; headers: object; pending: true; } interface CompletedRequest { url: string; method: HTTPMethod; body: string | null | object; pending: false; headers: object; response: { headers: object; body: string | null | object; statusCode: number; }; } type InterceptedRequest = PendingRequest | CompletedRequest; interface OrderingStrategy { /** Whether requests are ordered by time of initiation, or fulfillment */ orderBy?: 'START' | 'END'; } interface AssertionRequestOrderStrategy extends OrderingStrategy { /** Whether the intercepted request order must match the order in which expectations were set */ inOrder?: boolean; } interface GetRequestOptions extends OrderingStrategy { /** Whether pending requests will be included in the response */ includePending?: boolean; } type OnlyCompletedRequests = { includePending: false }; } /** * Convert T to T or Promise depending if `@wdio/sync` is being used or not. */ type AsyncSync = WebdriverIO.Browser extends WebDriver.Client ? T : Promise; declare module WebdriverIO { interface Browser { setupInterceptor(): AsyncSync; disableInterceptor(): AsyncSync; excludeUrls(urls: (string | RegExp)[]): AsyncSync; expectRequest( method: WdioInterceptorService.HTTPMethod, url: string | RegExp, statusCode: number, ): AsyncSync; hasPendingRequests(): AsyncSync; assertRequests( options?: WdioInterceptorService.OrderingStrategy, ): AsyncSync; assertExpectedRequestsOnly(inOrder?: boolean): AsyncSync; assertExpectedRequestsOnly( options?: WdioInterceptorService.AssertionRequestOrderStrategy, ): AsyncSync; resetExpectations(): AsyncSync; getExpectations(): AsyncSync; getRequest( index: number, options?: WdioInterceptorService.GetRequestOptions & WdioInterceptorService.OnlyCompletedRequests, ): AsyncSync; getRequest( index: number, options: WdioInterceptorService.GetRequestOptions, ): AsyncSync; getRequests( options?: WdioInterceptorService.GetRequestOptions & WdioInterceptorService.OnlyCompletedRequests, ): AsyncSync; getRequests( options: WdioInterceptorService.GetRequestOptions, ): AsyncSync; } } declare module 'wdio-intercept-service' { export = WdioInterceptorService; }