Skip to main content

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.

Briefcase image

Briefcase sticker created by Gohsantosadrive on Flaticon

First time here?

New to contract testing? Have a read of what is contract testing, then follow on with defining contracts.

If you're already familiar with Pact, you might be interested in the section written for users coming from Pact.

Contract testing lifecycle

  1. Define a contract (start here)
    1. Define examples
    2. Run tests to confirm the examples are correct
    3. Upload contracts to a broker
  2. Verify the contract (start here)
    1. Download contract from the broker
    2. Verify the contract
    3. 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:

  1. ContractCase doesn't yet support merging of contracts. This means that your whole contract must be defined in one test file.
  2. 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.
  3. 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.

ContractCase is currently only available in Javascript / Typescript. At a later date, support for Python, Java, C# and Go will be added, using JSii. There are no plans to add other languages at this time.

These caveats will be updated as progress is made. You can follow the detailed progress by reading the maintainer todo list.



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:

If you build on those examples, make sure you remove printResults: false and logLevel: none.

You will probably have a better time if you read the documentation on what is contract testing and defining contracts first, though.