{"schemaVersion":"1.0","record":{"label":"Pact JS","description":"JavaScript consumer-driven contract tests for HTTP and message-based integrations.","aliases":[],"kind":"software","website":"https://docs.pact.io/implementation_guides/javascript/","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.","license":"MIT","lifecycle":"active","example":false,"features":[{"name":"Consumer-driven contracts","status":"supported","detail":"Actual consumer tests generate interactions for provider verification.","useCase":"Consumer/provider interface compatibility","platforms":["Node.js 22+ for inspected 17.1.4"],"region":"Version, plan and platform requirements apply","evidence":[{"url":"https://docs.pact.io/consumer","locator":"Exercise actual consumer logic rather than mock-only calls","retrievedAt":"2026-10-07T11:14:10Z","kind":"vendor"},{"url":"https://docs.pact.io/","locator":"Consumer-driven contracts by example","retrievedAt":"2026-10-07T11:14:10Z","kind":"vendor"}]},{"name":"Message handler contracts","status":"supported","detail":"Tests message contents while abstracting the transport intermediary.","useCase":"Consumer/provider interface compatibility","platforms":["Node.js 22+ for inspected 17.1.4"],"region":"Version, plan and platform requirements apply","evidence":[{"url":"https://docs.pact.io/implementation_guides/javascript/docs/messages","locator":"Message-content abstraction and handler adapters","retrievedAt":"2026-10-07T11:15:17Z","kind":"vendor"}]},{"name":"Provider business side effects","status":"unsupported","detail":"Contract verification does not establish functional side effects such as persistence.","useCase":"Consumer/provider interface compatibility","platforms":["Node.js 22+ for inspected 17.1.4"],"region":"Version, plan and platform requirements apply","evidence":[{"url":"https://docs.pact.io/consumer/contract_tests_not_functional_tests","locator":"Message compatibility is not side-effect verification","retrievedAt":"2026-10-07T11:14:10Z","kind":"vendor"}]}],"alternatives":[],"slug":"pact-js","draftAlternatives":[{"targetSlug":"specmatic","status":"limited","detail":"Can replace interface-compatibility testing with JavaScript consumer-driven examples; schema-driven coverage and artifacts differ.","useCase":"Consumer/provider interface compatibility","platforms":["Node.js 22+ for inspected 17.1.4"],"region":"Version, plan and platform requirements apply","evidence":[{"url":"https://docs.pact.io/","locator":"Consumer-driven contracts by example","retrievedAt":"2026-10-07T11:14:10Z","kind":"vendor"},{"url":"https://github.com/pact-foundation/pact-js/blob/master/README.md","locator":"JavaScript contract testing and framework integration","retrievedAt":"2026-10-07T11:14:26Z","kind":"vendor"},{"url":"https://docs.specmatic.io/contract_driven_development","locator":"Executable specifications and mock validation","retrievedAt":"2026-10-07T11:14:19Z","kind":"vendor"}]}],"evidence":[{"url":"https://github.com/pact-foundation/pact-js/blob/master/README.md","locator":"JavaScript contract testing and framework integration","retrievedAt":"2026-10-07T11:14:26Z","kind":"vendor"},{"url":"https://docs.pact.io/","locator":"Consumer-driven contracts by example","retrievedAt":"2026-10-07T11:14:10Z","kind":"vendor"}],"document":{"version":1,"references":[{"url":"https://github.com/pact-foundation/pact-js/blob/master/LICENSE","locator":"MIT license","retrievedAt":"2026-10-07T11:14:41Z","id":"pact-js-license","title":"Pact JS license","kind":"vendor"},{"url":"https://github.com/pact-foundation/pact-js/blob/master/README.md","locator":"JavaScript contract testing and framework integration","retrievedAt":"2026-10-07T11:14:26Z","id":"pact-js-readme","title":"Pact JS repository","kind":"vendor"},{"url":"https://docs.pact.io/","locator":"Consumer-driven contracts by example","retrievedAt":"2026-10-07T11:14:10Z","id":"pact-intro","title":"Pact introduction","kind":"vendor"},{"url":"https://docs.pact.io/consumer","locator":"Exercise actual consumer logic rather than mock-only calls","retrievedAt":"2026-10-07T11:14:10Z","id":"pact-consumer","title":"Writing Pact consumer tests","kind":"vendor"},{"url":"https://docs.pact.io/consumer/contract_tests_not_functional_tests","locator":"Message compatibility is not side-effect verification","retrievedAt":"2026-10-07T11:14:10Z","id":"pact-functional","title":"Contract tests versus functional tests","kind":"vendor"},{"url":"https://docs.pact.io/implementation_guides/javascript/docs/messages","locator":"Message-content abstraction and handler adapters","retrievedAt":"2026-10-07T11:15:17Z","id":"pact-js-messages","title":"Pact JS event-driven systems","kind":"vendor"},{"url":"https://github.com/pact-foundation/pact-js/blob/master/package.json","locator":"Version 17.1.4 engines.node requires >=22","retrievedAt":"2026-10-07T11:16:07Z","id":"pact-js-runtime","title":"Pact JS package metadata","kind":"vendor"},{"url":"https://docs.pact.io/pact_broker","locator":"Self-hosted contract/result sharing versus managed PactFlow","retrievedAt":"2026-10-07T11:14:10Z","id":"pact-broker-intro","title":"Pact Broker introduction","kind":"vendor"},{"url":"https://docs.specmatic.io/contract_driven_development","locator":"Executable specifications and mock validation","retrievedAt":"2026-10-07T11:14:19Z","id":"specmatic-model","title":"Specmatic spec-driven development","kind":"vendor"}],"overviewCitations":["pact-js-readme","pact-intro"],"licenseCitations":["pact-js-license"],"sections":[{"id":"consumer","heading":"Testing the real consumer","paragraphs":[{"id":"consumer-detail","content":[{"text":"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."}],"citations":["pact-consumer","pact-intro"]}]},{"id":"scope","heading":"What verification establishes","paragraphs":[{"id":"scope-detail","content":[{"text":"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."}],"citations":["pact-functional"]}]},{"id":"messaging","heading":"Message-based systems","paragraphs":[{"id":"messaging-detail","content":[{"text":"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."}],"citations":["pact-js-messages"]}]},{"id":"sharing","heading":"Runtime, licensing and contract exchange","paragraphs":[{"id":"sharing-detail","content":[{"text":"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."}],"citations":["pact-js-license","pact-js-runtime","pact-broker-intro"]}]},{"id":"fit","heading":"Substitution scope","paragraphs":[{"id":"fit-detail","content":[{"text":"Pact JS can substitute for "},{"text":"Specmatic","targetSlug":"specmatic"},{"text":" 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."}],"citations":["pact-intro","pact-js-readme","specmatic-model"]}]}]},"id":"Q194","revision":178,"updatedAt":"2026-10-10T14:25:38Z","sourceUrl":"https://substitutefor.net/entities/Q194?revision=178"}}