software · Q194
Pact JS
JavaScript consumer-driven contract tests for HTTP and message-based integrations.
Overview
Pact JS is the JavaScript implementation of Pact's consumer-driven contract-testing approach. Consumer tests generate examples of expected interactions, which a provider verifies separately, helping teams detect incompatible request and response assumptions without exercising the whole distributed system together.[2][3]
Testing the real consumer
A useful consumer test invokes the application's actual API client or message handler against Pact's test double. Calling the mock with a generic HTTP library while bypassing that application logic can generate a contract without testing how the consumer constructs requests or processes responses. Contracts describe the interactions consumers rely on rather than every possible behavior of the provider's complete API.[3][4]
What verification establishes
Pact focuses on agreement about messages and their structure. It does not establish that a provider persisted a record or performed another business side effect correctly; those are functional-test responsibilities. The distinction allows a provider to change internal rules without unnecessarily breaking consumer contracts, but it also means contract success is not a substitute for the provider's own business-logic tests.[5]
Message-based systems
Pact JS also tests asynchronous and synchronous message interactions. Its message approach abstracts the transport and stands in for the intermediary while checking the data handled or produced by application functions. Small adapters may be needed to fit the expected handler interface. This validates message compatibility, not the live configuration or delivery guarantees of a particular queue or broker.[6]
Runtime, licensing and contract exchange
The JavaScript library is MIT-licensed; inspected package metadata for version 17.1.4 requires Node.js 22 or newer. Contract files and provider-verification results can be shared through the separately deployed Pact Broker. Its documentation distinguishes self-hosting, which requires administration, from managed PactFlow. Using the library therefore does not itself provide a hosted contract registry or remove the need to coordinate provider verification.[1][7][8]
Substitution scope
Pact JS can substitute for Specmatic for interface-compatibility checks when a JavaScript team wants consumers' executable examples to define the tested contract. Specmatic instead emphasizes reusable API specifications for tests and mocks. This is a choice of testing workflow, not compatible contract files or identical coverage: replacing schema-driven checks requires deciding which consumer assumptions and unconsumed API surfaces still need separate validation.[2][3][9]
Capabilities & limitations
Consumer-driven contracts
supportedActual consumer tests generate interactions for provider verification.[3][4]
Consumer/provider interface compatibility · Node.js 22+ for inspected 17.1.4 · Version, plan and platform requirements apply
2 sources · check evidence
Exercise actual consumer logic rather than mock-only calls
vendor · checked 2026-10-07Consumer-driven contracts by example
vendor · checked 2026-10-07Message handler contracts
supportedTests message contents while abstracting the transport intermediary.[6]
Consumer/provider interface compatibility · Node.js 22+ for inspected 17.1.4 · Version, plan and platform requirements apply
1 source · check evidence
Message-content abstraction and handler adapters
vendor · checked 2026-10-07Provider business side effects
unsupportedContract verification does not establish functional side effects such as persistence.[5]
Consumer/provider interface compatibility · Node.js 22+ for inspected 17.1.4 · Version, plan and platform requirements apply
1 source · check evidence
Message compatibility is not side-effect verification
vendor · checked 2026-10-07Can substitute for
These are products or services this entry can replace. Check the task and limitations for each comparison.
References
- Pact JS license
MIT license
vendor · retrieved 2026-10-07 - Pact JS repository
JavaScript contract testing and framework integration
vendor · retrieved 2026-10-07 - Pact introduction
Consumer-driven contracts by example
vendor · retrieved 2026-10-07 - Writing Pact consumer tests
Exercise actual consumer logic rather than mock-only calls
vendor · retrieved 2026-10-07 - Contract tests versus functional tests
Message compatibility is not side-effect verification
vendor · retrieved 2026-10-07 - Pact JS event-driven systems
Message-content abstraction and handler adapters
vendor · retrieved 2026-10-07 - Pact JS package metadata
Version 17.1.4 engines.node requires >=22
vendor · retrieved 2026-10-07 - Pact Broker introduction
Self-hosted contract/result sharing versus managed PactFlow
vendor · retrieved 2026-10-07 - Specmatic spec-driven development
Executable specifications and mock validation
vendor · retrieved 2026-10-07
Discussion & disputes
Ask about unclear claims or explain a concern with supporting sources. If you have a specific fix, suggest a correction.
No discussion yet.
Revision history
Open a revision to read an earlier version of this article.
| Revision | Timestamp | Edit summary |
|---|---|---|
| 178 | 2026-10-10 14:25:38 | /* wbeditentity-create-item:0| */ sf:464f225e-8369-43de-89db-434411d60641:v1 | Add Pact JS with cited product identity, workflow and portability boundaries; documentation research only. | attribution: /proposals/464f225e-8369-43de-89db-434411d60641 |