UNPKG

playwright-fluent

Version:
86 lines (85 loc) 4.31 kB
import { HarEntry, HarPostData, HttpHeaders, HttpRequestMethod } from '../../../utils'; import { Page, Request, Route } from 'playwright'; export interface HarRequestResponseOptions { /** * Optional filter to take only a subset of all available HAR entries * By default all HAR entries found in the provided HAR files are taken * @memberof HarRequestResponseOptions */ filterAllHarEntriesBeforeProcessing: (entry: HarEntry, index: number) => boolean; /** * Optional Predicate used to bypass request interception for specific requests. * By default all requests that match the given url are intercepted. * @memberof HarRequestResponseOptions */ bypassRequestPredicate: (request: Request) => boolean; /** * Optional filter that enables you to select the HAR entries for the given requested Url * By default entries are filtered by comparing the urls without the hostname and without the query string * @memberof HarRequestResponseOptions */ filterHarEntryByUrl: (requestUrl: string, harRequestUrl: string, index: number) => boolean; /** * Optional filter that enables you to select the HAR entries for the given requested postdata * By default entries are filtered by checking equality of postdata * @memberof HarRequestResponseOptions */ filterHarEntryByPostData: (requestPostData: string | null, harRequestPostData: HarPostData, index: number) => boolean; /** * Optional filter that enables you to select the HAR entries for the given requested url and query string * * @memberof HarRequestResponseOptions */ filterHarEntryByQueryString: (requestUrl: string, harRequestUrl: string, index: number) => boolean; /** * Optional filter that enables you to select the HAR entries with a specific response status * * @memberof HarRequestResponseOptions */ filterHarEntryByResponseStatus: (status: number) => boolean; /** * Optional selector to let you select one HAR entry when several HAR entries have been found. * By default the last HAR entry is taken. * * @memberof HarRequestResponseOptions */ selectEntryFromFoundHarEntries: (entries: HarEntry[], requestedUrl: string) => HarEntry; /** * Optional callback that will enable you to diagnose why no HAR entry has been found regarding a specific request url. * You should not mutate any given parameters * * @memberof HarRequestResponseOptions */ onHarEntryNotFound: (allEntries: HarEntry[], requestedUrl: string, requestedMethod: HttpRequestMethod) => void; /** * Optional callback that will enable you to check the correct HAR entry has been selected regarding a specific request url. * You should not mutate any given parameters * * @memberof HarRequestResponseOptions */ onHarEntryFound: (foundEntry: HarEntry, requestedUrl: string, requestedMethod: HttpRequestMethod) => void; /** * Optional callback that will enable you to add/remove/update the headers that will be provided in the response object * By default all headers found in the HAR entry will be used to serve the response. * * @memberof HarRequestResponseOptions */ enrichResponseHeaders: (headers: HttpHeaders) => HttpHeaders; /** * Optional callback that will enable you to handle yourself the request interception * in case the internal implementation did not found any entry in the provided HAR files. * By default route.continue() will be called. * * @memberof HarRequestResponseOptions */ handleRouteOnHarEntryNotFound: (route: Route, request: Request, entries: HarEntry[]) => void; /** * Optional callback that enables you to provide yourself an HAR entry for the given requested * when the internal implementation did not found any entry. * * @memberof HarRequestResponseOptions */ provideEntryOnHarEntryNotFound: (request: Request, entries: HarEntry[]) => HarEntry | null; } export declare const defaultHarRequestResponseOptions: HarRequestResponseOptions; export declare function onRequestToRespondFromHar(url: string, harFiles: string[], page: Page | undefined, options: HarRequestResponseOptions): Promise<void>;