https://github.com/acmachado14/simple-pact
This repository aims to exemplify, in a simple and practical way, the execution of contract tests with Pact using different languages for each application.
https://github.com/acmachado14/simple-pact
nodejs pact pact-broker php
Last synced: 3 months ago
JSON representation
This repository aims to exemplify, in a simple and practical way, the execution of contract tests with Pact using different languages for each application.
- Host: GitHub
- URL: https://github.com/acmachado14/simple-pact
- Owner: acmachado14
- License: gpl-3.0
- Created: 2022-07-09T19:46:28.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2023-12-03T03:59:49.000Z (over 2 years ago)
- Last Synced: 2023-12-03T23:24:25.005Z (over 2 years ago)
- Topics: nodejs, pact, pact-broker, php
- Language: PHP
- Homepage: https://youtu.be/z53dygLyFGQ
- Size: 256 KB
- Stars: 6
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
Contract Testing with Pact
# Description
This repository aims to exemplify, in a simple and practical way, the execution of contract tests with
Pact using different languages for each application.
# Flow
The flow used is as simple as possible to carry out the communication of the provider and consumer tests.
It is far from ideal for use in software productions!
If you want a complete flow for your application, I recommend
[Nirvana for contract test](https://github.com/PauloGoncalvesBH/nirvana-teste-de-contrato) which makes use of CI for verification steps.

## Pact Broker
The [Pact Broker](docker-compose.yml) is responsible for the communication between the systems, ensuring the execution of the tests
On both sides. Thus, the consumer sends the contract containing the information he expects to receive on a given route.
and the provider downloads this contract, executes it locally, checking if the data is being sent as expected and returns
test results for the Pact Broker.
### Prerequisites
- [Docker](https://docs.docker.com/get-docker/)
- [Docker-compose](https://docs.docker.com/compose/install/)
### Run Pact Broker
```
docker-compose up
```
## Consumer
O [consumer](./consumer) it is the application that consumes the API, it is responsible for making data requests to the provider.
#### Prerequisites
- Docker
### Install
```
make build
```
### Run terminal in docker
```
make run-it
```
### Run tests
```
npm run test:consumer
```
### Publish the contract
```
npm run pact:publish
```
## Provider
The [provider](./provider) is the application that promotes the API, is responsible for sending the data requested by the consumer.
#### Prerequisites
- PHP
- composer
### Up the application
```
php -S localhost:8000
```
### Run tests
```
vendor/bin/phpunit
```