UNPKG

flagpole

Version:

Simple and fast DOM integration, headless or headful browser, and REST API testing framework.

208 lines (207 loc) 9.49 kB
/// <reference types="node" /> import { ScenarioStatusEvent, ScenarioDisposition } from "./enums"; import { iLogItem, iResponse, iScenario, iSuite, iNextCallback, KeyValue, ResponsePipe, ScenarioCallback, ScenarioStatusCallback, ScenarioCallbackAndMessage, ResponsePipeCallbackAndMessage, iValue, HttpResponseOptions, WebhookServer, BrowserOptions, HttpRequestOptions, HttpProxy, HttpAuth, HttpTimeout, HttpMethodVerb } from "./interfaces"; import { BrowserControl } from "./puppeteer/browsercontrol"; import { AssertionResult } from "./logging/assertionresult"; import { HttpResponse } from "./httpresponse"; import { LogCollection } from "./logging/logcollection"; import { HttpRequest } from "./httprequest"; import { Browser } from "puppeteer-core"; import { ServerOptions } from "https"; import { ScenarioType } from "./scenario-types"; declare enum ScenarioRequestType { httpRequest = "httpRequest", localFile = "localFile", manual = "manual", webhook = "webhook" } export declare class Scenario implements iScenario { readonly suite: iSuite; get responseType(): ScenarioType; get title(): string; set title(newTitle: string); get totalDuration(): number; get executionDuration(): number | null; get requestDuration(): number | null; get hasFailed(): boolean; get hasPassed(): boolean; get hasAborted(): boolean; get hasBeenCancelled(): boolean; get hasBeenSkipped(): boolean; get isPending(): boolean; get isExecuting(): boolean; get isCompleted(): boolean; get disposition(): ScenarioDisposition; get opts(): any; get isReadyToExecute(): boolean; get hasExecuted(): boolean; get hasFinished(): boolean; get browserControl(): BrowserControl | null; get browser(): Browser | null; private get isImplicitWait(); private get isExplicitWait(); private get hasNextCallbacks(); get hasRequestStarted(): boolean; get url(): string | null; set url(value: string | null); get finalUrl(): string | null; get redirectCount(): number; get redirectChain(): string[]; get request(): HttpRequest; get nextCallbacks(): Array<{ message: string; callback: iNextCallback; }>; protected _title: string; protected _log: LogCollection; protected _subscribers: ScenarioStatusCallback[]; protected _nextCallbacks: iNextCallback[]; protected _nextMessages: Array<string | null>; protected _beforeCallbacks: ScenarioCallbackAndMessage[]; protected _afterCallbacks: ScenarioCallbackAndMessage[]; protected _finallyCallbacks: ScenarioCallbackAndMessage[]; protected _failureCallbacks: ScenarioCallbackAndMessage[]; protected _successCallbacks: ScenarioCallbackAndMessage[]; protected _pipeCallbacks: ResponsePipeCallbackAndMessage[]; protected _timeScenarioInitialized: number; protected _timeScenarioExecuted: number | null; protected _timeRequestStarted: number | null; protected _timeRequestLoaded: number | null; protected _timeScenarioFinished: number | null; protected _requestType: ScenarioRequestType; protected _responseType: ScenarioType; protected _redirectChain: string[]; protected _finalUrl: string | null; protected _waitToExecute: boolean; protected _waitTime: number; protected _flipAssertion: boolean; protected _ignoreAssertion: boolean; protected _request: HttpRequest; protected _mockResponseOptions: HttpResponseOptions | null; protected _browserControl: BrowserControl | null; protected _response: iResponse; protected _defaultBrowserOptions: BrowserOptions; protected _defaultRequestOptions: HttpRequestOptions; protected _aliasedData: any; protected _requestPromise: Promise<iScenario>; protected _requestResolve: Function; protected _finishedPromise: Promise<iScenario>; protected _finishedResolve: Function; protected _disposition: ScenarioDisposition; protected _webhookPromise: Promise<WebhookServer>; protected _webhookResolver: Function; static create(suite: iSuite, title: string, type: ScenarioType, opts: any): iScenario; protected constructor(suite: iSuite, title: string); protected _getArray(key: string): any[]; push(key: string, value: any): iScenario; set(aliasName: string, value: any): iScenario; get<T = any>(aliasName: string): T; getLog(): Promise<iLogItem[]>; subscribe(callback: ScenarioStatusCallback): iScenario; setJsonBody(json: KeyValue): iScenario; setRawBody(str: string): iScenario; verifyCert(verify: boolean): iScenario; setProxy(proxy: HttpProxy): iScenario; setTimeout(n: number): iScenario; setTimeout(timeouts: HttpTimeout): iScenario; setFormData(form: FormData): iScenario; setFormData(form: KeyValue, isMultipart?: boolean): iScenario; setMaxRedirects(n: number): iScenario; setBasicAuth(auth: HttpAuth): iScenario; setDigestAuth(auth: HttpAuth): iScenario; setBearerToken(token: string): iScenario; setCookie(key: string, value: string): iScenario; setHeaders(headers: KeyValue): iScenario; setHeader(key: string, value: any): iScenario; setMethod(method: HttpMethodVerb): iScenario; wait(bool?: boolean): iScenario; waitFor(thatScenario: iScenario): iScenario; comment(input: any): iScenario; result(result: AssertionResult): iScenario; ignore(assertions?: boolean | Function): iScenario; pause(milliseconds: number): iScenario; open(url: string, opts?: HttpRequestOptions): iScenario; open(link: iValue, opts?: HttpRequestOptions): iScenario; next(responseValues: { [key: string]: any; }): iScenario; next(message: string, callback: iNextCallback): iScenario; next(callback: iNextCallback): iScenario; next(...callbacks: iNextCallback[]): iScenario; nextPrepend(message: string, callback: iNextCallback): iScenario; nextPrepend(callback: iNextCallback): iScenario; skip(message?: string): Promise<iScenario>; cancelOrAbort(message?: string): Promise<iScenario>; abort(message?: string): Promise<iScenario>; cancel(message?: string): Promise<iScenario>; execute(): Promise<iScenario>; execute(params: { [key: string]: string | number; }): Promise<iScenario>; go(): Promise<this>; success(callback: ScenarioCallback): iScenario; success(message: string, callback: ScenarioCallback): iScenario; success(...callbacks: ScenarioCallback[]): iScenario; failure(callback: ScenarioCallback): iScenario; failure(message: string, callback: ScenarioCallback): iScenario; failure(...callbacks: ScenarioCallback[]): iScenario; pipe(callback: ResponsePipe): iScenario; pipe(...callbacks: ResponsePipe[]): iScenario; pipe(message: string, callback: ResponsePipe): iScenario; before(callback: ScenarioCallback): iScenario; before(...callbacks: ScenarioCallback[]): iScenario; before(message: string, callback: ScenarioCallback): iScenario; after(callback: ScenarioCallback): iScenario; after(...callbacks: ScenarioCallback[]): iScenario; after(message: string, callback: ScenarioCallback): iScenario; finally(callback: ScenarioCallback): iScenario; finally(...callbacks: ScenarioCallback[]): iScenario; finally(message: string, callback: ScenarioCallback): iScenario; mock(opts?: HttpResponseOptions | string): iScenario; local(localPath: string): iScenario; webhook(a?: string | number | ServerOptions, b?: number | ServerOptions, c?: ServerOptions): iScenario; server(): Promise<WebhookServer>; setResponseType(type: ScenarioType, opts?: any): iScenario; waitForFinished(): Promise<iScenario>; waitForResponse(): Promise<iScenario>; promise(): Promise<iScenario>; repeat(): iScenario; repeat(count: number): iScenario[]; buildUrl(): URL; private _pushCallbacks; protected _reset(): iScenario; protected _pipeResponses(httpResponse: HttpResponse): Promise<HttpResponse>; protected _processResponse(httpResponse: HttpResponse): Promise<void>; private _executeBrowserRequest; private _executeDefaultRequest; private _markRequestAsStarted; protected _executeHttpRequest(): void; protected _executeLocalRequest(): void; protected _executeMock(): void; protected _markScenarioCompleted(message?: string | null, details?: string | null, disposition?: ScenarioDisposition): Promise<iScenario>; private _fireCallbacks; private _logScenarioHeading; private _markExecutionAsStarted; protected _fireBefore(): Promise<any>; protected _fireAfter(): Promise<void>; protected _fireSuccess(): Promise<void>; protected _fireFailure(errorMessage?: string): Promise<void>; protected _fireFinally(): Promise<void>; protected _getOverloads(a: any, b?: any): { message: string | null; callback: Function; }; protected _expect(responseValues: { [key: string]: any; }): iNextCallback; protected _getCallbackOverload(a: any, b?: any): Function; protected _getMessageOverload(a: any): string | null; protected _next(a: iNextCallback | string | { [key: string]: any; }, b?: iNextCallback | { [key: string]: any; } | null, append?: boolean): iScenario; protected _publish(statusEvent: ScenarioStatusEvent): Promise<void>; protected _pushToLog(logItem: iLogItem): iScenario; } export {};