UNPKG

flagpole

Version:

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

130 lines (129 loc) 5.38 kB
import { Suite } from "./suite"; import { iLogLine } from "./consoleline"; import { ResponseType, NormalizedResponse } from "./response"; import { Browser, BrowserOptions } from "./browser"; import * as r from "request"; import { AssertionResult } from './assertionresult'; export declare enum ScenarioStatusEvent { beforeExecute = 0, executionProgress = 1, afterExecute = 2, finished = 3 } export declare class Scenario { readonly suite: Suite; 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 _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: (scenario: Scenario) => void; protected _log: iLogLine[]; protected _failures: Array<AssertionResult>; protected _passes: Array<AssertionResult>; 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 _defaultBrowserOptions: BrowserOptions; protected _defaultRequestOptions: any; static create(suite: Suite, title: string, type: ResponseType, opts: any, onCompletedCallback: (scenario: Scenario) => void): Scenario; private constructor(); getLog(): Promise<iLogLine[]>; 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; subheading(message: string): Scenario; comment(message: string): Scenario; logResult(result: AssertionResult): Scenario; logWarning(message: string): Scenario; ignore(assertions?: boolean | Function): Scenario; open(url: string): Scenario; next(message: string, callback: any): Scenario; next(callback: any): Scenario; skip(message?: string): 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; image(opts?: any): Scenario; video(opts?: any): Scenario; html(opts?: any): Scenario; json(opts?: any): Scenario; script(opts?: any): Scenario; stylesheet(opts?: any): Scenario; resource(opts?: any): Scenario; browser(opts?: BrowserOptions): Scenario; extjs(opts?: BrowserOptions): Scenario; mock(localPath: string): Scenario; protected _reset(): Scenario; protected _getCookies(): r.Cookie[]; protected _processResponse(r: NormalizedResponse): void; protected _buildUrl(): string; protected _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 _publish(statusEvent: ScenarioStatusEvent): Promise<void>; }