ContractCase Contract Testing Suite
ContractCase is a next-generation consumer-driven contract testing framework, building on many of the lessons from maintaining the excellent Pact contract testing framework. Contract testing an effective way to get deployment confidence for your applications and services, giving much faster and more actionable feedback than any of the other approaches.
First time here?
If you're already familiar with Pact, you might be interested in the section written for users coming from Pact.
Contract testing lifecycle
- Define a contract (start here)
- Define examples
- Run tests to confirm the examples are correct
- Upload contracts to a broker
- Verify the contract (start here)
- Download contract from the broker
- Verify the contract
- Publish verification result to the broker
Incomplete documentation is in the sidebar on your left (or at the bottom on mobile). By way of apology for any breaking changes, at least one new page of documentation will be added every time a breaking change is released during the beta period.
Caveats and limitations
ContractCase is now available and should work for both client and server driven http/https contracts. Feedback on the ContractCase API / DSL and (especially) naming conventions very welcome. However, the following caveats should be kept in mind:
- ContractCase doesn't yet support merging of contracts. This means that your whole contract must be defined in one test file.
- ContractCase currently only has rudimentary support for the contract broker. It works, but it's not very configurable yet - if you have a use case that isn't yet supported and you'd like it prioritised, please open an issue.
- ContractCase currently is only compatible with Jest. At a later date, the jest support will be extracted, and the peer-dependency removed.
Although the test coverage is high, and great care has been taken to ensure that the results are correct, there may still be bugs. Please open an issue if you experience any problems.
These caveats will be updated as progress is made. You can follow the detailed progress by reading the maintainer todo list.
THE API IS UNSTABLE AND BREAKING CHANGES WILL HAPPEN IN MINOR VERSIONS BEFORE 1.0.0 IS RELEASED
I'm fine with all the caveats, how do I get started?
npm install --save-dev @contract-case/contract-case-jest
You may also need the peer dependencies:
npm install --save-dev jest@^29.4.3
If you just want to jump in to some examples, you can have a read of:
- The client-driven contract definition
- The client-driven contract verification
- The server-driven contract definition
- The server-driven contract verification.
If you build on those examples, make sure you remove
printResults: false and