UNPKG

@pact-foundation/pact

Version:
70 lines (69 loc) 2.15 kB
import { Interaction, type InteractionObject } from '../dsl/interaction'; import type { MockService } from '../dsl/mockService'; import type { PactV2Options, PactV2OptionsComplete } from '../dsl/options'; /** * Creates a new {@link PactProvider}. * @memberof Pact * @name create * @param {PactV2Options} opts * @return {@link PactProvider} */ export declare class Pact { static defaults: PactV2Options; static createOptionsWithDefaults(opts: PactV2Options): PactV2OptionsComplete; mockService: MockService; opts: PactV2OptionsComplete; private mockServerStartedPort?; private pact; private interaction; private finalized; constructor(config: PactV2Options); /** * Setup the pact framework, including allocating a port for the dynamic * mock server * * @returns {Promise} */ setup(): Promise<PactV2OptionsComplete>; /** * Add an interaction to the {@link MockService}. * @memberof PactProvider * @instance * @param {Interaction} interactionObj * @returns {Promise} */ addInteraction(interactionObj: InteractionObject | Interaction): Promise<string>; /** * Checks with the Mock Service if the expected interactions have been exercised. * @memberof PactProvider * @instance * @returns {Promise} */ verify(): Promise<string>; /** * Writes the Pact and clears any interactions left behind and shutdown the * mock server * @memberof PactProvider * @instance * @returns {Promise} */ finalize(): Promise<void>; /** * Writes the pact file out to file. Should be called when all tests have been performed for a * given Consumer <-> Provider pair. It will write out the Pact to the * configured file. * @memberof PactProvider * @instance * @returns {Promise} */ writePact(): Promise<string>; /** * Clear up any interactions in the Provider Mock Server. * @memberof PactProvider * @instance * @returns {Promise} */ removeInteractions(): Promise<string>; private startMockServer; private reset; }