POC for Contract Testing (Pact)
This POC is created using a nodejs library called Pact.
https://github.com/pact-foundation/pact-js
Pact is a contract testing tool. Contract testing is a way to ensure that services (such as an API provider and a client) can communicate with each other.
https://docs.pact.io/readme
How to use
Required packages and basic setup is done.
There are useful comments included so code should be pretty straight forward.
You're all set to start writing tests :-)
To Run Tests
yarn install
to install dependencies
yarn test:consumer
to run consumer tests against mock server and generate pact file
yarn publish:pacts
to start a docker http server and publish pacts to be accessible to provider
yarn test:provider
to run the pact file against the actual server and publish results back to http server
yarn test:e2e
to run the all the above steps in one go for end to end worklfow
Test Report
mochawesome reporter is used to capture and present the test results.
Test Report is available in ./mochawesome-report
in both json and html format