@ply-ct/ply
Version:
REST API Automated Testing
61 lines (60 loc) • 2.23 kB
TypeScript
import { Values } from './values';
import { TestType, Test, PlyTest } from './test';
import { Response } from './response';
import { Log } from './log';
import { Retrieval } from './retrieval';
import { Runtime } from './runtime';
import { Options, RunOptions } from './options';
import { PlyResult } from './result';
export interface Request extends Test {
url: string;
method: string;
headers: {
[key: string]: string;
};
body?: string;
submitted?: Date;
submit(values: Values, options?: Options, runOptions?: RunOptions): Promise<Response>;
}
export declare class PlyRequest implements Request, PlyTest {
readonly name: string;
readonly logger: Log;
readonly type: TestType;
readonly url: string;
readonly method: string;
readonly headers: {
[key: string]: string;
};
readonly body?: string;
readonly start?: number;
readonly end?: number;
submitted?: Date;
graphQl?: string;
/**
* @param name test name
* @param obj object to parse for contents
*/
constructor(name: string, obj: Request, logger: Log, retrieval: Retrieval);
getSupportedMethod(method: string): string | undefined;
get isGraphQl(): boolean;
getRunId(values: Values): string;
/**
* Call submit() to send the request without producing actual results
* or comparing with expected. Useful for cleaning up or restoring
* REST resources before/after testing (see Case.before()/after()).
*/
submit(values: Values, options?: Options, runOptions?: RunOptions): Promise<Response>;
private doSubmit;
/**
* Request object with substituted values
*/
getRequest(values: Values, options?: Options, runOptions?: RunOptions, includeAuthHeader?: boolean): Request;
private responseHeaders;
/**
* Only to be called in the context of a Suite (hence 'runtime').
* To execute a test programmatically, call one of the Suite.run() overloads.
* Or to send a request without testing, call submit().
* @returns result with request invocation and status of 'Pending'
*/
run(runtime: Runtime, values: Values, runOptions?: RunOptions, runNum?: number): Promise<PlyResult>;
}