UNPKG

@dfinity/pic

Version:

An Internet Computer Protocol canister testing library for TypeScript and JavaScript.

54 lines (53 loc) 1.5 kB
import { StartServerOptions } from './pocket-ic-server-types'; /** * This class represents the main PocketIC server. * It is responsible for maintaining the lifecycle of the server process. * See {@link PocketIc} for details on the client to use with this server. * * @category API * * @example * ```ts * import { PocketIc, PocketIcServer } from '@dfinity/pic'; * import { _SERVICE, idlFactory } from '../declarations'; * * const wasmPath = resolve('..', '..', 'canister.wasm'); * * const picServer = await PocketIcServer.create(); * const pic = await PocketIc.create(picServer.getUrl()); * * const fixture = await pic.setupCanister<_SERVICE>({ idlFactory, wasmPath }); * const { actor } = fixture; * * // perform tests... * * await pic.tearDown(); * await picServer.stop(); * ``` */ export declare class PocketIcServer { private readonly serverProcess; private readonly url; private constructor(); /** * Start a new PocketIC server. * * @param options Options for starting the server. * @returns An instance of the PocketIC server. */ static start(options?: StartServerOptions): Promise<PocketIcServer>; /** * Get the URL of the server. * * @returns The URL of the server. */ getUrl(): string; /** * Stop the server. * * @returns A promise that resolves when the server has stopped. */ stop(): Promise<void>; private static getBinPath; private static assertBinExists; }