@pact-foundation/pact
Version:
Pact for all things Javascript
33 lines (32 loc) • 1.85 kB
TypeScript
import type { ConsumerInteraction } from '@pact-foundation/pact-core';
import type { Rules, TemplateHeaders } from '../../v3';
import type { V4ResponseBuilder } from './types';
export declare class ResponseBuilder implements V4ResponseBuilder {
protected interaction: ConsumerInteraction;
constructor(interaction: ConsumerInteraction);
headers(headers: TemplateHeaders): V4ResponseBuilder;
jsonBody(body: unknown): V4ResponseBuilder;
xmlBody(body: unknown): V4ResponseBuilder;
binaryFile(contentType: string, file: string): V4ResponseBuilder;
/**
* Sets the response body as multipart/form-data content.
* This is useful for testing APIs that respond with multipart/form-data.
*
* @param contentType - The content type of the multipart body (e.g., 'multipart/form-data')
* @param file - Path to the file containing the multipart body content
* @param mimePartName - The name of the mime part in the multipart body
* @param boundary - Optional boundary string for the multipart content. If not provided, will be passed as undefined.
* @returns The V4ResponseBuilder instance for method chaining
*/
multipartBody(contentType: string, file: string, mimePartName: string, boundary?: string): V4ResponseBuilder;
/**
* Applies matching rules to the provider response.
* Matching rules allow you to define flexible matching criteria for response attributes
* beyond exact equality (e.g., regex patterns, type matching, number ranges).
*
* @param rules - The matching rules as a strongly typed Rules object. Rules should follow the Pact matching rules format.
* @returns The V4ResponseBuilder instance for method chaining
*/
matchingRules(rules: Rules): V4ResponseBuilder;
body(contentType: string, body: Buffer): V4ResponseBuilder;
}