back to home

pact-foundation / pact-js

JS version of Pact. Pact is a contract testing framework for HTTP APIs and non-HTTP asynchronous messaging systems.

View on GitHub
1,750 stars
351 forks
116 issues

AI Architecture Analysis

This repository is indexed by RepoMind. By analyzing pact-foundation/pact-js in our AI interface, you can instantly generate complete architecture diagrams, visualize control flows, and perform automated security audits across the entire codebase.

Our Agentic Context Augmented Generation (Agentic CAG) engine loads full source files into context on-demand, avoiding the fragmentation of traditional RAG systems. Ask questions about the architecture, dependencies, or specific features to see it in action.

Source files are only loaded when you start an analysis to optimize performance.

Embed this Badge

Showcase RepoMind's analysis directly in your repository's README.

[![Analyzed by RepoMind](https://img.shields.io/badge/Analyzed%20by-RepoMind-4F46E5?style=for-the-badge)](https://repomind.in/repo/pact-foundation/pact-js)
Preview:Analyzed by RepoMind

Repository Overview (README excerpt)

Crawler view

Pact JS Fast, easy and reliable testing for your APIs and microservices. **Pact** is the de-facto API contract testing tool. Replace expensive and brittle end-to-end integration tests with fast, reliable and easy to debug unit tests. • ⚔ Lightning fast • šŸŽˆ Effortless full-stack integration testing - from the front-end to the back-end • šŸ”Œ Supports HTTP/REST and event-driven systems • šŸ› ļø Configurable mock server • 😌 Powerful matching rules prevents brittle tests • šŸ¤ Integrates with Pact Broker / PactFlow for powerful CI/CD workflows • šŸ”” Supports 12+ languages **Why use Pact?** Contract testing with Pact lets you: • ⚔ Test locally • šŸš€ Deploy faster • ā¬‡ļø Reduce the lead time for change • šŸ’° Reduce the cost of API integration testing • šŸ’„ Prevent breaking changes • šŸ”Ž Understand your system usage • šŸ“ƒ Document your APIs for free • šŸ—„ Remove the need for complex data fixtures • šŸ¤·ā€ā™‚ļø Reduce the reliance on complex test environments Watch our series on the problems with end-to-end integrated tests, and how contract testing can help. Documentation This readme offers a basic introduction to the library. The full documentation for Pact JS and the rest of the framework is available at https://docs.pact.io/. • Installation • Consumer Testing • Matching • Provider Testing • Event Driven Systems • Plugins • GraphQL • XML • Examples • Migration guide • Troubleshooting Tutorial (60 minutes) Learn the key Pact JS features in 60 minutes: https://github.com/pact-foundation/pact-workshop-js Need Help • Join our community slack workspace. • Stack Overflow: https://stackoverflow.com/questions/tagged/pact • Say šŸ‘‹ on Twitter: [@pact_up] Installation Looking for the previous stable 9.x.x release? Requirements Node 16+ as of pact-js v12 • If using pact-js v11 or lower, • make sure the option is disabled, pact uses npm scripts to compile native dependencies and won't function without it. • Pact uses native extensions and installs them via the package. This requires a build chain for a successful installation. See also issue #899. This is now prebuilt in pact-js v12+ Do Not Track In order to get better statistics as to who is using Pact, we have an anonymous tracking event that triggers when Pact installs for the first time. The only things we track are your type of OS, and the version information for the package being installed. No PII data is sent as part of this request. You can disable tracking by setting the environment variable : Usage Consumer package The main consumer interfaces are the class and exports of the package. Writing a Consumer test Pact is a consumer-driven contract testing tool, which is a fancy way of saying that the API writes a test to set out its assumptions and needs of its API (s). By unit testing our API client with Pact, it will produce a that we can share to our to confirm these assumptions and prevent breaking changes. In this example, we are going to be testing our User API client, responsible for communicating with the over HTTP. It currently has a single method that will return a . Pact tests have a few key properties. We'll demonstrate a common example using the 3A pattern. You can see (and run) the full version of this in , as well as other examples in the parent folder. To run the examples • Clone the repo Run a single example • Change into the required example folder • Install all the examples dependencies • Run all the example - Run all examples • Change into the examples folder • Run all examples Provider package The main provider interface is the class of the package. Verifying a Provider A provider test takes one or more pact files (contracts) as input, and Pact verifies that your provider adheres to the contract. In the simplest case, you can verify a provider as per below using a local pact file, although in practice you would usually use a Pact Broker to manage your contracts and CI/CD workflow. It's best to run Pact verification tests as part of your unit testing suite, so you can readily access stubbing, IaC and other helpful tools. Compatibility Specification Compatibility | Version | Stable | [Spec] Compatibility | Install | | ------- | ------ | -------------------- | ------------------ | | 11.x.x + | Yes | 2, 3, 4 | See [installation] | | 10.x.x | Yes | 2, 3, 4 | See [installation] | | 9.x.x | Yes | 2, 3\* | [9xx] | _\*_ v3 support is limited to the subset of functionality required to enable language inter-operable [Message support]. Supported Platforms | OS | Architecture | Supported | Pact-JS Version | | ------------- | ------------ | --------- | ---------------- | | MacOS | x86_64 | āœ… | All | | MacOS | arm64 | āœ… | 9.x + | | Linux (libc) | x86_64 | āœ… | All | | Linux (libc) | arm64 | āœ… | 10.x + | | Linux (musl) | x86_64 | āœ… | 13.x + | | Linux (musl) | arm64 | āœ… | 13.x + | | Windows | x86_64 | āœ… | All | | Windows | x86 | āŒ | 9.x - | | Windows | arm64 | āŒ | - | Roadmap The roadmap for Pact and Pact JS is outlined on our main website. Contributing See CONTRIBUTING. [spec]: https://github.com/pact-foundation/pact-specification [10xx]: https://github.com/pact-foundation/pact-js/tree/10.x.x [9xx]: https://github.com/pact-foundation/pact-js/tree/9.x.x [pact website]: http://docs.pact.io/ [@pact_up]: https://twitter.com/pact_up [pact specification v2]: https://github.com/pact-foundation/pact-specification/tree/version-2 [pact specification v3]: https://github.com/pact-foundation/pact-specification/tree/version-3 [library]: https://github.com/pact-foundation/pact-reference/releases [installation]: #installation [message support]: https://github.com/pact-foundation/pact-specification/tree/version-3#introduces-messages-for-services-that-communicate-via-event-streams-and-message-queues [changelog]: https://github.com/pact-foundation/pact-js/blob/master/CHANGELOG.md [pact broker]: https://github.com/pact-foundation/pact_broker [pactflow]: https://pactflow.io