flagpole
Version:
Simple and fast DOM integration, headless or headful browser, and REST API testing framework.
152 lines (151 loc) • 7.22 kB
TypeScript
import { ResponseType, ScenarioStatusEvent } from "./enums";
import { iLogItem, iResponse, iScenario, iSuite, iValue, iNextCallback, KeyValue, ResponsePipe } 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 canExecute(): boolean;
get hasExecuted(): boolean;
get hasFinished(): boolean;
get url(): string | null;
get finalUrl(): string | null;
get redirectCount(): number;
get redirectChain(): string[];
get request(): HttpRequest;
protected _title: string;
protected _log: LogCollection;
protected _subscribers: Function[];
protected _nextCallbacks: Function[];
protected _nextMessages: Array<string | null>;
protected _beforeCallbacks: Function[];
protected _beforeMessages: Array<string | null>;
protected _afterCallbacks: Function[];
protected _afterMessages: Array<string | null>;
protected _finallyCallbacks: Function[];
protected _finallyMessages: Array<string | null>;
protected _errorCallbacks: Function[];
protected _errorMessages: Array<string | null>;
protected _failureCallbacks: Function[];
protected _failureMessages: Array<string | null>;
protected _successCallbacks: Function[];
protected _successMessages: Array<string | null>;
protected _pipeCallbacks: ResponsePipe[];
protected _pipeMessages: Array<string | null>;
protected _onCompletedCallback: Function;
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 _followRedirect: boolean | Function | null;
protected _browserControl: BrowserControl | null;
protected _isMock: boolean;
protected _response: iResponse;
protected _defaultBrowserOptions: BrowserOptions;
protected _defaultRequestOptions: HttpRequestOptions;
protected _aliasedData: any;
static create(suite: iSuite, title: string, type: ResponseType, opts: any, onCompletedCallback: Function): iScenario;
protected constructor(suite: iSuite, title: string, onCompletedCallback: Function);
set(aliasName: string, value: any): iScenario;
get(aliasName: string): any;
getLog(): Promise<iLogItem[]>;
subscribe(callback: Function): 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: KeyValue): iScenario;
setMaxRedirects(n: number): iScenario;
shouldFollowRedirects(onRedirect: boolean | Function): iScenario;
setBasicAuth(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(value: iValue): iScenario;
comment(message: string): 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<Scenario>;
cancel(): Promise<Scenario>;
getBrowserControl(): BrowserControl;
execute(): Promise<Scenario>;
execute(params: {
[key: string]: string | number;
}): Promise<Scenario>;
error(callback: Function): iScenario;
error(message: string, callback: Function): iScenario;
success(callback: Function): iScenario;
success(message: string, callback: Function): iScenario;
failure(callback: Function): iScenario;
failure(message: string, callback: Function): iScenario;
pipe(callback: ResponsePipe): iScenario;
pipe(...callbacks: ResponsePipe[]): iScenario;
pipe(message: string, callback: ResponsePipe): iScenario;
before(callback: Function): iScenario;
before(...callbacks: Function[]): iScenario;
before(message: string, callback: Function): iScenario;
after(callback: Function): iScenario;
after(...callbacks: Function[]): iScenario;
after(message: string, callback: Function): iScenario;
finally(callback: Function): iScenario;
finally(message: string, callback: Function): iScenario;
mock(localPath: string): iScenario;
protected _reset(): iScenario;
protected _pipeResponses(httpResponse: HttpResponse): HttpResponse;
protected _processResponse(httpResponse: HttpResponse): void;
setResponseType(type: ResponseType, opts?: any): iScenario;
promise(): Promise<Scenario>;
private _executeBrowserRequest;
private _executeDefaultRequest;
protected _executeRequest(): void;
protected _executeMock(): void;
protected _executeWhenReady(): boolean;
protected _markScenarioCompleted(errorMessage?: string | null, errorDetails?: string): Promise<Scenario>;
protected _fireBefore(): Promise<any>;
protected _fireAfter(): Promise<void>;
protected _fireSuccess(): Promise<void>;
protected _fireFailure(): Promise<void>;
protected _fireError(error: string): Promise<void>;
protected _fireFinally(): Promise<void>;
protected _getOverloads(a: Function | string, b?: Function | null): {
message: string | null;
callback: Function;
};
protected _getCallbackOverload(a: Function | string, b?: Function | null): Function;
protected _getMessageOverload(a: any): string | null;
protected _next(a: Function | string, b?: Function | null, append?: boolean): iScenario;
protected _publish(statusEvent: ScenarioStatusEvent): Promise<void>;
protected _pushToLog(logItem: iLogItem): iScenario;
}