CodeVetter
← All unpacks
CodeVetter · Repo Unpack evidence

pact-foundation/pact-js

Scanned commit 18f30a1aa4 dated 2026-10-02 — last upstream commit. Generated by codevetter 1.15.0 on 2026-10-02.

github.com/pact-foundation/pact-js ↗ · 318 files · 1.3 MB

Pact JS Fast, easy and reliable testing for your APIs and microservices.

Deep analysis by cli:codex via the codex CLI on 2026-10-02 (485s) — every claim below links to its cited source files. Source inspection; upstream code and tests were not executed.

Overview

Pact JS is a TypeScript contract-testing SDK for teams building HTTP APIs and message-based integrations. Consumer tests define expected interactions, exercise application clients or message handlers, and generate pact files; provider verification checks those contracts against running services or registered message producers. Its distinctive architecture combines versioned JavaScript builders with native pact-core operations, an Express verification proxy, flexible matching rules, and plugins for additional content types and transports.

System map

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.

Feature catalog

The public surface supports HTTP request/response contracts, asynchronous event contracts, synchronous messages, and GraphQL over HTTP. Matching APIs express flexible contracts while supplying concrete examples to consumer tests. Provider callbacks, broker options, interaction metadata, and plugins support more involved verification workflows.

Data flow

Consumer inputs become native interaction declarations rather than a JavaScript implementation of contract matching. Native mock servers or reified messages feed application callbacks, and successful orchestration writes contracts to disk. Provider verification routes native requests through JavaScript middleware, state callbacks, and message producers before returning results to the caller.

Behavior traces

Three concrete flows were followed through source: V4 HTTP consumer testing, HTTP provider verification, and V4 asynchronous message testing. Each trace follows declaration, execution, and persistence or result handling. The examples show application clients and handlers participating in those flows rather than treating the library's builders as the entire test.

Testing signals

Tests and CI were inspected, not executed; their existence establishes intended checks rather than passing results. Root Vitest combines mocked unit tests with native-backed integration tests, while examples and regression packages run consumer suites before provider suites. This is a bounded inspection, and the selected lifecycle specs do not establish coverage of every mismatch, persistence, transport, or cleanup failure branch.

Risk map

These findings are source observations and explicitly labeled hypotheses, not confirmed vulnerabilities. Sensitive boundaries include temporary HTTP listeners, request logging, caller-selected filesystem paths, and plugin executables installed outside the checkout. Failure handling deserves particular attention because ordinary state errors, experimental mismatch filtering, and cleanup exceptions follow different paths.

Extension points

Extension points are primarily typed builder stages and caller-provided callback registries. Matching declarations and explicit Rules provide two paths into native matching, while plugins add content and transport support. Changes to public capabilities must account for exports, types, concrete builders, and cleanup behavior together.

Contributor handoff

Tests and CI were inspected, not executed, and this inventory is bounded rather than exhaustive. Begin future work at the public export and the specific generation of API being changed, then follow its native calls and lifecycle tests. Preserve compatibility, inspect npm lifecycle side effects before requesting execution, and use source behavior to resolve documentation drift.

Languages

LanguageFilesShare of source
TypeScript19493%
JSON33docs/config
Markdown30docs/config
Shell147%
YAML11docs/config
JavaScript10%

Start reading here

Probable source entrypoint: src/index.ts — inferred from the directory tree and manifest, not the upstream docs.

Source roots

src/ (105 files)

Source layout — src/

PathFiles
src/common/13
src/dsl/32
src/errors/4
src/httpPact/5
src/v3/11
src/v4/28
src/xml/6
src/index.ts1
src/messageConsumerPact.spec.ts1
src/messageConsumerPact.ts1
src/messageProviderPact.spec.ts1
src/messageProviderPact.ts1
src/pact.integration.spec.ts1

Repository structure

Top-level pathFiles
src/105
regression/85
examples/60
docs/17
scripts/16
.github/14

Docs found: CONTRIBUTING.mdREADME.mddocs/consumer.mddocs/graphql.mddocs/matching.mddocs/messages.mddocs/migrations/16.mddocs/migrations/9-10.mddocs/plugins.mddocs/provider.md

Package

package.json — @pact-foundation/pact v17.1.4, 36 declared dependencies.

@babel/cli@babel/core@babel/preset-env@biomejs/biome@pact-foundation/pact-core@scarf/scarf@tsconfig/node22@types/express@types/http-proxy@types/lodash@types/nock@types/node

CI & config entrypoints

Structural health signals

Average score 9.2/10 across 96 analyzed source files; 1 hotspot surfaced.

These are deterministic review leads — size, churn, and structural signals — not proof of a bug in this project.

Recent history