UNPKG

cumulocity-cypress

Version:
84 lines (83 loc) 3.16 kB
import { C8yTestHierarchyTree } from "../../shared/types"; import { C8yPact, C8yPactInfo, C8yPactRecord } from "../../shared/c8ypact"; import type { C8yAuthOptionType } from "../../shared/auth"; /** * Configuration options for C8yPactRunner. */ export interface C8yPactRunnerOptions { /** * Filter for consumer name. */ consumer?: string; /** * Filter for producer name. */ producer?: string; /** * Filter for methods. */ methods?: string[]; /** * Authentication type for the runner. Supported values are `CookieAuth`, `BasicAuth`, and `BearerAuth`. */ authType?: C8yAuthOptionType; /** * Path prefix filter for the runner. */ paths?: string[]; /** * Assertions for the runner. If one of the assertions fail on request execution, * the test will fail. */ assertions?: C8yPactRunnerAssertions; } export interface C8yPactRunnerAssertions { /** * Maximum request duration in milliseconds. If one request takes longer than this value, * the test will fail. If not set, no duration check is performed. */ maxRequestDuration?: number; } /** * Runtime for C8yPact objects. A runner will create the tests dynamically based on * the pact objects information and rerun recorded requests. */ export interface C8yPactRunner { /** * Runs all pact objects. Will create the tests dynamically for each pact object. * * @param pacts Pact objects to run. * @param options Runner options. */ run: (pacts: C8yPact[], options?: C8yPactRunnerOptions) => void; /** * Runs a single pact object. Needs to run within a test-case. * * @param pact Pact object to run. * @param options Runner options. */ runTest: (pact: C8yPact, options?: C8yPactRunnerOptions) => void; } /** * Default implementation of C8yPactRunner. Runtime for C8yPact objects that will * create the tests dynamically and rerun recorded requests. Supports Basic, Cookie, and Bearer based * authentication, id mapping, consumer and producer filtering and URL replacement. * * Use `C8Y_PACT_RUNNER_AUTH` to set the authentication type for the runner and overwrite * the authentication type detected in the pact records. Supported values are `CookieAuth`, `BasicAuth`, and `BearerAuth`. */ export declare class C8yDefaultPactRunner implements C8yPactRunner { constructor(); protected idMapper: { [key: string]: string; }; run(pacts: C8yPact[], options?: C8yPactRunnerOptions): void; protected createTestsFromHierarchy(hierarchy: C8yTestHierarchyTree<C8yPact>, options: C8yPactRunnerOptions): void; runTest(pact: C8yPact, options?: C8yPactRunnerOptions): void; protected createHeader(pact: C8yPactRecord): any; protected createFetchOptions(pact: C8yPactRecord, info: C8yPactInfo): any; protected createURL(pact: C8yPactRecord, info: C8yPactInfo): string | undefined; protected updateURLs(value: string, info: C8yPactInfo): string; protected updateIds(value: string): string; } export declare function getOptionsFromEnvironment(): C8yPactRunnerOptions;