flagpole
Version:
Simple and fast DOM integration, headless or headful browser, and REST API testing framework.
120 lines (119 loc) • 5.28 kB
TypeScript
import { ResponseType, ScenarioStatusEvent } from "./enums";
import { iLogItem, iResponse, iScenario, iSuite } from './interfaces';
import { Browser, BrowserOptions } from "./browser";
import * as r from "request";
import { AssertionResult } from './logging/assertionresult';
import { HttpResponse } from './httpresponse';
import { LogCollection } from './logging/logcollection';
export declare class Scenario implements iScenario {
readonly suite: iSuite;
readonly responseType: ResponseType;
title: string;
readonly totalDuration: number | null;
readonly executionDuration: number | null;
readonly requestDuration: number | null;
readonly hasFailed: boolean;
readonly hasPassed: boolean;
readonly canExecute: boolean;
readonly hasExecuted: boolean;
readonly hasFinished: boolean;
readonly url: string | null;
readonly finalUrl: string | null;
readonly requestOptions: any;
protected _title: string;
protected _log: LogCollection;
protected _subscribers: Function[];
protected _nextCallbacks: Function[];
protected _nextMessages: Array<string | null>;
protected _beforeCallbacks: Function[];
protected _afterCallbacks: Function[];
protected _finallyCallbacks: Function[];
protected _errorCallbacks: Function[];
protected _failureCallbacks: Function[];
protected _successCallbacks: Function[];
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 _redirectCount: number;
protected _finalUrl: string | null;
protected _url: string | null;
protected _waitToExecute: boolean;
protected _flipAssertion: boolean;
protected _ignoreAssertion: boolean;
protected _cookieJar: r.CookieJar;
protected _options: any;
protected _followRedirect: boolean | Function | null;
protected _browser: Browser | null;
protected _isMock: boolean;
protected _response: iResponse;
protected _defaultBrowserOptions: BrowserOptions;
protected _defaultRequestOptions: any;
static create(suite: iSuite, title: string, type: ResponseType, opts: any, onCompletedCallback: Function): Scenario;
private constructor();
getLog(): Promise<iLogItem[]>;
subscribe(callback: Function): void;
setJsonBody(jsonObject: any): Scenario;
setRawBody(str: string): Scenario;
verifySslCert(verify: boolean): Scenario;
setProxyUrl(proxyUrl: string): Scenario;
setTimeout(timeout: number): Scenario;
setFormData(form: {}): Scenario;
setMaxRedirects(n: number): Scenario;
shouldFollowRedirects(onRedirect: boolean | Function): Scenario;
setBasicAuth(authorization: {
username: string;
password: string;
}): Scenario;
setBearerToken(token: string): Scenario;
setCookie(key: string, value: string, opts?: any): Scenario;
setHeaders(headers: {}): Scenario;
setHeader(key: string, value: any): Scenario;
setMethod(method: string): Scenario;
wait(bool?: boolean): Scenario;
comment(message: string): Scenario;
result(result: AssertionResult): Scenario;
ignore(assertions?: boolean | Function): Scenario;
open(url: string): Scenario;
next(message: string, callback: any): Scenario;
next(callback: any): Scenario;
nextPrepend(message: string, callback: any): Scenario;
nextPrepend(callback: any): Scenario;
skip(message?: string): Promise<Scenario>;
cancel(): Promise<Scenario>;
getBrowser(): Browser;
execute(): Promise<Scenario>;
error(callback: Function): Scenario;
success(callback: Function): Scenario;
failure(callback: Function): Scenario;
before(callback: Function): Scenario;
after(callback: Function): Scenario;
finally(callback: Function): Scenario;
mock(localPath: string): Scenario;
protected _reset(): Scenario;
protected _getCookies(): r.Cookie[];
protected _processResponse(httpResponse: HttpResponse): void;
protected _buildUrl(): string;
setResponseType(type: ResponseType, opts?: any): Scenario;
private _executeImageRequest;
private _executeBrowserRequest;
private _executeDefaultRequest;
protected _executeRequest(): void;
protected _executeMock(): void;
protected _executeWhenReady(): void;
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 _getCallbackOverload(a: Function | string, b?: Function | null): Function;
protected _getMessageOverload(a: any): string | null;
protected _next(a: Function | string, b?: Function | null, append?: boolean): Scenario;
protected _publish(statusEvent: ScenarioStatusEvent): Promise<void>;
protected _pushToLog(logItem: iLogItem): Scenario;
}