UNPKG

@ply-ct/ply

Version:

REST API Automated Testing

117 lines (116 loc) 4.34 kB
/// <reference types="node" /> import { EventEmitter } from 'events'; import { Options, PlyOptions, RunOptions } from './options'; import { Suite } from './suite'; import { Test } from './test'; import { Request } from './request'; import { Case } from './case'; import { Log } from './log'; import { FlowSuite } from './flows'; import { OverallResults } from './runs/model'; export declare class Ply { private logger?; readonly options: PlyOptions; constructor(options?: Options, logger?: Log | undefined); /** * Load request from .ply file */ loadRequest(location: string): Promise<Request>; loadRequestSync(location: string): Request; /** * Load request suites. * @param locations can be URLs or file paths */ loadRequests(location: string): Promise<Suite<Request>[]>; loadRequests(...locations: string[]): Promise<Suite<Request>[]>; loadRequests(locations: string[], ...moreLocations: string[]): Promise<Suite<Request>[]>; /** * Throws if location or suite not found */ loadRequestSuite(location: string): Promise<Suite<Request>>; /** * Load request suites. * @param locations can be URLs or file paths */ loadRequestsSync(location: string): Suite<Request>[]; loadRequestsSync(...locations: string[]): Suite<Request>[]; loadRequestsSync(locations: string[], ...moreLocations: string[]): Suite<Request>[]; /** * Throws if location or suite not found */ loadRequestSuiteSync(location: string): Suite<Request>; loadSuite(location: string): Promise<Suite<Request>>; loadSuiteSync(location: string): Suite<Request>; /** * Throws if location or suite not found */ loadCaseSuites(location: string): Promise<Suite<Case>[]>; loadCases(file: string): Promise<Suite<Case>[]>; loadCases(...files: string[]): Promise<Suite<Case>[]>; loadCases(files: string[], ...moreFiles: string[]): Promise<Suite<Case>[]>; /** * Throws if location or suite not found */ loadFlowSuites(location: string): Promise<FlowSuite[]>; loadFlow(file: string): Promise<FlowSuite>; loadFlows(file: string): Promise<FlowSuite[]>; loadFlows(...files: string[]): Promise<FlowSuite[]>; loadFlows(files: string[], ...moreFiles: string[]): Promise<FlowSuite[]>; } /** * A Plyee is a test (request/case), or a suite. * * Format: <absolute_suite_file_forward_slashes>#<optional_case_suite>^<test_name> * eg: c:/ply/ply/test/ply/requests/movie-queries.ply.yaml#moviesByYearAndRating * or: /Users/me/ply/ply/test/ply/cases/movieCrud.ply.ts#movie-crud^add new movie * or for a suite: /Users/me/ply/ply/test/ply/requests/movie-queries.ply.yaml * (TODO: handle caseFile#suite^case) */ export declare class Plyee { readonly path: string; private hash; private hat; constructor(suite: string, test: Test); constructor(path: string); get location(): string; get suite(): string; get test(): string | undefined; toString(): string; static isRequest(path: string): boolean; static isCase(path: string): boolean; static isFlow(path: string): boolean; /** * Maps plyee paths to Plyee by Suite. */ static requests(paths: string[]): Map<string, Plyee[]>; static cases(paths: string[]): Map<string, Plyee[]>; static flows(paths: string[]): Map<string, Plyee[]>; /** * Returns a map of unique suite location to Plyee[] * @param paths test paths * @param test (optional) for matching */ static collect(paths: string[], test?: (plyee: Plyee) => boolean): Map<string, Plyee[]>; } /** * Utility for executing multiple tests, organized into their respective suites. * Used by both CLI and vscode-ply. */ export declare class Plier extends EventEmitter { private readonly ply; /** * general purpose logger not associated with suite (goes to console) */ readonly logger: Log; get options(): PlyOptions; constructor(options?: Options, logger?: Log); /** * Plyees should be test paths (not suites). */ run(plyees: string[], runOptions?: RunOptions, plyVersion?: string): Promise<OverallResults>; /** * Finds plyees from suites and tests. * @param paths suite/test paths */ find(paths: string[]): Promise<string[]>; }