CodeVetter · Repo Unpack · System map
pact-foundation/pact-js
The repository delivers an npm SDK whose public entrypoint exposes several generations of contract-testing APIs. JavaScript owns builder state, callbacks, and verification middleware, while pact-core owns native contract and mock-server operations. Generated pact files connect consumer and provider testing; release and documentation workflows distribute the package and synchronize documentation.
- src/index.ts exports PactV2, Verifier, legacy message APIs, V3 exports, and V4 exports; PactV4 is aliased as Pact and MatchersV3 as Matchers.
- PactV3 and PactV4 create ConsumerPact handles through makeConsumerPact and attach pact-js version metadata; their default specification versions are V3 and V4 respectively.
- The API generations use different orchestration structures: V2 exposes setup/addInteraction/verify, V3 owns a mutable current interaction, and V4 returns staged HTTP, synchronous, asynchronous, and GraphQL builders.
- Provider verification creates a temporary Express/http-proxy server with state and message endpoints, then passes its address and a message transport to serviceFactory.verifyPacts.
- Contract persistence is delegated to pact-core writePactFile calls using caller-selected directories or ./pacts; V2 additionally passes merge-versus-overwrite behavior.
- VerifierOptions combines pact-core options with local ProxyOptions; documented broker integration includes pactBrokerUrl, consumerVersionSelectors, broker authentication, and publishVerificationResult.
- package.json requires Node >=22 and defines npm scripts for tsc compilation/distribution, Biome formatting/linting, tsc --noEmit, Vitest, and regression testing; tsconfig emits declarations and source maps into dist.
- Publishing is dispatch-driven: latest checks out master and runs release.sh with SKIP_EXAMPLES=true, while the 9.x workflow checks out 9.x.x; Markdown pushes on master dispatch a docs.pact.io update.