cumulocity-cypress
Version:
Cypress commands for Cumulocity IoT
65 lines (64 loc) • 2.19 kB
TypeScript
import { C8yPact, C8yPactSaveKeys } from "../c8ypact";
/**
* Using C8yPactFileAdapter you can implement your own adapter to load and save pacts using any format you want.
* This allows loading pact objects from different sources, such as HAR files, pact.io, etc.
*
* The default adapter is C8yPactDefaultFileAdapter which loads and saves pact objects from/to
* json files using C8yPact objects. Default location is cypress/fixtures/c8ypact folder.
*/
export interface C8yPactFileAdapter {
/**
* Loads all pact objects. The key must be the pact id used in C8yPact.id.
*/
loadPacts: () => {
[key: string]: C8yPact;
};
/**
* Loads a pact object by id from file.
*/
loadPact: (id: string) => C8yPact | null;
/**
* Saves a pact object.
*/
savePact: (pact: C8yPact) => void;
/**
* Deletes a pact object or file.
*/
deletePact: (id: string) => void;
/**
* Gets the folder where the pact files are stored.
*/
getFolder: () => string;
/**
* Checks if a pact exists for a given id.
*/
pactExists(id: string): boolean;
/**
* Provides some custom description of the adapter.
* @example C8yPactFileAdapter
*/
description(): string;
}
/**
* Default implementation of C8yPactFileAdapter which loads and saves pact objects from/to
* json files using C8yPact objects.
*/
export declare class C8yPactDefaultFileAdapter implements C8yPactFileAdapter {
folder: string;
constructor(folder: string);
description(): string;
getFolder(): string;
loadPacts(): {
[key: string]: C8yPact;
};
loadPact(id: string): C8yPact | null;
pactExists(id: string): boolean;
savePact(pact: C8yPact | Pick<C8yPact, C8yPactSaveKeys>): void;
deletePact(id: string): void;
readJsonFiles(): string[];
protected deleteJsonFiles(): void;
protected loadPactObjects(): any[];
protected createFolderRecursive(f: string): string | undefined;
protected toAbsolutePath(f: string): string;
protected isNodeError<T extends new (...args: any) => Error>(error: any, type: T): error is InstanceType<T> & NodeJS.ErrnoException;
}