UNPKG

@ply-ct/ply

Version:

REST API Automated Testing

249 lines (248 loc) 7.06 kB
/** * Ply options. Empty values are populated with Defaults. */ export interface Options { /** * Tests base directory ('.'). */ testsLocation?: string; /** * Request files glob pattern, relative to testsLocation ('**\/*.{ply.yaml,ply.yml}'). */ requestFiles?: string; /** * Case files glob pattern, relative to testsLocation ('**\/*.ply.ts'). */ caseFiles?: string; /** * Flow files glob pattern, relative to testsLocation ('**\/*.ply.flow'). */ flowFiles?: string; /** * File pattern to ignore, relative to testsLocation ('**\/{node_modules,bin,dist,out}\/**'). */ ignore?: string; /** * File pattern for requests/cases/flows that shouldn't be directly executed, relative to testsLocation. */ skip?: string; /** * Expected results base dir (testsLocation + '/results/expected'). */ expectedLocation?: string; /** * Actual results base dir (this.testsLocation + '/results/actual'). */ actualLocation?: string; /** * Result files live under a similar subpath as request/case files (true). * (eg: Expected result relative to 'expectedLocation' is the same as * request file relative to 'testsLocation'). */ resultFollowsRelativePath?: boolean; /** * Log file base dir (this.actualLocation). */ logLocation?: string; /** * Files containing values JSON (or CSV or XLSX). */ valuesFiles?: { [file: string]: boolean; }; /** * Results summary output JSON */ outputFile?: string; /** * Verbose output (false). Takes precedence over 'quiet' if both are true. */ verbose?: boolean; /** * The opposite of 'verbose' (false). */ quiet?: boolean; /** * Bail on first failure (false). */ bail?: boolean; /** * Validate for missing required input values. * Default is true unless 'submit' runOption. */ validate?: boolean; /** * Run suites in parallel. */ parallel?: boolean; /** * (For use with rowwise values). Number of rows to run per batch. */ batchRows?: number; /** * (For use with rowwise values). Delay in ms between row batches. */ batchDelay?: number; /** * Reporter output format. Built-in formats: json, csv, xlsx. * See https://github.com/ply-ct/ply-viz for more options. */ reporter?: string; /** * (When flows have loopback links). Max instance count per step (10). Overridable in flow design. */ maxLoops?: number; /** * Predictable ordering of response body JSON property keys -- needed for verification (true). */ responseBodySortedKeys?: boolean; /** * Response headers to exclude when generating expected results. */ genExcludeResponseHeaders?: string[]; /** * Media types to be treated as binary. */ binaryMediaTypes?: string[]; /** * Prettification indent for yaml and response body (2). */ prettyIndent?: number; } /** * Populated ply options. */ export interface PlyOptions extends Options { testsLocation: string; requestFiles: string; caseFiles: string; flowFiles: string; ignore: string; skip: string; expectedLocation: string; actualLocation: string; resultFollowsRelativePath: boolean; logLocation: string; valuesFiles: { [file: string]: boolean; }; outputFile?: string; verbose: boolean; quiet: boolean; bail: boolean; validate: boolean; parallel: boolean; batchRows: number; batchDelay: number; reporter?: string; maxLoops: number; responseBodySortedKeys: boolean; genExcludeResponseHeaders?: string[]; binaryMediaTypes?: string[]; prettyIndent: number; args?: any; } /** * Options specified on a per-run basis. */ export interface RunOptions { /** * Run test requests but don't verify outcomes. */ submit?: boolean; /** * Skip verify only if expected result does not exist. */ submitIfExpectedMissing?: boolean; /** * Create expected from actual and verify based on that. */ createExpected?: boolean; /** * Create expected from actual only if expected does not exist. */ createExpectedIfMissing?: boolean; /** * If untrusted, enforce safe expression evaluation without side-effects. * Supports a limited subset of template literal expressions. * Default is false assuming expressions from untrusted sources are evaluated. */ trusted?: boolean; /** * Import requests or values from external format (currently 'postman' or 'insomnia' is supported). * Overwrites existing same-named files. */ import?: 'postman' | 'insomnia'; /** * Import collections into request suites (.yaml files), instead of individual (.ply) requests. */ importToSuite?: boolean; /** * Generate report from previously-executed Ply results. See --reporter for options. */ report?: string; /** * Augment OpenAPI v3 doc at specified path with operation summaries, request/response samples, * and code snippets from Ply expected results. */ openapi?: string; /** * Import case suite modules from generated .js instead of .ts source (default = false). * This runOption needs to be set in your case's calls to Suite.run (for requests), * and also in originating the call to Suite.run (for the case(s)). */ useDist?: boolean; requireTsNode?: boolean; /** * Base file system location for custom flow steps */ stepsBase?: string; /** * If key is an expression, then simple subt is performed */ values?: { [key: string]: string; }; } /** * Locations are lazily inited to reflect bootstrapped testsLocation. */ export declare class Defaults implements PlyOptions { readonly testsLocation: string; private _expectedLocation?; private _actualLocation?; private _logLocation?; constructor(testsLocation?: string); requestFiles: string; caseFiles: string; flowFiles: string; ignore: string; skip: string; reporter: any; get expectedLocation(): string; get actualLocation(): string; get logLocation(): string; resultFollowsRelativePath: boolean; valuesFiles: {}; verbose: boolean; quiet: boolean; bail: boolean; validate: boolean; parallel: boolean; batchRows: number; batchDelay: number; maxLoops: number; responseBodySortedKeys: boolean; genExcludeResponseHeaders: string[]; binaryMediaTypes: string[]; prettyIndent: number; } export declare const PLY_CONFIGS: string[]; export declare class Config { private readonly defaults; options: PlyOptions; private yargsOptions; constructor(defaults?: PlyOptions, commandLine?: boolean, configPath?: string); private load; private read; }