UNPKG

flagpole

Version:

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

85 lines (84 loc) 2.71 kB
/// <reference types="node" /> import { Scenario } from "./scenario"; import { Cookie } from 'request'; import { IncomingMessage } from 'http'; import * as puppeteer from "puppeteer-core"; import { AssertionContext } from './assertioncontext'; import { Value } from './value'; export interface iResponse { type: ResponseType; typeName: string; statusCode: Value; statusMessage: Value; body: Value; jsonBody: Value; url: Value; finalUrl: Value; length: Value; loadTime: Value; context: AssertionContext; headers: Value; cookies: Value; isBrowser: boolean; getRoot(): any; find(path: string): Promise<any>; findAll(path: string): Promise<Array<any>>; header(key?: string): Value; cookie(key?: string): Value; absolutizeUri(uri: string): string; evaluate(context: any, callback: Function): Promise<any>; readonly scenario: Scenario; } export declare enum ResponseType { html = 0, json = 1, image = 2, stylesheet = 3, script = 4, video = 5, audio = 6, resource = 7, browser = 8, extjs = 9 } export declare class NormalizedResponse { body: string; statusCode: number; statusMessage: string; headers: { [key: string]: string; }; cookies: Cookie[]; private constructor(); static fromRequest(response: IncomingMessage, body: string, cookies: Cookie[]): NormalizedResponse; static fromPuppeteer(response: puppeteer.Response, body: string, cookies: Cookie[]): NormalizedResponse; static fromProbeImage(response: any, cookies: Cookie[]): NormalizedResponse; static fromLocalFile(relativePath: string): Promise<NormalizedResponse>; } export declare abstract class GenericResponse implements iResponse { readonly scenario: Scenario; private _response; abstract readonly type: ResponseType; abstract readonly typeName: string; abstract find(path: string): Promise<any | null>; abstract findAll(path: string): Promise<any[]>; abstract evaluate(context: any, callback: Function): Promise<any>; readonly isBrowser: boolean; readonly statusCode: Value; readonly statusMessage: Value; readonly body: Value; readonly length: Value; readonly headers: Value; readonly cookies: Value; readonly jsonBody: Value; readonly url: Value; readonly finalUrl: Value; readonly loadTime: Value; readonly context: AssertionContext; constructor(scenario: Scenario, response: NormalizedResponse); absolutizeUri(uri: string): string; getRoot(): any; header(key: string): Value; cookie(key: string): Value; protected _wrapAsValue(data: any, name: string): Value; }