declarative-e2e-test
Version:
Declaration driven test generator for REST endpoints
27 lines (26 loc) • 1.26 kB
TypeScript
import { Response, Test } from 'supertest';
import { ErrorHandlerType, ExpectType, fnType, ITestedRequest, ITestRequestConfig, IWithHeaders, SupportedHttpVerb } from './models';
export interface IEvaluatedProps extends IWithHeaders {
verb?: SupportedHttpVerb;
url: string;
body?: any;
expect: ExpectType[];
error?: ErrorHandlerType;
}
export declare class TestedRequest {
private props;
private globalRequestConfig;
private agent?;
private response?;
constructor(props: ITestedRequest, globalRequestConfig?: ITestRequestConfig);
static buildTestedRequest(props: ITestedRequest, globalRequestConfig?: ITestRequestConfig): TestedRequest;
setResponse(resp: Response): void;
evaluateRequestProps(context: any): IEvaluatedProps;
run(context: any, app?: any): Promise<Response>;
initializeAgent(requestProps: IEvaluatedProps, app?: any): this;
createAgent(requestProps: IEvaluatedProps, app?: any): Test;
applyHeaders(requestProps: IEvaluatedProps): TestedRequest;
applyBody(requestProps: IEvaluatedProps): TestedRequest;
applyExpect(requestProps: IEvaluatedProps, context?: any, done?: fnType): TestedRequest;
applyErrorHandler(requestProps: IEvaluatedProps, context?: any): this;
}