flagpole
Version:
Simple and fast DOM integration, headless or headful browser, and REST API testing framework.
160 lines (159 loc) • 7.7 kB
TypeScript
import { ResponseType, ScenarioStatusEvent, ScenarioDisposition } from "./enums";
import { iLogItem, iResponse, iScenario, iSuite, iNextCallback, KeyValue, ResponsePipe, ScenarioCallback, ScenarioStatusCallback, ScenarioCallbackAndMessage, ResponsePipeCallbackAndMessage } from "./interfaces";
import { BrowserControl } from "./browsercontrol";
import { AssertionResult } from "./logging/assertionresult";
import { HttpResponse } from "./httpresponse";
import { LogCollection } from "./logging/logcollection";
import { HttpRequestOptions, HttpProxy, HttpAuth, HttpRequest, HttpTimeout, HttpMethodVerb, BrowserOptions } from "./httprequest";
export declare class Scenario implements iScenario {
readonly suite: iSuite;
get responseType(): ResponseType;
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 isReadyToExecute(): boolean;
get hasExecuted(): boolean;
get hasFinished(): boolean;
private get isImplicitWait();
private get isExplicitWait();
private get hasNextCallbacks();
private get hasRequestStarted();
get url(): string | null;
set url(value: string | null);
get finalUrl(): string | null;
get redirectCount(): number;
get redirectChain(): string[];
get request(): HttpRequest;
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 _responseType: ResponseType;
protected _redirectChain: string[];
protected _finalUrl: string | null;
protected _waitToExecute: boolean;
protected _waitTime: number;
protected _flipAssertion: boolean;
protected _ignoreAssertion: boolean;
protected _request: HttpRequest;
protected _browserControl: BrowserControl | null;
protected _isMock: boolean;
protected _response: iResponse;
protected _defaultBrowserOptions: BrowserOptions;
protected _defaultRequestOptions: HttpRequestOptions;
protected _aliasedData: any;
protected _requestPromise: Promise<void>;
protected _requestResolve: Function;
protected _finishedPromise: Promise<void>;
protected _finishedResolve: Function;
protected _disposition: ScenarioDisposition;
static create(suite: iSuite, title: string, type: ResponseType, opts: any): iScenario;
protected constructor(suite: iSuite, title: string);
set(aliasName: string, value: any): iScenario;
get(aliasName: string): any;
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;
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>;
cancel(message?: string): Promise<iScenario>;
getBrowserControl(): BrowserControl;
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(localPath: string): iScenario;
setResponseType(type: ResponseType, opts?: any): iScenario;
waitForFinished(): Promise<void>;
waitForResponse(): Promise<void>;
promise(): Promise<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 _executeRequest(): 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 _getCallbackOverload(a: any, b?: any): Function;
protected _getMessageOverload(a: any): string | null;
protected _next(a: iNextCallback | string, b?: iNextCallback | null, append?: boolean): iScenario;
protected _publish(statusEvent: ScenarioStatusEvent): Promise<void>;
protected _pushToLog(logItem: iLogItem): iScenario;
}